Skip to content

Instantly share code, notes, and snippets.

View happypeter's full-sized avatar
🐶
Wait for U

Peter Wang happypeter

🐶
Wait for U
View GitHub Profile
@happypeter
happypeter / first.c
Created August 21, 2009 07:44
Peter's first gist
#include <stdio>
int main()
{
printf("what is gist?\n");
/*
* I am making a change with git, click "this gist" shown below
*1. clone it down from github
*git clone git@gist.github.com:171713.git gist-171713
*2. change it and push it
*3. now you see the change in the html page
@happypeter
happypeter / dabblet.css
Created June 15, 2012 05:23
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@happypeter
happypeter / db_backup.sh
Created June 27, 2012 12:04
db backup with git
#!/usr/bin/env bash
ssh linode 'cd local_clone; cd happynewsdb; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot authlove_development>authlove_development.sql; \
git commit -a -m"i"; \
git push;\
cd ../happyecdb/ ; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot ec_development>ec_development.sql; \
git commit -a -m"i"; \
git push;\
@happypeter
happypeter / happycasts_sync.sh
Created July 22, 2012 12:51
sync my happycasts/* to my server
#!/bin/bash
sync_dryrun()
{
echo
echo -e "\033[1m ...dryrun...\033[0m"
rsync -rv --delete ~/happycasts/episodes/ peter@linode:~/media/assets/episodes/ --dry-run
echo -e "\033[1m ...dryrun...\033[0m"
echo
}
@happypeter
happypeter / mac_fuck_gfw.sh
Last active July 3, 2016 06:03
FUCK GWF apple script
#!/user/bin/env bash
on_die() {
echo
echo byebye proxy
echo
networksetup -setsocksfirewallproxystate "Ethernet 2" off #close the proxy
# the name can be "wifi" or "Ethernet 1", just see what is listed in "network preference"
}
@happypeter
happypeter / restart_airport.sh
Created September 5, 2012 06:42
quick apple script to restart Airport
#!/usr/bin/env bash
####################################################################
#
# my iMac drop connections sometimes, a quick restart bring it back
#
####################################################################
networksetup -setairportpower en1 off
echo "NOW:" `networksetup -getairportpower en1`
@happypeter
happypeter / happycasts_deploy.sh
Last active October 10, 2015 04:38
deploy happycasts on my linode vps
#!/usr/bin/env bash
ssh -t peter@happycasts.net '
source ~/.bash_login && cd ~/happycasts && \
git pull && \
bundle exec rake db:migrate RAILS_ENV=production; \
bundle && bundle exec rake assets:precompile &&\
touch tmp/restart.txt
'
@happypeter
happypeter / Traps.markdown
Created September 12, 2012 07:33 — forked from billie66/nginx.conf
Deploy Rails on Ubuntu server 12.04 with Nginx, Unicorn, Mysql
  1. the default index.html does not work well in prodution mode, so do not borther to config that, just delete it and go on.

  2. To put things in production mode, do

     rails g scaffold items name:string
     rake db:migrate RAILS_ENV=production
     rm public/index.html
     #change route.rb point root to items#index
     rake assets:precompile
     sudo service nginx restart
    

./config/unicorn_init.sh stop

@happypeter
happypeter / db_backup.sh
Created September 24, 2012 10:22
db backup with git
#!/usr/bin/env bash
ssh linode 'cd local_clone/db-data/; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot authlove_production>authlove_production.sql; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot ec_development>ec_development.sql; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot happycasts_production>happycasts_production.sql; \
git add *.sql
git commit -a -m"i"; \
git push;\
'
@happypeter
happypeter / deploy.rb
Created October 30, 2012 00:23
Capistrano recip
require "bundler/capistrano"
set :application, "blog"
set :repository, "git@github.com:happypeter/blog.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :user, "deployer"
set :deploy_to, "/home/#{user}/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, true