Skip to content

Instantly share code, notes, and snippets.

View hongkongkiwi's full-sized avatar
🤓

Andy hongkongkiwi

🤓
View GitHub Profile
@jrk
jrk / scpi.pl
Created July 22, 2009 08:03
An improved replacement for scp, with resume and advanced compression support. By Andrei Alexandrescu.
#!/usr/bin/env perl
# Via: http://erdani.org/code/scpi.html
################################################################################
## Copyright (c) 2006 by Andrei Alexandrescu
## Permission to use, copy, modify, distribute and sell this software for any
## purpose is hereby granted without fee, provided that the above copyright
## notice appear in all copies and that both that copyright notice and this
## permission notice appear in supporting documentation.
## The author makes no representations about the
@3dd13
3dd13 / download_open_rice_contact.rb
Created October 19, 2010 08:36
OpenRice.com is a famous restaurant online directory in Hong Kong. Here is a ruby script to grep all the contact information of all shops. at this moment of time, there are around 26K records on the website. this program took ~ 15mins to finish. and
require 'rubygems'
require 'mechanize'
require 'fastercsv'
def get_all_option_values(page, attr_name)
page.search("[name=#{attr_name}]").search("option").map do |opt|
option_value = opt.attribute("value").value
[option_value, opt.text.strip.gsub(/\302\240\302\240/, '')] if option_value && option_value.length > 0
end.compact
end
@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@mistersourcerer
mistersourcerer / NSDictionary+Persistence.h
Created March 16, 2011 19:47
NSDictionary / NSMutableDictionary plist file persistence
#import <Foundation/Foundation.h>
@interface NSDictionary(Persistence)
-(void)writeToFileInDocumentsDir:(NSString *)path atomically:(BOOL)atomically;
@end
@zwaldowski
zwaldowski / NSObject+Blocks.h
Created May 4, 2011 12:08
Perform blocks with delays and cancellation
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)
@ghedo
ghedo / sound_playback.c
Last active May 26, 2024 13:44
Simple sound playback using ALSA API and libasound
/*
* Simple sound playback using ALSA API and libasound.
*
* Compile:
* $ cc -o play sound_playback.c -lasound
*
* Usage:
* $ ./play <sample_rate> <channels> <seconds> < <file>
*
* Examples:
@csanz
csanz / encrypt_decrypt.js
Created August 30, 2011 16:06
Simple String Encryption & Decryption with Node.js
function encrypt(text){
var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq')
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq')
var dec = decipher.update(text,'hex','utf8')
@bergie
bergie / .gitignore
Created September 19, 2011 15:50
Node.js email handling examples
config.json
reading-image.png
@spudtrooper
spudtrooper / jar2java
Created October 31, 2011 13:45
Generates java source from a jar file (e.g. for use in javadoc)
#!/bin/sh
#
# Transforms a jar file into source and outputs source files to 'src'.
# Example:
#
# jar2java foo.jar ; --> source to 'src'
#
# After you can run javadoc on these files, e.g.
#
# javadoc -classpath foo.jar -d api `find src -name "*.java"`
@geek0x23
geek0x23 / customer.js
Created November 9, 2011 01:41
A mongoose model that takes advantage of the handy invalidate method to run multiple validations
var mongoose = require('./db-connect'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
uuid = require('node-uuid'),
Validator = require('validator').Validator,
val = new Validator(),
bcrypt = require('bcrypt');
Validator.prototype.error = function(msg) { return false; };