Skip to content

Instantly share code, notes, and snippets.

@xuyang2
xuyang2 / statuses.md
Created August 17, 2016 11:05 — forked from vkostyukov/statuses.md
HTTP status codes used by world-famous APIs
API Status Codes
[Twitter][tw] 200, 304, 400, 401, 403, 404, 406, 410, 420, 422, 429, 500, 502, 503, 504
[Stripe][stripe] 200, 400, 401, 402, 404, 429, 500, 502, 503, 504
[Github][gh] 200, 400, 422, 301, 302, 304, 307, 401, 403
[Pagerduty][pd] 200, 201, 204, 400, 401, 403, 404, 408, 500
[NewRelic Plugins][nr] 200, 400, 403, 404, 405, 413, 500, 502, 503, 503
[Etsy][etsy] 200, 201, 400, 403, 404, 500, 503
[Dropbox][db] 200, 400, 401, 403, 404, 405, 429, 503, 507
@xuyang2
xuyang2 / install-graphite-ubuntu-12.04.sh
Created December 4, 2015 05:40 — forked from jgeurts/install-graphite-ubuntu-12.04.sh
Install Graphite 0.9.10 on Ubuntu 12.04
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
(gci C:\Users -r | ? {$_.PSIsContainer -eq $True}) | ? {$_.GetFiles().Count + $_.GetDirectories().Count -eq 0} | select FullName
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
@xuyang2
xuyang2 / benchmark.py
Created October 15, 2015 08:01 — forked from eamartin/benchmark.py
Python JSON Benchmark
'''cjson, jsonlib, simplejson, and yajl also use C code
demjson did not use C code, but was too painfully slow to benchmark
(took about 20 seconds for these tests)
'''
import json
import sys
import time
with open('doc.json') as f:
@xuyang2
xuyang2 / qs.js
Created July 25, 2014 11:32
Angular query string utilities
// expose angular query string utilities
(function () {
'use strict';
var module = angular.module('myQueryString', []);
module.factory('myQueryString.QueryString', [function () {
var forEach = angular.forEach;
var hasOwnProperty = angular.hasOwnProperty;
var isArray = angular.isArray;
/**
* @see http://www.java2s.com/Code/Java/Security/JCEalgorithmsinBrowser.htm
*/
import java.awt.Dimension;
import java.security.Provider;
import java.security.Security;
import java.util.HashSet;
import java.util.Set;
import junit.framework.Assert;
import org.apache.commons.codec.binary.Base64;
import org.bouncycastle.crypto.engines.RC4Engine;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.Before;
import org.junit.Test;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
#!/bin/sh
# one way (older scala version will be installed)
# sudo apt-get install scala
#2nd way
sudo apt-get remove scala-library scala
wget www.scala-lang.org/files/archive/scala-2.10.3.deb
sudo dpkg -i scala-2.10.3.deb
sudo apt-get update
@xuyang2
xuyang2 / gist:9932749
Created April 2, 2014 12:02
underscore mixins
_.mixin({
/**
* Iterates over an array of numbers and returns the sum. Example:
*
* var sum = _.sum([1, 2, 3]);
* => 6
*
* @param obj
* @returns {Number}
*/