Skip to content

Instantly share code, notes, and snippets.

View DavyLin's full-sized avatar
💭
I may be slow to respond.

davylin DavyLin

💭
I may be slow to respond.
View GitHub Profile
@DavyLin
DavyLin / FileUtil.java
Created January 26, 2018 00:29 — forked from suweya/FileUtil.java
OkHttp download file by Okio
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;
==>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 October 19, 2016 08:23
github throw error SSL certificate problem: Couldn't understand the server certificate format
> cd ~/.ssh
> sudo wget http://curl.haxx.se/ca/cacert.pem
> export CURL_CA_BUNDLE=~/.ssh/cacert.pem
@DavyLin
DavyLin / elasticsearch.md
Last active August 27, 2015 03:51 — forked from nicolashery/elasticsearch.md
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
DavyLin / choiceADKVersion
Last active August 29, 2015 14:06
choiceADKVersion
class MethodInLowSdk{
public static void aMethod();
};
class MethodInHighSdk{
public static void aMethod();
}
void CallAMethodByVersion(){
if(android.os.Build.VERSION.SDK_INT > low_sdk){
@DavyLin
DavyLin / test5
Created June 5, 2014 14:14 — forked from netstu/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(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 December 31, 2013 14:48
a example for javascript
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 December 31, 2015 20:19
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()));
#!/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|