Skip to content

Instantly share code, notes, and snippets.

View ouyangzhiping's full-sized avatar

Zhiping Yang ouyangzhiping

View GitHub Profile
@ouyangzhiping
ouyangzhiping / 000-instructions.md
Created June 21, 2012 12:14 — forked from halpo/000-instructions.md
harvestr R users conference presentation.

Building a beamer presentation with knitr.

Introduction

The documents included are the input for knitr. In addition you need to have the tool pandoc installed. I also use a custom beamer template to add the University of Utah \institute command to the template. It also changes the indentation some.

Steps

  1. knit document with
@ouyangzhiping
ouyangzhiping / nginx
Created June 20, 2012 11:30 — forked from continuityapp/nginx
Ubuntu 10.04 LTS Nginx startup script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# 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
@ouyangzhiping
ouyangzhiping / gist:2927606
Created June 14, 2012 01:32
wordpress:migrate_wordpress
# -*- coding:utf-8 -*-
# Usage rake wordpress:migrate_wordpress[:src, :dst]
# rake wordpress:migrate_wordpress
# You will need gem "mysql" in your Gemfile
namespace :wordpress do
task :migrate_wordpress, [:src, :dst] => :environment do |cmd, args|
args.with_defaults(:src => "wordpress", :dst => "development")
config = Rails.configuration.database_configuration
src_db = config[args[:src]]
# encoding: UTF-8
#!/usr/bin/env ruby
# This script convers markdown book to one of the serveral e-book
# formats supported with calibre (http://calibre-ebook.com)
#
# Samples:
#
# Build e-book for amazon kindle for english and russian languages
# $ make-ebook en ru
@ouyangzhiping
ouyangzhiping / nginx.sh
Created May 21, 2012 20:05 — forked from marshluca/nginx.sh
/etc/init.d/nginx
# /etc/init.d/nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@ouyangzhiping
ouyangzhiping / top_github_lang.rb
Created March 4, 2012 01:54 — forked from benbjohnson/top_github_lang.rb
Queries for the Languages on GitHub by Popularity
#!/usr/bin/ruby
require 'rubygems'
require 'mechanize'
mechanize = Mechanize.new
rankings = {}
# Retrieve language list
mechanize.get("https://github.com/languages") do |page|
@ouyangzhiping
ouyangzhiping / gitcoder.rb
Created March 4, 2012 01:49 — forked from dongyuwei/gitcoder.rb
find the website/blog of github top coder
require 'rubygems'
require 'nokogiri'
require 'net/http'
require 'openssl'
require 'open-uri'
class Net::HTTP
alias_method :origConnect, :connect
def connect
@ouyangzhiping
ouyangzhiping / move logic to model
Created February 25, 2012 04:45 — forked from darrenterhune/move logic to model
csv import example in model
# controller
def proc_csv
import = Import.find(params[:id])
if import.load_csv
flash[:notice] = "woo"
redirect_to some_url
else
flash[:error] = "ohoh"
end
end
@ouyangzhiping
ouyangzhiping / gist:1479172
Created December 14, 2011 23:55 — forked from samqiu/railscasts.rb
download railscast video
#!/usr/bin/ruby
require 'rss'
p 'Downloading rss index'
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
videos_filenames = videos_urls.map {|url| url.split('/').last }
@ouyangzhiping
ouyangzhiping / gist:1479171
Created December 14, 2011 23:55 — forked from samqiu/railscasts.rb
download railscast video
#!/usr/bin/ruby
require 'rss'
p 'Downloading rss index'
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
videos_filenames = videos_urls.map {|url| url.split('/').last }