Skip to content

Instantly share code, notes, and snippets.

View youxiachai's full-sized avatar

youxiachai youxiachai

View GitHub Profile
@totherik
totherik / npmjs.ini
Last active August 29, 2015 13:56
npmjs.org registry install script
; CouchDB Config
; Drop in PREFIX/local.d/npmjs.ini
[couch_httpd_auth]
public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
users_db_public = true
[httpd]
secure_rewrites = false
@RuiAAPeres
RuiAAPeres / gist:11402456
Last active August 29, 2015 14:00
Sam Page's SparkRecording Implementation with Facebook's Pop
//The calculations are coming from [here](https://gist.github.com/d-ronnqvist/11266321) (thanks David!)
- (void)updateAnimations
{
CGFloat duration = self.duration * (1.f - [[self.progressLayers firstObject] strokeEnd]);
CGFloat strokeEndFinal = 1.f;
for (CAShapeLayer *progressLayer in self.progressLayers)
{
POPBasicAnimation *popEndAnimation = [POPBasicAnimation animation];
@forthxu
forthxu / test google ips
Last active August 29, 2015 14:02
google g-f-w pings
#!/usr/bin/python
#-*- coding:utf8 -*-
'''
Created on 2014-06-02
# QQ:263967133
# pings运行一般运行一次就够了,自己选一个ip段
# google ip地址段
# 64.233.160.0 - 64.233.191.255
# 66.102.0.0 - 66.102.15.255
@LiuJi-Jim
LiuJi-Jim / Matrix67.2011-2012.Maze.js
Created November 8, 2012 10:11
Matrix67 2011->2012 Maze
// v2.0,避免一个for (in),速度大幅度提高,但graph的构造不如之前优雅,优化了hash,总代码量几乎没有增加,加了点注释。
var ops = ['+7', '/2', '*3', '-5'];
var graph = [
[{e:0,n:1}, {e:1,n:1}],
[{e:0,n:0}, {e:1,n:0}, {e:2,n:2}, {e:3,n:2}],
[{e:2,n:1}, {e:3,n:1}]
]; // 第一维是顶点,第二维是出边,e是边的id,n是指向的顶点。
graph.forEach(function(vex, i){
vex.forEach(function(edge, j){
edge.f = new Function('val', 'return val' + ops[edge.e]); // 把边构造成一个function
@sofish
sofish / jqLite.extra.js
Last active October 20, 2015 13:09
rewrite `parent` and `find` method for jqLite
angular.$ = angular.element;
// jqLite `.parent([selector])` 支持 selector
angular.$.prototype.parent = function(sel) {
if(!sel) return angular.$(this[0].parentNode);
var list = [].slice.call(document.querySelectorAll(sel))
, currentNode = this[0]
, ret;
while(currentNode.nodeName !== 'HTML') {
@kimukou
kimukou / build.gradle
Last active December 17, 2015 09:39
android gradle plugin test
defaultTasks 'clean', 'build'
version = "x.y.z"
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
var requestLib = require("request"),
request = requestLib.defaults({
json:true
}, function(uri, options, callback){
var params = requestLib.initParams(uri, options, callback);
return requestLib(params.uri, params.options, function(err, res, body){
// treat bad status codes as errors
if (!err && res.statusCode >= 400) {
params.callback.apply(this, [res.statusCode, res, body]);
} else {
@chrisyip
chrisyip / iojs.sh
Last active February 16, 2016 06:03
Get latest installed node from nvm path
#!/usr/bin/env sh
if [ -d "$(brew --prefix)/Cellar" ]; then
node=`find /usr/local/Cellar -name node | grep iojs/.*/bin/node`
if [ ! -z "$node" ]; then
$node $@
else
echo "io.js not installed"
fi
else
@nutinshell
nutinshell / gist:1d463ab3321dd5fa0d6e
Created October 26, 2015 15:07
Surge - Bypass CN CIDR
bypass-tun = 0.0.0.0/8, 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 59.64.0.0/10, 59.128.0.0/9, 60.0.0.0/10, 60.160.0.0/11, 60.192.0.0/10, 61.0.0.0/10, 61.64.0.0/11, 61.128.0.0/10, 61.224.0.0/11, 100.64.0.0/10, 101.0.0.0/9, 101.128.0.0/11, 101.192.0.0/10, 103.0.0.0/10, 103.192.0.0/10, 106.0.0.0/9, 106.224.0.0/11, 110.0.0.0/7, 112.0.0.0/9, 112.128.0.0/11, 112.192.0.0/10, 113.0.0.0/9, 113.128.0.0/11, 113.192.0.0/10, 114.0.0.0/9, 114.128.0.0/11, 114.192.0.0/10, 115.0.0.0/8, 116.0.0.0/8, 117.0.0.0/9, 117.128.0.0/10, 118.0.0.0/11, 118.64.0.0/10, 118.128.0.0/9, 119.0.0.0/9, 119.128.0.0/10, 119.224.0.0/11, 120.0.0.0/10, 120.64.0.0/11, 120.128.0.0/11, 120.192.0.0/10,
@soulmachine
soulmachine / Mutual.scala
Last active September 15, 2017 12:52
使用 Spark 计算新浪微博的互相关注的关系。输入为一个文本文件,每行的格式为 userid1, userid2, userid3,...,useridN, 表示用户userid1关注了userid2, userid3,...,useridN。输出也是一个文本文件,每行格式为 userid1, userid2,表示这两个用户互相关注了。
package com.yanjiuyanjiu.weibo
import org.apache.spark.SparkContext._
import org.apache.spark.{SparkContext, Logging}
/**
* 查找互相关注的关系。
*
* 输入为一个文本文件,每行的格式为 userId1, userId2, userId3,..., userIdN,表示 userId1 关注了 userId2, userId3, ..., userIdN