This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZIP,LAT,LNG | |
00601,18.180555, -66.749961 | |
00602,18.361945, -67.175597 | |
00603,18.455183, -67.119887 | |
00606,18.158345, -66.932911 | |
00610,18.295366, -67.125135 | |
00612,18.402253, -66.711397 | |
00616,18.420412, -66.671979 | |
00617,18.445147, -66.559696 | |
00622,17.991245, -67.153993 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wrap the $.getJSON() call to return a real Promise | |
// properly handling rejection with the available `.fail` method | |
var fetchJSON = function(url) { | |
return new Promise((resolve, reject) => { | |
$.getJSON(url) | |
.done((json) => resolve(json)) | |
.fail((xhr, status, err) => reject(status + err.message)); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 2 problems for the code below: | |
// (1) use somethingAsync(function(err, result)) format that could swallowed up the error in the nested call. | |
// (2) nested async call as a whole can be flattened out | |
firstThingAsync().then(function(result) { | |
// handle success but any error coming from secondThingAsync() will be swallowed | |
secondThingAsync().then(function(result2) { | |
// do something with result1 and result2 | |
}); | |
}, | |
function(err) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example; | |
import com.amazonaws.services.lambda.runtime.Context; | |
import com.amazonaws.services.lambda.runtime.LambdaLogger; | |
import com.amazonaws.util.StringUtils; | |
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import example.model.ApiGatewayRequest; | |
import example.model.ApiGatewayResponse; | |
import example.model.Article; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<String> strList = Stream.of("1", "2", "illegal_3", "4", "illegal_5", "6").collect(Collectors.toList()); | |
//return null and filter null | |
intList = strList.stream()// same with "parallelStream()" | |
.map(x -> { | |
try { | |
return Integer.parseInt(x); | |
} catch (NumberFormatException nfe) { | |
System.err.println(nfe.getMessage()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------- | |
# Migrate wordpress site to another domain name | |
#------------------------------------------------------- | |
# ref: http://coolestguidesontheplanet.com/updating-wordpress-mysql-database-after-moving-to-a-new-url/ | |
UPDATE wp_options SET option_value = replace(option_value, 'http://[old].com', 'http://[new].com') WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = replace(guid, 'http://[old].com','http://[new].com'); | |
UPDATE wp_posts SET post_content = replace(post_content, 'http://[old].com', 'http://[new].com'); | |
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://[old].com','http://[new].com'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Secure wp-config.php file | |
<files wp-config.php> | |
order allow,deny | |
deny from all | |
</files> | |
# Disable Directory Indexing and Browsing | |
# Put the folowing line at the end of file. | |
Options -Indexes | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | |
<title>BarkBox - Show LOVE to your little friend</title> | |
<!-- Google Tag Manager --> | |
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | |
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) { | |
return asyncSupplyStage(asyncPool, supplier); | |
} | |
public <U> CompletableFuture<U> thenApply(Function<? super T,? extends U> fn) { | |
return uniApplyStage(null, fn); | |
} | |
public CompletableFuture<Void> thenAccept(Consumer<? super T> action) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------- define functional interface ------------------------------ | |
@FunctionalInterface | |
interface Converter<F, T> { | |
T convert(F from); | |
} | |
// ------------------------- use it in the code --------------------------------------- | |
//pass static method as reference | |
Converter<String, Integer> converter = Integer::valueOf; |
NewerOlder