Skip to content

Instantly share code, notes, and snippets.

@creeek
creeek / gist:dfd0716d04527869a7d5
Created February 29, 2016 08:17 — forked from selaromi/gist:e6f253d739bb31c95853
SHA256 in Java Ruby C# PHP Phython
*SHA256–Bit Hash Java Example*
import java.security.MessageDigest;
import java.security.SignatureException;
String sourceString = ...; // shared secret + fields in correct format
String hash = sha256Digest(sourceString);
public String sha256Digest (String data) throws SignatureException {
return getDigest(“SHA-256”, data, true);
}
@creeek
creeek / Razer Synapse Yosemite.md
Created June 25, 2015 01:22
How to fix Razer Synapse in Mac OSX 10.0 Yosemite

How to fix Razer Synapse in Mac OSX 10.0 Yosemite

Start Terminal.app and type:

sudo nvram boot-args="kext-dev-mode=1"

Verify that command works by typing:

sudo nvram -p | grep -i boot-args
@creeek
creeek / default.custom.yaml
Created April 20, 2015 06:30
Custom RIME
# ~/Library/Rime/default.custom.yaml
patch:
menu/page_size: 5
recognizer/patterns/yuncheng123: "^yuncheng[0-9]+$"
recognizer/patterns/yunchengime: "^yuncheng[-_.0-9]*$"
recognizer/patterns/xiang123: "^xiang[0-9]+$"
recognizer/patterns/xiangime: "^xiang[-_.0-9]*$"
recognizer/patterns/xuxiang123: "^xuxiang[0-9]+$"
recognizer/patterns/xuxiangime: "^xuxiang[-_.0-9]*$"
1. Hello World!
git log
git checkout 9b9380ba22cd3f1d0974abeea9738fa60ef96a2e
2. bug
git checkout origin/bug
3. LinusTorvalds2014
git log cool.cpp
git blame cool.cpp
git branch -a
git checkout origin/LinusTorvalds2014
@creeek
creeek / _form.html.erb
Created December 22, 2014 08:15
UpYun 表单上传验证信息 helper 方法,用于生成 input tag
<form action="http://v0.api.upyun.com/rbtest/" method="post" enctype="multipart/form-data">
<%= upyun_form_input_tag(:return_url => new_post_path) %>
<input type="file" name="file" />
<button type="submit">上传图片</button>
</form>
@creeek
creeek / upyun_http_form_api.md
Created December 22, 2014 08:12
UPYUN HTTP FORM API

HTTP FORM API 允许用户直接上传文件到 UPYUN,而不需要通过客户服务器进行中转。支持 HTTP 和 HTTPS 协议,您可以选择最优的方式提交请求。

普通上传流程如下:

普通上传流程

UPYUN FORM API 流程如下:

UPYUN表单流程

@creeek
creeek / setup_rails_on_osx.md
Created October 22, 2014 02:16
Setup Ruby On Rails on Mac OS X 10.10 Yosemite

Overview

We will be setting up a Ruby on Rails development environment on Mac OS X 10.10 Yosemite.

Installing Homebrew

First, we need to install Homebrew. Homebrew allows us to install and compile software packages easily from source. Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes. Open Terminal and run the following command:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Installing Ruby

@creeek
creeek / OSX应用嵌套网页.md
Created October 22, 2014 01:50
OSX应用嵌套网页

GitHub上发现OSX下一个Trello的第三方开源客户端Trello.app,实际是一个webview的实现。 可以尝试把访问的地址改成其他网站,找到关键语句:

NSString *urlAddress = @"https://trello.com/login/";

把这段代码替换成其他URL

NSString *urlAddress = @"https://xxx.com/";

另外使用Xcode编译项目时,需注意设置应用图标。

@creeek
creeek / mysql_gone_away_error.md
Created October 22, 2014 01:34
ERROR 2006 (HY000) at line xxx: MySQL server has gone away

ERROR 2006 (HY000): MySQL server has gone away

  • Just in case, to check variables you can use
$> mysqladmin variables -u user -p

This will display the current variables, in this case max_allowed_packet, and as someone said in another answer you can set it temporarily with

$> mysql -u user -p 
mysql> SET GLOBAL max_allowed_packet=1072731894
@creeek
creeek / mysql_with_launchd.md
Last active August 29, 2015 14:07
Control MySQL server with launchd

Control MySQL server with launchd

  • Install the latest copy of mySQL ([downloads page]). This will place a copy of mysql in /usr/local/mysql-version#, and create a link at /usr/local/mysql. It might offer to install the mentioned StartupItem; do not do this. If you already have this StartupItem, remove it (it's located in /Library/StartupItems).
  • Create the following plist file in your favorite text editor, or use the Property List Editor which comes with XCode, and save it as com.mysql.mysqld.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>