Skip to content

Instantly share code, notes, and snippets.

mid_range <- function(x) mean(range(x, na.rm = TRUE))
centres <- ddply(county_df, c("state", "county"), summarise,
lat = mid_range(lat),
long = mid_range(long)
)
bubbles <- merge(centres, unemp, by = c("state", "county"))
ggplot(bubbles, aes(long, lat)) +
geom_polygon(aes(group = group), data = state_df,
colour = "white", fill = NA) +
library(maps)
unemp <- read.csv('unemployment09.csv',header=FALSE, stringsAsFactors=FALSE,
col.names=c("blsid", "stfips", "cofips", "name", "year", "pop1", "pop2", "unempraw", "unemppct"))
unemp$mpname <- tolower(paste(state.name[match(sub("^.*([A-Z][A-Z])$","\\1",unemp$name,fixed=FALSE),state.abb)],
sub("^(.*) (County|[Cc]ity|Parish), ..$","\\1", unemp$name),sep=","))
unemp$ri <- as.numeric(cut(unemp$unemppct,c(seq(0,10,by=2),max(unemp$unemppct))))
@defunkt
defunkt / installing-mustache.vim.md
Created March 6, 2010 10:21
Installing mustache.vim

mustache.vim

In your shell:

cd ~/.vim
git clone git://github.com/juvenn/mustache.vim.git
mv mustache.vim/syntax/* syntax/
mv mustache.vim/indent/* indent/
mv mustache.vim/ftdetect/* ftdetect/

rm -rf mustache.vim

//豆瓣:只显示楼主
javascript:void(function(){$(".topic-reply li").each(function(){ if($(this).find(".user-face a").attr('href')!=$(".user-face:first").find('a').attr('href')){$(this).toggle() } });})();
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'digest/md5'
require 'fastercsv'
require 'json'
require 'curb'
require 'pp'
data = []
@avinashbangar
avinashbangar / yql_flickr.php
Created November 6, 2010 06:44
Getting photos from Flickr using YQL
<!-->
Following code gets information about photos from Flickr via YQL for the given search term
Author : avinash
Email : avinash@tutkiun.com
<-->
<h2>Using YQL to Access the Flickr API</h2>
<form name='upcoming_form'>
@onyxfish
onyxfish / csvkit_tutorial.sh
Created April 17, 2011 23:23
Full script for the csvkit tutorial (proof of process repeatability)
#!/bin/bash
###################
# Getting started #
###################
# Setup a workspace
mkdir va_benefits
cd va_benefits
@predominant
predominant / ubuntu-1104-nginx-base.sh
Created October 5, 2011 15:19
Install Ubuntu 11.04 Nginx based web server with PHP-FPM, MySQL and MongoDB
#!/bin/bash
###
#
# Copyright (c) 2011 Cake Development Corporation (http://cakedc.com)
#
# Ubuntu 11.04 based web server installation script
# Run this by executing the following from a fresh install of Ubuntu 11.04 server:
#
# bash -c "$(curl -fsSL https://raw.github.com/gist/1264701)" <mysqlPassword>
@biovisualize
biovisualize / README.md
Last active March 4, 2016 22:43
D3 chart plugin template

A template example to write simple chart plugins on top of D3. It is a base for discussion, so your are much welcome to modify it and comment it. The requirements are discussed on the wiki.

This implementation provides: div or svg parent, variants (bars or stacked bars), position, relative position (after or under another chart of the same svg parent), margins, gap between bars (in %), transition duration, separated data and labels (to discuss), uses axis component (to complete), chart size taken from the parent and will resize with it, all items accessible from CSS for styling, most options optional, automatic redraw on setting change and zero argument returns the value.

In this example, the first bar chart data updates periodically and a mouse click changes chart type.

@zrong
zrong / dnspodsh.sh
Last active April 2, 2024 04:44
在bash中使用DNSPod的API接口实现DDNS客户端
#!/bin/bash
##############################
# dnspodsh v0.3
# 基于dnspod api构架的bash ddns客户端
# 作者:zrong(zengrong.net)
# 详细介绍:http://zengrong.net/post/1524.htm
# 创建日期:2012-02-13
# 更新日期:2012-03-11
##############################