Skip to content

Instantly share code, notes, and snippets.

@DavyLin
DavyLin / FileUtil.java
Created Jan 26, 2018 — forked from suweya/FileUtil.java
OkHttp download file by Okio
View FileUtil.java
import android.os.Environment;
import android.support.annotation.NonNull;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
View gist:da165d79089b7bae020a0e3ed913aa43
==>sudo xcode-select -switch /Applications/Xcode.app
==>cd ~/.cocoapods/repos
==>git clone https://github.com/CocoaPods/Specs.git 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
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 http://curl.haxx.se/ca/cacert.pem
> export CURL_CA_BUNDLE=~/.ssh/cacert.pem
@DavyLin
DavyLin / elasticsearch.md
Last active Aug 27, 2015 — forked from nicolashery/elasticsearch.md
Elasticsearch: updating the mappings and settings of an existing index
View elasticsearch.md

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
DavyLin / choiceADKVersion
Last active Aug 29, 2015
choiceADKVersion
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
View FizzTest.java
public class FizzTest {
public static void main(String[] args) {
String string = "";
String[] nums = new Scanner(System.in).next().split(",");
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
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
DavyLin / example.java
Last active Dec 31, 2015
example for ExectorService,download the file
View example.java
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
#!/bin/ruby
if __FILE__ == $0
vars = {}
Dir.glob("**/*") do |name|
if File.file? name and name =~ /\.clj$/
File.open(name,"r") do |f|
content = f.read
if content =~ /environ.core/
content.scan(/\(env :([a-zA-Z\-]+) ("([^\)]+)")?\)/).each do |matches|