Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am ryanchang on github.
  • I am brewgeek (https://keybase.io/brewgeek) on keybase.
  • I have a public key ASCBwvM5xZjt6NBpf3AAuvxRe4-eeuN_CUv8Rl1PuCVPIQo

To claim this, I am signing this object:

@ryanchang
ryanchang / print_source.sh
Last active July 17, 2017 06:42
软件著作权申请打印代码专用😂
#!/bin/bash
for file in $( find . -name \*.m|grep -v lib ); do
echo "$file"
cat $file
echo "\n"
done
for file in $( find . -name \*.h|grep -v lib ); do
echo "$file"
cat $file
@ryanchang
ryanchang / gio_export_example.rb
Created May 15, 2017 08:27
GrowingIO原始数据导出
require 'date'
require 'openssl'
require 'rest-client'
require 'json'
def auth_token(secret, project, ai, tm)
message = ("POST\n/auth/token\nproject=" + project + "&ai=" + ai + "&tm=" + tm).encode("utf-8")
digest = OpenSSL::Digest.new('sha256')
OpenSSL::HMAC.hexdigest(digest, secret.encode("utf-8"), message)
end
@ryanchang
ryanchang / websocket_rails_client.py
Last active September 7, 2015 03:10
Python client for websocket_rails.
import websocket
import thread
import time
import json
def on_message(ws, message):
print "recieved: " + message
response = json.loads(message)[0]
event = response[0]
print "event: " + event
@ryanchang
ryanchang / upload_audio.py
Last active August 29, 2015 14:26
Upload audio file to rails server with paperclip with python requests HTTP client.
import requests
import base64
from datetime import datetime
import json
f = open('output.mp3')
recording = base64.b64encode(f.read())
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
payload = {'audio_clip': {'device':'0005', 'time':current_time, 'recording':{'filename':'output.mp3', 'content_type':'audio/mp3', 'content':recording}}}
@ryanchang
ryanchang / fullstack_arsenal.md
Created March 30, 2015 08:57
Fullstack Arsenal

Fullstack Arsenal

PhantomJS

Full web stack No browser required PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast andnative support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

immutable-js

Immutable provides Persistent Immutable List, Stack, Map, OrderedMap, Set, OrderedSet and Record. They are highly efficient on modern JavaScript VMs by using structural sharing via hash maps tries and vector tries as popularized by Clojure and Scala, minimizing the need to copy or cache data.

ReactJS

@ryanchang
ryanchang / svg2pdfs.rb
Created November 26, 2014 05:44
Convert all the .svg file in the current directory to .pdf with svg2pdf tool
sources = Dir["./*.svg"]
puts sources
sources.each do |svg|
pdf = "#{svg[0...-4]}.pdf"
%x(svg2pdf #{svg} #{pdf})
end
@ryanchang
ryanchang / lldb_cheat_sheet.md
Last active October 31, 2024 21:52
LLDB Cheat Sheet

LLDB Cheat Sheet

A complete gdb to lldb command map.

Print out

  • Print object
(lldb) po responseObject
(lldb) po [responseObject objectForKey@"state"]
  • p - Print primitive type