Posts

Showing posts from July 24, 2018

Woocommerce Restrict My Account Page but NOT Lost Password Page

Woocommerce Restrict My Account Page but NOT Lost Password Page I have a WordPress site with Woocommerce. In Woocommerce, Lost Password URL merges with My Account page (www.site.com/my-account/lost-password/) . (www.site.com/my-account/lost-password/) Then I create a redirect function that will redirect non-logged in users when they hit "My Account" page to "Login" page. This means I limit them too to access the Lost Password page. add_action( 'wp', 'redirect' ); function redirect() { if ( is_page(array('my-account', 'payment-screen', 'submit-resume', 'post-a-job')) && !is_user_logged_in() ) { wp_redirect( home_url('/login') ); die(); } elseif ( is_page(array( 'register', 'login' )) && is_user_logged_in() ) { wp_redirect( home_url('/my-account') ); die(); } } I want to restrict non-logged in users only for www.site.com/my-account/ and redire

Distributed Computation for large data-data processing

Distributed Computation for large data-data processing I have a huge time series data and I want to do data processing using spark`s parallel processing/distributed computation. The requirement is looking at the data row by row to determine the groups as specified below under desired result sections, I can't really get spark to distribute this without some kind of coordination between the executors For instance : Taking a small part of sample data-set for explaining the case t lat long 0 27 28 5 27 28 10 27 28 15 29 49 20 29 49 25 27 28 30 27 28 Desired Output should be : Lat-long interval (27,28) (0,10) (29,49) (15,20) (27,28) (25,30) I am able to get the desired result using this piece of code val spark = SparkSession.builder().master("local").getOrCreate() import spark.implicits._ val df = Seq( (0, 27,28), (5, 27,28), (10, 27,28), (15, 26,49), (20, 26,49), (25, 27,28), (30, 27,28) ).toDF("t", "lat","long&quo

Xception input_shape channels

Xception input_shape channels I'm new with Keras. I'm working on the Keras Xception model (version 2.2.0) witch I have successfully trained with RGB images. My resources are limited and therefore have converted the images into grey scale to reduce the data size (I am not sure if this is correct just an intuition). My current dataset consists of grayscale image and as mush as I studies keras pretrained models expect 3 channel input. I've tried the code below to generate image data: train_generator = train_datagen.flow_from_directory( train_folder, target_size=(img_width, img_height), color_mode='grayscale', batch_size=batch_size, shuffle=True, seed=seed) and then built the model as follow: model = xception.Xception(include_top=False, input_shape=(img_width, img_height, 1)) model = xception.Xception(include_top=False, input_shape=(img_width, img_height, 1)) but I get the error: ValueError: The input must have 3 channels; got input_shape=(257, 321, 1) input_shape=(257,

Configuration object Pattern in PHP

Configuration object Pattern in PHP I am trying to understand what Configuration Object pattern is. For instance in php, how to write the following class using Configuration Object pattern? class User extends People { public function __construct($name , $email){} } You can check good documentation here ibm.com/developerworks/library/os-php-config/index.html – SynapseIndia 6 hours ago 1 Answer 1 Like this: class User extends People { private $name; private $email; public function __construct($conf){ $this->name = $conf->name; $this->email = $conf->email; } } Of course this pattern is for much more complicated situations, when you want to configure DB connection or some API client or smth like that. This patt

Get-PartitionSupportedSize is failing with error

Get-PartitionSupportedSize is failing with error Here is the command which I am using: for $disk in Get-Disk $allowedSize = (Get-PartitionSupportedSize -DiskNumber $disk.Number -PartitionNumber $partitionNum).SizeMax Here is the stack: Not able to find any good links for the same, so any leads are appreciated. First, your for loop is formatted incorrectly, your going to have errors if you have multiple partitions on the same drive, they are all going to be in bytes, How are you going to match the get-disk friendly name with the sizemax? If you want to work it out and go from there, I can appreciate that. If you want the answer, just ask. – Drew Lean 7 hours ago 2 Answers 2 Few small things This worked for me $PartitionNum=3 #or whatever You need f

Generate number sequence with step size in linq

Generate number sequence with step size in linq I need to generate a sequence of numbers using C# linq. Here is how I have done it using for loop. int startingValue = 1; int endValue = 13; int increment = 5; for (int i = startingValue; i <= endValue; i += increment) { Console.WriteLine(i); } check this article on generating sequence numbers in LINQ – Karthik Chintala 6 hours ago Replace Console.WriteLine(i) with yield return i and wrap it in a method that returns an IEnumerable<int> and you're done. Iterator methods are nice like that. – Jeroen Mostert 6 hours ago Console.WriteLine(i) yield return i IEnumerable<int> Where does this 'need&#

How do I instruct artisan to save model to specific directory?

How do I instruct artisan to save model to specific directory? I'm using Laravel 5. I have created a /Models directory under the /App directory, but when generating the models using Artisan it's storing them under the App directory. /Models /App App I have searched the documentation to try and find how to specify a different path name, but to no avail: php artisan make:model TestModel How do I instruct artisan to save the model to specific directory? artisan Are you making models so often it's too much work to just move them where you want them? – ceejayoz Jan 29 '15 at 21:43 Yes. There's 17 models in total, with various relationships, and the possibility of the models growing as more features are implemented. I do not want them under the /app directory. It's not the place for them an

Get rid of Unchecked overriding: return type requires unchecked conversion

Get rid of Unchecked overriding: return type requires unchecked conversion Example code similar to my code. public interface Builder<B, A> { B build(A a); } public class ClientBuilder implements Builder<String, Integer> { @Override public String build(Integer i) { return i.toString(); } } public abstract class Client<B> { protected abstract <A> Builder<B, A> getBuilder(); } public class ClientClient extends Client<String> { @Override protected Builder<String, Integer> getBuilder() { return null; } } In my ClientClient class I get a warning that says the following: ClientClient Unchecked overriding: return type requires unchecked conversion.Found 'Builder<java.lang.String,java.lang.Integer>', required 'Builder<java.lang.String,A> Unchecked overriding: return type requires unchecked conversion.Found 'Builder<java.lang.String,java.lang.Integer>', required 'Builder<java.lang.Stri

code prints incorrect output in in jupyter notebook whereas it is running correctly on online IDE

code prints incorrect output in in jupyter notebook whereas it is running correctly on online IDE # Program for Armstrong Number # this program prints wrong results in jupyter but running correct in online ide import math print("this program is for armstrong numbern") m=0 p=0 n=int(input("Enter any number: n")) y=n while y!=0: y=y/10 p+=1 y=n while n!=0: x=n%10 m+=math.pow(x,p) n=n/10 if y==m: print("The given number is an armstrong numbern") else: print("The given number is not an armstrong numbern") I know about indentation in python and i use it here – sy254191 6 hours ago Please paste your code as it is, select it and click on {} to format it as code. – Thierry Lathuille

Varying number of div layout

Varying number of div layout I'm trying to generate a layout which has varying number of divs, I.e. | Large | Large | |Small | Small | Small | | Large | Large | ... Large divs will have 50% width, whereas smaller one's will have 33%. How can I go about this? I'm floating the div's so that they're in a row, but unsure on how I can get three smaller divs, below the larger ones, whilst still ensuring everything is central? Current approach: .case-card--large { width: 50%; float: right; } .case-card { float: right; text-align: center; padding: 40px; width: 33%; border: 1px solid blue; } <div class="case-card case-card--large"> <div class="wrapper"> <p>Dummy text</p> </div> </div> <div class="case-card case-card--large"> <div class="wrapper"> <p>Dummy text</p> </div> </div> <div class="case-card"> &

How to reset gulp cache on node project?

How to reset gulp cache on node project? I am using mocha tests and it seems that the test file is caching somehow.. Is there any command to reset the cache on gulp project? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to sort JSON in swift based on persian characters

How to sort JSON in swift based on persian characters i am new to swift , i going to sort a json file in bundle not by code , is there anyway to sort the file using by code or not , i want to sort it from "citname":"لومار" the json file is : { "data":[ { "_id":1, "citproidint":4, "citname":"لومار" }, { "_id":2, "citproidint":4, "citname":"ايوان" }, { "_id":3, "citproidint":12, "citname":"آبعلی" }, { "_id":4, "citproidint":25, "citname":"نيشابور" }, { "_id":5, "citproidint":27, "citname":"سقز" },

Python - Group-by multiple columns with .mean() and .agg()

Python - Group-by multiple columns with .mean() and .agg() I want to group-by three columns, and then find the mean of a fourth numerical column for all rows which are duplicated across the first three columns. I can achieve this with the following function: df2 = df.groupby(['col1', 'col2', 'col3'], as_index=False)['col4'].mean() The problem is that I also want a fifth column which will aggregate for all rows grouped by the groupby function, which I don't know how to do on top of the previous function. For example: df index col1 col2 col3 col4 col5 0 Week_1 James John 1 when and why? 1 Week_1 James John 3 How? 2 Week_2 James John 2 Do you know when? 3 Week_2 Mark Jim 3 What time? 4 Week_2 Andrew Simon 1 How far is it? 5 Week_2 Andrew Simon 2

How to optimize the code for 10 power 5 output

How to optimize the code for 10 power 5 output Please help me to find out how to optimize this code for 10 to the power 5 output in java. It's show time limit error. Even i try to use HashMap in place of DP array. I tried all the method which i know to optimize this. For bigger output i used long as datatype. public static void main(String args) throws Exception { Scanner s = new Scanner(System.in); int t = s.nextInt(); HashMap<Long, Long> hash = new HashMap<Long, Long>(); for (int i = 0; i < t; i++) { int n = s.nextInt(); int a = s.nextInt(); int b = s.nextInt(); long val = Long.MAX_VALUE; if (a == b) { if (n % 2 == 0) { int ans = (n / 2) * (n / 2); val = (a * ans) + (b * ans); } else { int ans = n / 2; val = (a * (ans * ans)) + (b * ((ans + 1) * (ans + 1))); } } else { for (long j = 0; j <

print number having digit 3 or 6 from 1 to 1000.like 3 ,6,13,16…996,

print number having digit 3 or 6 from 1 to 1000.like 3 ,6,13,16…996, Here is my code. When the value of the number is less than 100, output is correct but when the value of number is 1000.output is wrong import java.util.*; public class Test { public static void main(String args) { int i,x,y,z,num; int number=1; for(;number<1000;number++) { i=number; while (i > 0) { z=i%10; //System.out.println( "digit="+z); if(((z%3==0)&&(z%9!=0)&&(z!=0))||(z%6==0)&&(z!=0)) //condition for divisiblity by 3 or 6 and not by 9 { System.out.println( "number="+number); break; } i = i / 10; } } } } because your loop is till 999 only – Aman Chhabra 27 mins ago

RTL not working for a Layout

RTL not working for a Layout I add all the necessary things to support RTL for an english arabic application android:supportsRtl="true" to the element in manifest file. Change all of "left/right" layout properties to new "start/end" equivalents. everything works fine except this layout still blank in RTL but it LTR it works like a charm: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:background="@color/white" android:layoutDirection="rtl" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/limit_levels" android:layout_width="match_parent" android:gravity="center" android:layout_weight="1" android:layout_margin="5dp" android:la