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
import requests | |
import re | |
import time | |
url_base = 'http://xxx.site/{}.mp3' | |
def download(name): | |
url = url_base.format(name) | |
print(url) | |
r = requests.get(url, allow_redirects=True) |
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
# Decimal to Hex | |
'{:02x}'.format(100000) | |
import base36 | |
# base36 https://pypi.python.org/pypi/base36/0.1.1 | |
base36.dumps(100000) |
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 main | |
import "fmt" | |
import "strings" | |
func main() { | |
path := "folder/path/filename.mp4" | |
fmt.Println(strings.LastIndex(path, "/")) | |
fmt.Println(path[:strings.LastIndex(path, "/")]) | |
fmt.Println(path[:strings.LastIndex(path, ".")]) |
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
echo '0002' | xxd -r -p | nc localhost 8888 | xxd -l 120 -ps -c 100 | |
echo -ne '0002' | sed -e 's/../\\x&/g' |
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 main | |
import ( | |
"encoding/hex" | |
"fmt" | |
) | |
func main() { | |
bs := make([]byte, 7) | |
copy(bs[:], "0000003") |
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
s := fmt.Sprintf("number is %d, string is %s", 1234, "STRING") | |
fmt.Println(s) |
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
/* print JAVA */ | |
System.out.println(String.format("Hi, My name is %s. I'm %d years old.", "HWANG", 30)); | |
/* print GO */ | |
fmt.Printf("Hi, My name is %s. I'm %d years old.\n", "HWANG", 30) |
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
$ vi hello.sh | |
(hello.sh) | |
#!/bin/bash | |
echo hello world | |
$ chmod 755 hello.sh | |
$ ./hello.sh | |
hello world |
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
/* Java */ | |
Calendar cal = Calendar.getInstance(); | |
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
System.out.println(fmt.format(cal.getTime())); | |
// Output "2017-02-28 11:35:01" | |
/* Go */ | |
time.Now().format("2006-01-02 15:04:05") | |
// Output "2017-02-28 11:35:01" |