Skip to content

Instantly share code, notes, and snippets.

View huobazi's full-sized avatar
🎯
Focusing

Marble Wu huobazi

🎯
Focusing
View GitHub Profile
@huobazi
huobazi / CRUD_SP_Generation.sql
Created June 2, 2011 04:40 — forked from adamcarr/CRUD_SP_Generation.sql
Generate CRUD stored procedures from tables in schema
-- #########################################################
-- Author: www.sqlbook.com
-- Copyright: (c) www.sqlbook.com. You are free to use and redistribute
-- this script as long as this comments section with the
-- author and copyright details are not altered.
-- Purpose: For a specified user defined table (or all user defined
-- tables) in the database this script generates 4 Stored
-- Procedure definitions with different Procedure name
-- suffixes:
-- 1) List all records in the table (suffix of _GetAll)
@huobazi
huobazi / HomepagePresenter.php
Created June 2, 2011 06:13 — forked from fprochazka/HomepagePresenter.php
Mobile device detection in Nette
<?php
class HomepagePresenter extends BasePresenter
{
public function actionDefault()
{
$detector = $this->context->detector;
if ($detector->isMobile()) {
$this->redirect("mobile");
@huobazi
huobazi / cookie.js
Created June 2, 2011 07:20 — forked from maxpert/cookie.js
Cookie Wrapper
var cryptForm = function(formId, toCryptNames) {
document.getElementById(formId).onsubmit = function() {
var clonedForm = this.cloneNode(true);
var els = clonedForm.getElementsByTagName("input");
for (i in els) if (toCryptNames.indexOf(els[i].name) > -1)
els[i].value = braintree.encrypt(els[i].value);
clonedForm.style.display = 'none';
document.body.appendChild(clonedForm);
@huobazi
huobazi / tube.rb
Created June 8, 2011 08:17
Pulls sql from a remote server
#!/usr/bin/env ruby
# in the app's folder on your computer
# tube pull user@host:app_path [--from_env=production] [--to_env=development]
#
# e.g:
# tube pull host:apps/myapp
# tube pull user@host:/apps/myapp
require 'rubygems'
@huobazi
huobazi / gist:1016000
Created June 9, 2011 03:37
javascript isArray
var _isArray = function (obj) {
return obj &&
typeof obj === 'object' &&
typeof obj.length === 'number' &&
typeof obj.splice === 'function' &&
!(obj.propertyIsEnumerable('length'));
};
@huobazi
huobazi / Linode install
Created June 15, 2011 06:08
rails passenger apache sphinx install
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to run this!"
exit 2
fi
echo "What is the hostname of the server? "
read hostname
@huobazi
huobazi / setup.sh
Created June 15, 2011 06:14
Ubuntu setup for Ruby, Nginx, Postgres 9, Rails
#!/bin/bash
# install dependencies
apt-get install openssh-server curl git-core
apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
# install RVM
bash < <(curl -sk https://rvm.beginrescueend.com/install/rvm)
### as per RVM instructions
@huobazi
huobazi / init_d_nginx
Created June 15, 2011 06:26
Nginx initialization script. Place in /etc/init.d/nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@huobazi
huobazi / gist:1026604
Created June 15, 2011 06:42 — forked from lxneng/gist:1005730
natty 163 mirror
deb http://mirrors.163.com/ubuntu/ natty main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ natty main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ natty-security universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ natty-security universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ natty-updates universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ natty-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ natty-proposed universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ natty-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ natty-updates universe main multiverse restricted