Skip to content

Instantly share code, notes, and snippets.

DavyLin /
Created Jan 26, 2018 — forked from suweya/
OkHttp download file by Okio
import android.os.Environment;
import java.util.concurrent.TimeUnit;
View gist:da165d79089b7bae020a0e3ed913aa43
==>sudo xcode-select -switch /Applications/
==>cd ~/.cocoapods/repos
==>git clone master
==>it must show:
Cloning into 'master'...
remote: Counting objects: 855220, done.
remote: Compressing objects: 100% (3211/3211), done.
remote: Total 855220 (delta 1424), reused 0 (delta 0), pack-reused 851785
Receiving objects: 100% (855220/855220), 342.79 MiB | 1.04 MiB/s, done.
DavyLin / gist:4b69234a34166e6d7dc35d6dcdb40e5b
Created Oct 19, 2016
github throw error SSL certificate problem: Couldn't understand the server certificate format
View gist:4b69234a34166e6d7dc35d6dcdb40e5b
> cd ~/.ssh
> sudo wget
> export CURL_CA_BUNDLE=~/.ssh/cacert.pem
DavyLin /
Last active Aug 27, 2015 — forked from nicolashery/
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
  "_id": 1,
DavyLin / choiceADKVersion
Last active Aug 29, 2015
View choiceADKVersion
class MethodInLowSdk{
public static void aMethod();
class MethodInHighSdk{
public static void aMethod();
void CallAMethodByVersion(){
if(android.os.Build.VERSION.SDK_INT > low_sdk){
View test5
on run {targetBuddyPhone, targetMessage, repeatCount}
tell application "Messages"
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
set myCount to repeatCount as integer
repeat myCount times
send targetMessage to targetBuddy
end repeat
end tell
end run
public class FizzTest {
public static void main(String[] args) {
String string = "";
String[] nums = new Scanner(",");
for (int i = 1; i <= 100; i++) {
if (String.valueOf(i).indexOf(nums[0]) != -1) {
string += "Fizz";
} else {
if (i % Integer.parseInt(nums[0]) == 0) {
string += "Fizz";
DavyLin / typeTip.js
Created Dec 31, 2013
a example for javascript
View typeTip.js
var a = 'hello';
var b = new String('hello');
a + b; // 'hello hello'
typeof a; // 'string'
typeof b; // 'object'
a instanceof String; //false
b instanceof String; // true
a.substr == b.substr; //true
DavyLin /
Last active Dec 31, 2015
example for ExectorService,download the file
ExecutorService service=Executors.newFixedThreadPool(Integer.valueOf(poolThreadNum.toString()));
CountDownLatch downlatch= new CountDownLatch(Integer.valueOf(poolThreadNum.toString()));
CountDownLatch sucess_downlatch=new CountDownLatch(Integer.valueOf(poolThreadNum.toString()));
View environ.rb
if __FILE__ == $0
vars = {}
Dir.glob("**/*") do |name|
if File.file? name and name =~ /\.clj$/,"r") do |f|
content =
if content =~ /environ.core/
content.scan(/\(env :([a-zA-Z\-]+) ("([^\)]+)")?\)/).each do |matches|