Skip to content

Instantly share code, notes, and snippets.

View hSATAC's full-sized avatar
🐈
Cataholic

Ash Wu hSATAC

🐈
Cataholic
View GitHub Profile
@hSATAC
hSATAC / mitmproxy.py
Created August 9, 2012 03:36
How to modify http request host and port using mitmproxy script
def request(context, flow):
if "miiicasa.com" in flow.request.host:
if flow.request.scheme == "https":
flow.request.host = "192.168.254.9"
flow.request.port = "50113"
if flow.request.scheme == "http":
flow.request.host = "192.168.254.9"
flow.request.port = "50110"
<VirtualHost *:80>
ServerName golang.tw
DocumentRoot /home/cat/go_code/src/golang.tw/public
<Directory /home/cat/go_code/src/golang.tw/public/>
AllowOverride all
Options -MultiViews
</Directory>
@interface UIDevice (Hardware)
- (NSString *) platform;
@end
#pragma mark - UIDevice+platform.h
@implementation UIDevice (Hardware)
/*
Platforms
iPhone1,1 -> iPhone 2G
@hSATAC
hSATAC / gist:3754899
Created September 20, 2012 09:28 — forked from keimlink/gist:831633
Startup script for the Supervisor server (RHEL)
#!/bin/bash
#
# Startup script for the Supervisor server
#
# Tested with Red Hat Enterprise Linux Server release 5.5
#
# chkconfig: 2345 85 15
# description: Supervisor is a client/server system that allows its users to \
# monitor and control a number of processes on UNIX-like \
# operating systems.
@hSATAC
hSATAC / gist:3810421
Created October 1, 2012 08:56
vpn-ssh
#!/bin/sh
# /usr/local/bin/vpn-pppssh
#
# This script initiates a ppp-ssh vpn connection.
# see the VPN PPP-SSH HOWTO on http://www.linuxdoc.org for more information.
#
# revision history:
# 1.6 11-Nov-1996 miquels@cistron.nl
# 1.7 20-Dec-1999 bart@jukie.net
# 2.0 16-May-2001 bronson@trestle.com
#!/bin/sh
# do gocode first
cd /Users/cat/golang.tw/gocode
git pull
git filter-branch -f --subdirectory-filter vim -- --all
git push pathogen master
git fetch
git reset --hard origin/master
@hSATAC
hSATAC / gist:3978482
Created October 30, 2012 05:32
obj-c unit test with asynchronous request
- (void)testLogin
{
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[[miiiCasaServer getServer] login:@"test@example.com" andPassword:@"password" success:^(AFHTTPRequestOperation *operation, id responseObject) {
assertThat(responseObject[@"status"], is(@"ok"));
dispatch_semaphore_signal(semaphore);
} failure:nil];
while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW))
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]];
@hSATAC
hSATAC / gemspec-usage.md
Created November 5, 2012 06:10 — forked from holman/gemspec-usage.md
test/spec/mini

Just install this in your apps like so:

gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'

@hSATAC
hSATAC / gist:4712835
Created February 5, 2013 07:22
puppet stage example
# Append this at the bottom of /etc/puppetlabs/puppet/manifests/site.pp
node 'devm3' {
stage { 'pre': }
class {
"archfix": stage => "pre";
}
Stage["pre"] -> Stage["main"]
include common
import urllib, urllib2, json
class FacebookTestUserManager:
'''
A tool which helps to create and delete test account for
Facebook.
See https://developers.facebook.com/docs/test_users/
'''