Skip to content

Instantly share code, notes, and snippets.

View robin's full-sized avatar
🏔️

Lu Yibin robin

🏔️
View GitHub Profile
JAVA_OPTS="${JAVA_OPTS} -Xms1024m -Xmx2048m -XX:MaxPermSize=256m -server"; export JAVA_OPTS;
parse_git_branch() {
RSLT=''
GIT_BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* //'`
if [ "$GIT_BRANCH" ]
then
GIT_STATUS=`git status 2> /dev/null | grep 'working directory clean'`
CLR='2'
if [ "$GIT_STATUS" ]
then
CLR='2'
set mailserver smtp.gmail.com port 587
username "email@domain.tld" password "password"
using tlsv1
with timeout 30 seconds
#import <Cocoa/Cocoa.h>
@interface NSMutableArray (variadicMethodExample)
- (void) appendObjects:(id) firstObject, ...; // This method takes a nil-terminated list of objects.
@end
@implementation NSMutableArray (variadicMethodExample)
#import <SystemConfiguration/SCNetworkReachability.h>
#define ReachableViaWiFiNetwork          2
#define ReachableDirectWWAN               (1 << 18)
// fast wi-fi connection
+(BOOL)hasActiveWiFiConnection
{
     SCNetworkReachabilityFlags     flags;
     SCNetworkReachabilityRef     reachabilityRef;
     BOOL                              gotFlags;
require 'fileutils'
# [chinesename].englishname.garbage.ext => abc - [chinesename].ext
def rename1(path)
files = Dir["#{path}/*"].each {|file|
filename = file.split('/')[-1]
next if filename !~ /^\[/
if filename =~ /(\[.+\]\.?)(.*)(\.[a-z]+)/
chinesename = $1
ext = $3
<style type="text/css">
.thumbImage
{
max-width:150px;
max-height:150px;
}
*html.thumbImage
{
width:expression(this.width>150&&this.width>this.height?150:auto);
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)
parse_git_branch() {
RSLT=''
GIT_BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* //'`
if [ "$GIT_BRANCH" ]
then
GIT_STATUS=`git status 2> /dev/null | grep 'working directory clean'`
CLR='2'
if [ "$GIT_STATUS" ]
then
CLR='2'
@robin
robin / proxy.js
Created August 17, 2011 16:23 — forked from steadicat/proxy.js
A reverse-proxy for CouchDB written in Node.js
#!/usr/local/bin/node
var sys = require('sys');
var http = require('http');
var url = require('url');
var PREFIX = '/db/';
var TARGET = 'http://example.cloudant.com';
var PORT = 8001;