Skip to content

Instantly share code, notes, and snippets.

(function() {
this.tmpl3 = function tmpl(str, data) {
var value = "var out = ''; out+=" + "'" +
str.replace(/[\r\t\n]/g, " ")
.replace(/'(?=[^%]*%>)/g,"\t")
.split("'").join("\\'")
.split("\t").join("'")
.replace(/<%=(.+?)%>/g, "'; out += $1; out += '")
.split("<%").join("';")
#!/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 / 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 / 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
@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 / phpunzip.php
Created May 10, 2017 09:32 — forked from samwhelp/phpunzip.php
PHP ZIP 解壓縮,檔名編碼自動轉為Utf-8編碼範例
#!/usr/bin/env php
<?php
/**
* PHP ZIP 解壓縮,檔名編碼自動轉為Utf-8編碼範例。
*
* @see https://gist.github.com/samwhelp/2f6764561bc3b5f15125
* @see http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?post_id=327124#forumpost327124
* @see http://micy.cn/blog/post/118
* @see http://www.chengcms.com/study/391.html?jdfwkey=wtgln3
* @see http://forum.ubuntu.org.cn/viewtopic.php?f=163&t=325386
@xuyang2
xuyang2 / main.go
Created May 15, 2018 12:33 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
bool
create_process_as_login_user(
_In_ const wchar_t* cmdline
)
{
_ASSERTE(NULL != cmdline);
if (NULL == cmdline) return false;
DWORD session_id = WTSGetActiveConsoleSessionId();
DWORD explorer_pid = 0xFFFFFFFF;
@xuyang2
xuyang2 / curl.md
Created August 10, 2018 01:29 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@xuyang2
xuyang2 / win_subprocess.py
Created January 18, 2019 13:07 — forked from vaab/win_subprocess.py
Fixing python 2.7 windows unicode issue with ``subprocess.Popen``.
## issue: https://bugs.python.org/issue19264
import ctypes
import subprocess
import _subprocess
from ctypes import byref, windll, c_char_p, c_wchar_p, c_void_p, \
Structure, sizeof, c_wchar, WinError
from ctypes.wintypes import BYTE, WORD, LPWSTR, BOOL, DWORD, LPVOID, \
HANDLE