Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-09-23T21:24:57Z
Updated: 2 hours 5 min ago

wordpress W3 Total Cache Fragmented Caching not working

Sat, 06/03/2017 - 21:50

Sorry for my bad English.

I used this code to test w3 total cache fragment caching :

<?php /* Template Name: test */ ?> <?php echo date("H:i:s"); ?> <br> <!-- mfunc FRAGMENT_CACHING --> echo date("H:i:s"); <!-- /mfunc FRAGMENT_CACHING -->

And I added this line to the wp-config.php file :

define('W3TC_DYNAMIC_SECURITY', 'FRAGMENT_CACHING');

But I want to be cached the first time.

And the second time to be updated.

I've purchased Pro version.

Drupal 8 - migrate image field from CSV with multiple values

Sat, 06/03/2017 - 21:50

I'm trying to populate a new Drupal 8 (8.3.2) site with content from a CSV file, using core's Migrate module, Migrate Source CSV, Migrate Tools and Migrate Plus. I'm able to import each node successfully with a single image, but I'm unsure of how to migrate multiple images into the node's multi-value image field.

My module currently looks like this:

id: product_data label: Products migration_group: product_migration migration_tags: - node - product source: plugin: csv path: 'public://import/products/products.full.csv' header_row_count: 1 keys: - product_sku constants: bool_0: 0 bool_1: 1 uid_root: 1 restricted_html: restricted_html destination: plugin: 'entity:node' default_bundle: product process: title: product_name field_sku: product_sku sticky: constants/bool_0 promote: constants/bool_1 uid: constants/uid_root 'field_image/target_id': plugin: migration migration: poduct_image source: product_full_image migration_dependencies: optional: - product_image dependencies: enforced: module: - custom_migration

And to create the image entities:

id: product_image label: Images associated with a product. migration_group: product_migration migration_tags: - product - file - image source: plugin: csv path: 'public://import/products/products.full.csv' header_row_count: 1 keys: - product_full_image fields: product_full_image: Name of the image file associated with the program. constants: file_source_uri: public://import/products/old-images file_dest_uri: 'public://program/image' destination: plugin: 'entity:file' process: file_source: - plugin: concat delimiter: / source: - constants/file_source_uri - product_full_image - plugin: urlencode file_dest: - plugin: concat delimiter: / source: - constants/file_dest_uri - product_full_image - plugin: urlencode filename: product_full_image uri: plugin: file_copy source: - '@file_source' - '@file_dest' dependencies: enforced: module: - custom_migration

And the csv file is formatted like this:

product_sku,product_name,product_full_image C242,couch,Blue Couch,"image1.jpg,image2.jpg" C243,chair,Red Chair,image3.jpg

I've tried to work with the expload and iterator plugins, but honestly I'm totally lost here. Any ideas would be greatly appreciated.

how to solve the error when convert string date to integer?

Sat, 06/03/2017 - 21:50

I would like to convert my string date to int but I get an error, example of my date dim. janv. 23 24:00:00 +0000 2011. This is part of my code :

String created_at = (String) jsonObject.get("created_at"); System.out.println("la date de création de tweet est: " + created_at); DateFormat df = new SimpleDateFormat(" ddd. MMMM. EE HH:mm:ss z yyyy"); String s= df.format(created_at); int out=Integer.valueOf(s); System.out.println("new date " +out);

And the output is:java.lang.IllegalArgumentException: Cannot format given Object as a Date. Someone can help me please!

How to extract weights and biases in h2o model if export_weights_and_bias argument was set to FALSE?

Sat, 06/03/2017 - 21:50

I have an h2o deeplearning model, "model1", that generalizes very well. Unfortunately, I forgot to set export weights and biases = TRUE when building the model.

I've tried to retrain numerous models with all the exact parameters, seed, and dataset as in the original model1 plus added set export weights and biases to true.

Unfortunately none of these new models generalize well at all. In fact they all fail miserably to generalize - although all models train, validate, cross-validate and test very well. I've even tried checkpointing the original model1 so I can add the export weights and biases argument = TRUE. However, because I did not use Modulo CV, I'm unable to checkpoint.

Irreproducibility is giving me a huge headache. In order for me to productionalize, I need to somehow extract the weights and biases of this original, working model1 - despite export weights and biases being originally set to FALSE.

I've looked at the mean weights and biases of model1 and they simply do not match any of mean weights and biases of my retrained models with same parameters, seed, dataset, etc. I'm uncertain if mean weights and biases can be used somehow to force reproducibility.

I've read that downloading model1 to POJO may allow access to the weights and biases, but I'm uncertain about this, I don't know java and I don't see any example java code to help me along.

Any suggestions or other possible solutions/workarounds?

Thank you in advance for any help.

Can't establish TCP Peer connection

Sat, 06/03/2017 - 21:49
UDP - Sent: tracker.leechers-paradise.org:6969 :: 0 0 4 17 27 10 19 80 0 0 0 0 0 60 0 0 UDP - Received: 87.233.192.220:6969 :: 0 0 0 0 0 60 0 0 0 0 52 55 7 74 0 0 UDP - Sent: tracker.leechers-paradise.org:6969 :: 0 0 52 55 7 74 0 0 0 0 0 1 0 0 0 0 43 44 50 0 0 79 0 0 31 58 23 27 0 0 0 35 0 0 0 1 0 48 33 31 0 30 0 0 82 0 0 82 37 0 0 0 2 0 80 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 UDP - Received: 87.233.192.220:6969 :: 0 0 0 1 0 0 0 0 0 0 7 81 0 0 0 1 0 0 0 11 43 0 0 0 0 33 29 0 26 0 64 19 0 0 0 0 0 82 0 71 0 0 61 0 0 0 0 47 75 0 81 38 0 57 0 5 0 48 0 47 41 0 0 0 80 33 0 0 58 6 33 85 69 0 54 9 0 45 41 0 TCP - Establishing connection: 84.9.208.69:6881 events.js:163 throw er; // Unhandled 'error' event ^ Error: connect ECONNREFUSED 84.9.208.69:6881 at Object.exports._errnoException (util.js:1050:11) at exports._exceptionWithHostPort (util.js:1073:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)

This is the decoded announce response

1 // Event (Announce) 4197152652 // Random request ID 1953 // Interval 1 // Leechers 17 // Seeders [ [ '173.239.236.71', 30075 ], [ '187.113.172.46', 25079 ], [ '213.109.239.162', 24194 ], [ '41.205.38.172', 25625 ], [ '67.184.203.252', 32307 ], [ '69.114.27.207', 30474 ], [ '88.6.51.133', 27066 ], [ '92.221.128.51', 53925 ], [ '103.255.145.186', 45271 ], [ '84.9.208.69', 6881 ] ] // Peers

I've been trying to figure out what's going on, but there are no errors and I've not found documentation on an explanation.

The connection is either closed after connecting, or simply refused.

My handshake seems to be valid, but even if it wasn't, the connection is being closed/refused before I even get the chance to write the handshake.

Parse HTML string in Angular 2 and extract and update values

Sat, 06/03/2017 - 21:48

I just started working on an Angular project but am a bit stuck. I have a component that receives an HTML string from a (trusted) external source. I want to extract and update values from this string, and dispay it in my component.

Now displaying the string is easily done with the following code:

<div [innerHTML]="displayString"></div>

My input string has some <span> elements with the data-card-text element attached as identifier. Is it possible to extract this value, and update it whenever my component wants?

Example: let displayString:string = "<svg><text data-card-text>Value I want to update</text></svg>"

Are operations like these even possible in Angular 2?

XSL Autonumbering

Sat, 06/03/2017 - 21:48

Given the following structure,

<?xml version="1.0" encoding="utf-8"?> <crew> <crewDrill> <step> <if> <step></step> <step></step> </if> </step> <if> <step> <if> <step></step> <step></step> </if> </step> </if> </crewDrill> <crewDrill> <step> <if> <step></step> <step></step> </if> </step> <if> <step></step> <step></step> </if> </crewDrill> </crew>

I would like to use xsl 1.0 to autonumber by adding an attribute to each <step> node. I want to use multiple levels and restart numbering at the start of each <crew> element. More specifically, I would like to get the following result:

<crew> <crewDrill> <step nb="1"> <if> <step nb="1.1"></step> <step nb="1.2"></step> </if> </step> <if> <step nb="2"> <if> <step nb="2.1"></step> <step nb="2.2"></step> </if> </step> </if> </crewDrill> <crewDrill> <step nb="1"> <if> <step nb="1.1"></step> <step nb="1.2"></step> </if> </step> <if> <step nb="2"></step> <step nb="2"></step> </if> </crewDrill> </crew>

I have tried the following with no success:

<xsl:template match="step"> <xsl:copy> <xsl:attribute name="proceduralStepNumber"> <xsl:number format="1. " level="multiple" from="crewDrill"/> </xsl:attribute> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template>

Mongo Aggregation with per day data using Spring Aggregation

Sat, 06/03/2017 - 21:48

I have a big data events stored on Mongo with ISO date . Multiple events with details occur per day and the Data is stored for whole year.

Suppose I want to aggregate daily reports for event related data[sum of event related data particular to each day] using Mongo through Spring libraries related to aggregates, how does one do that using Aggregation of Spring Data.

I am able to group by other data but daily summary of events.

Basically per day summation.

Any body can help?

The code snippet is what i tried with out much success.

Date start = Date.from(Instant.parse(startDate)); Date end = Date.from(Instant.parse(endDate)); Criteria dateCriteria = Criteria.where("tripStart").gte(start).lt(end); Criteria vehicleCriteria=Criteria.where("vehicle").all(vehicle); MatchOperation matchOperation = Aggregation.match(dateCriteria); MatchOperation deviceMatchOperation = Aggregation.match(vehicleCriteria); Aggregation agg = Aggregation.newAggregation(matchOperation,deviceMatchOperation, Aggregation.group("tripStart").sum("overSpeedCount") .as("OS").sum("missed signal").as("ms").sum("hardBreakCount") .as("hbc"), Aggregation.project( "hcbc", "hac","hbc")); // Convert the aggregation result into a List AggregationResults<TripDoc> groupResults = mongoTemplate.aggregate(agg, collectionName, MyData.class);

How do i pass the fixed value with the input value into an array list using the constructor?

Sat, 06/03/2017 - 21:40

I'm trying to pass two values for an object to be passed into an ArrayList from a constructor, I'm stuck trying to figure out how to pass the rate value which has a fixed value in the constructor which another class is also inheriting from. The obj requires an int, double (int is via input).

public static HotelRoom roomNormal() { int room1to299; double rate; HotelRoom obj = null; room1to299 = Integer.parseInt(JOptionPane.showInputDialog("Enter room number")); rate = obj.getRate(); obj = new HotelRoom(room1to299, rate); JOptionPane.showMessageDialog(null,"--Rooms Booked out--\n\n\n" + "Room No. " + room1to299 + "Nightly Rate $" + obj.getRate()); return obj; }

This is the HotelRoom class

public class HotelRoom { private int roomNo; private double rate; public HotelRoom(int roomNo, double rate) { this.roomNo = roomNo; this.rate = rate; if(roomNo < 300) this.rate = 69.95; else this.rate = 89.95; } public int getRoomNo() { return roomNo; } public void setRoomNo(int roomNo) { this.roomNo = roomNo; } public double getRate() { return rate; } public void setRate(double rate) { this.rate = rate; } @Override public String toString() { return "Room No.: " + roomNo + ", Rate: " + rate + '\n'; } public double increaseRate(double surcharge) { return (this.rate + surcharge); } }

Comparing objects and enum class?

Sat, 06/03/2017 - 21:40

I have enum class, something like this:

public enum ProductCategory { FOOD("FOOD"), BEVERAGE("BEVERAGE"), DEFAULT("DEFAULT"); private final String label; private ProductCategory(String label) { this.label = label; } public String getLabel() { return label; } }

And I want to write method that will compare two objects based on the ProductCategory. So if two objects have the same category (for example: FOOD), the method will return true.

public boolean searchFilterFunction(Object firstObject, Object secondObject) { if(firstObject==null || secondObject==null) return false; //code? return true; }

Enum class is in one package, and the method I want to write is in another. Can someone give me some hint?

Pages