Skip to content

Instantly share code, notes, and snippets.

View yingca1's full-sized avatar
🎯
Focusing

Ying yingca1

🎯
Focusing
  • London, UK
  • 00:24 (UTC +01:00)
View GitHub Profile
import torch
torch.Tensor(1).cuda()
print("hello world!")
f = open("demofile2.txt", "a")
f.write("Now the file has more content!")
f.close()
@yingca1
yingca1 / AES.java
Created November 1, 2017 02:51
AES encrypt & decrypt in java and nodejs
private static byte[] iv = "0000000000000000".getBytes();
private static String decrypt(String encrypted, String seed)
throws Exception {
byte[] keyb = seed.getBytes("utf-8");
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] thedigest = md.digest(keyb);
SecretKeySpec skey = new SecretKeySpec(thedigest, "AES");
Cipher dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
dcipher.init(Cipher.DECRYPT_MODE, skey, new IvParameterSpec(iv));
byte[] clearbyte = dcipher.doFinal(Base64.decode(encrypted, Base64.DEFAULT));
@yingca1
yingca1 / Makefile
Created May 10, 2017 07:44
Makefile for python project
venv: venv/bin/activate
venv/bin/activate: requirements.txt
test -d venv || virtualenv venv
venv/bin/pip install -Ur requirements.txt
touch venv/bin/activate
clean: venv
venv/bin/pip freeze | grep -v -f requirements.txt - | grep -v '^#' | xargs venv/bin/pip uninstall -y
freeze: venv
@yingca1
yingca1 / yc.zsh-theme
Created December 27, 2016 05:54
oh-my-zsh theme file
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# Machine name.
local platform=`uname`
local ipaddr=$HOST
if [[ "$platform" == "Darwin" ]]; then
ipaddr=$(ipconfig getifaddr en0)
import urllib.request
import asyncio
import json
r = urllib.request.urlopen('https://raw.githubusercontent.com/spacelan/wechat-emoticon/master/emoticons.json').read().decode('utf8')
json_obj = json.loads(r)
@asyncio.coroutine
def download(todo):
urllib.request.urlretrieve(todo.get('url'), todo.get('md5') + '.gif')
@yingca1
yingca1 / android
Last active August 29, 2015 14:06
# 批量装文件夹下apk
for f in *.apk ; do adb install -r $f; done;
@yingca1
yingca1 / colors.xml
Created September 23, 2014 03:31
android
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<color name="white">#FFFFFF</color><!--白色 -->
<color name="ivory">#FFFFF0</color><!--象牙色 -->
<color name="lightyellow">#FFFFE0</color><!--亮黄色 -->
<color name="yellow">#FFFF00</color><!--黄色 -->
<color name="snow">#FFFAFA</color><!--雪白色 -->
<color name="floralwhite">#FFFAF0</color><!--花白色 -->
<color name="lemonchiffon">#FFFACD</color><!--柠檬绸色 -->
<color name="cornsilk">#FFF8DC</color><!--米绸色 -->
@yingca1
yingca1 / macos
Last active August 29, 2015 14:04
mac command lines
mac 硬盘测速
time dd if=/dev/zero bs=1024k of=tstfile count=1024
time dd if=tstfile bs=1024k of=/dev/null count=1024
显示:defaults write com.apple.finder AppleShowAllFiles -bool true
隐藏:defaults write com.apple.finder AppleShowAllFiles -bool false
@yingca1
yingca1 / logcat
Created July 11, 2014 12:23
logcat some common usage
adb logcat -b main -b radio -b events -v time>test.log
@yingca1
yingca1 / wifi
Created July 11, 2014 03:40
windows wifi hotpsot setup
netsh wlan set hostednetwork mode=allow ssid="wifi hotspot name" key="wifi password"
netsh wlan start hostednetwork