Skip to content

Instantly share code, notes, and snippets.

View tuoxie007's full-sized avatar

Jason Hsu tuoxie007

View GitHub Profile
@ericchen
ericchen / gist:3081970
Created July 10, 2012 08:11
nodejs AES encrypt and decrypt
var crypto = require('crypto');
var AESCrypt = {};
AESCrypt.decrypt = function(cryptkey, iv, encryptdata) {
encryptdata = new Buffer(encryptdata, 'base64').toString('binary');
var decipher = crypto.createDecipheriv('aes-256-cbc', cryptkey, iv),
decoded = decipher.update(encryptdata);
@robertpitt
robertpitt / socks5.js
Created July 30, 2012 01:30
SOCKS5 Server as per rfc1928 (nodejs)
/**
* SOCKS5 Proxy as per RFC1928
* @see : http://www.ietf.org/rfc/rfc1928.txt
*/
/**
* Load Dependancies
*/
var net = require('net'),
@Frobitz
Frobitz / coffeescript-homebrew
Created August 4, 2012 13:32
Install CoffeeScript with Homebrew on OS X 10.8 Mountain Lion
# Install Homebrew
ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)
# Follow on-screen instructions (X11 isn't necessary for this if it shows as not installed)
brew install node
# Open .bashrc and add this line (create .bashrc if its not in your home directory already)
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@xurenlu
xurenlu / iconv-gbkencode.js
Created June 13, 2013 03:47
nodejs-gbkUrlencode.js
function encodeURIComponentUTF8toGBK(utf8String){
var Iconv = require("iconv").Iconv;
var iconvLite=require("iconv-lite");
var Buffer =require("buffer").Buffer;
var iconv = new Iconv("UTF-8","GBK");
var res = iconv.convert(utf8String);
return encodeURIComponent(iconvLite.decode(res,"GBK"));
}
console.log(
@ajamaica
ajamaica / gist:5893344
Created June 30, 2013 01:03
UIInterpolatingMotionEffect
UIInterpolatingMotionEffect *mx = [[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];
mx.maximumRelativeValue = @-39.0;
mx.minimumRelativeValue = @39.0;
UIInterpolatingMotionEffect *mx2 = [[UIInterpolatingMotionEffect alloc]
initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
mx2.maximumRelativeValue = @-39.0;
mx2.minimumRelativeValue = @39.0;
@visnup
visnup / SlideAnimatedTransitioning.h
Last active November 13, 2023 12:07
iOS 7 screen edge gesture swipe from right to left (similar to edge swiping from left to right) on UINavigationController. *only* the edge swipe uses the custom transition; everything else uses default behaviors.
//
// SlideAnimatedTransitioning.h
// SwipeLeft
//
// Created by Visnu on 4/14/14.
// Copyright (c) 2014 Visnu Pitiyanuvath. All rights reserved.
//
#import <Foundation/Foundation.h>
@c0ming
c0ming / build.sh
Last active January 30, 2019 01:12
A script for build iOS7 universal static library with clang
#!/bin/bash
# e.g. libmms http://sourceforge.net/projects/libmms/
# set -x
BUILD_DIR=`pwd`"/build"
STATIC_LIB_NAME="libmms.a"
STATIC_LIB_NAME_ARM="libmms.a.arm"
STATIC_LIB_NAME_X86="libmms.a.x86"
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@jiaaro
jiaaro / _INSTRUCTIONS.md
Last active January 22, 2024 17:47
Using Swift libraries in Python

Using Swift libraries in Python

So... this is obviously totally, 100%, like for. real. not. supported. by. Apple. …yet?

But still... I thought it was pretty badass. And, seeing how there's already a Swift buildpack for Heroku you could move some slow code into Swift can call it as a library function. But, you know, not in production or anything. That would be silly, right?

Now, having said that, the actual Python/Swift interop may have bugs. I'll leave that as an exercise to the reader.

How to get Python code calling Swift functions: