Skip to content

Instantly share code, notes, and snippets.

View ouyangzhiping's full-sized avatar

Zhiping Yang ouyangzhiping

View GitHub Profile
@ouyangzhiping
ouyangzhiping / family-tree.md
Created July 25, 2013 15:57
如何在R中绘制家族树

如何在R中绘制家族树

家族树是民族志,社会学与心理学常用的一种方法,在笔者的婚恋关系研究中,同样也需要绘制夫妻双方的家族树,以求其其相似性. 恰巧网友今日询问类似问题,记录步骤如下. (以下操作均在RStudio中执行.)

1. 安装并加载家族树R包kinship2

install.packages("kinship2", dependencies = TRUE)
@ouyangzhiping
ouyangzhiping / mac2013.sh
Last active December 20, 2015 04:39
setup your mac
# install xcode
app store => xcode => command line tool
# install brew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
# install brew cask

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@ouyangzhiping
ouyangzhiping / database.yml.production
Last active December 20, 2015 01:19
database.yml.production.example
common: &common
adapter: postgresql
username: ouyang
password: ouyang
#host: 33.33.33.10
development:
<<: *common
database: attention_dev

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

The range sliders at the top change the values for the force-directed algorithm and the buttons load new graphs and apply various techniques. This will hopefully serve as a tool for teaching network analysis and visualization principles during my Gephi courses and general Networks in the Humanities presentations.

Notice this includes a pretty straightforward way to load CSV node and edge lists as exported from Gephi.

It also includes a pathfinding algorithm built for the standard data structure of force-directed networks in D3. This requires the addition of .id attributes for the nodes, however.

Now with Clustering Coefficients!

Also, it loads images for nodes but the images are not in the gist. The code also refers to different network types but the data files on Gist only refer to the transportation network.

#!/usr/bin/env python
# Twilio Tools for Reminding & Calling
# Download the twilio-python library from http://twilio.com/docs/libraries
from twilio.rest import TwilioRestClient
from twilio import twiml
from flask import Flask
app = Flask(__name__)
account = "TWILIO ACCOUNT"
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ]; then
source "$rvm_path/scripts/rvm"
rvm use `cat .ruby-version`@`cat .ruby-gemset`
fi

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@ouyangzhiping
ouyangzhiping / Markdown.sublime-build
Created June 27, 2012 09:22 — forked from dvhthomas/Markdown.sublime-build
Pandoc powered Sublime Text 2 build provider for Markdown files: HTML the easy way
{
"cmd": ["pandoc.exe", "--to=html", "--output=$file.html", "$file"],
"selector": "source.md"
}