Skip to content

Instantly share code, notes, and snippets.

@a3linux
a3linux / gist:602ea54fc8ab771459332039425dc46e
Created November 3, 2016 01:35 — forked from rhelmer/gist:a053aedb863ef3d7d317
quick sync script for symbols
#!/usr/bin/env python
"""
A quick sync script for symbols from NFS->S3
We can't simply record the time our sync script ran and find all newer files
since files with timestamps in the past may appear. So, keep track of all .txt
index files that we encounter, and only sync files when there are additions
to that set.
"""
// Check isDir in golang
// use a switch to make it a bit cleaner
fi, err := file.Stat();
switch {
case err != nil:
// handle the error and return
case fi.IsDir():
// it's a directory
default:
// it's not a directory
# Decrease TIME_WAIT seconds
net.ipv4.tcp_fin_timeout = 30
# Recycle and Reuse TIME_WAIT sockets faster
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
@a3linux
a3linux / curl-ttfb.sh
Created March 1, 2016 03:11 — forked from acdha/curl-ttfb.sh
Use curl to measure and report HTTP response times (pre-, start- and total transfer)
#!/bin/bash
#
# Report time to first byte for the provided URL using a cache buster to ensure
# that we're measuring full cold-cache performance
while (($#)); do
echo $1
curl -so /dev/null -H "Pragma: no-cache" -H "Cache-Control: no-cache" \
-w "%{http_code}\tPre-Transfer: %{time_pretransfer}\tStart Transfer: %{time_starttransfer}\tTotal: %{time_total}\tSize: %{size_download}\n" \
"$1?`date +%s`"
@a3linux
a3linux / index.html
Created January 6, 2016 01:57 — forked from agarzon/index.html
My Html5 template with Jquery and Bootstrap from CDN
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Project Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<meta name="description" content="">
<link rel="shortcut icon" href="favicon.ico">
一只站在树上的鸟儿,从来不会害怕树枝断裂,因为她相信的不是树枝,而是她自己的翅膀
马行无力皆因瘦、人不风流只为贫
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
function git_unadded_new {
if git rev-parse --is-inside-work-tree &> /dev/null
then
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]
then
echo ""
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
/*
* Template backbone.js code that encapsulates a
* datatable.net table within a view for a hypothetical ;)
* auction listings application.
*/
var HomeRouter = Backbone.Router.extend({
routes: {
'refresh' : 'refresh',
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''将搜狗拼音导出的文本词库转换成ibus-libpinyin的用户词典
by Conanca
'''
content = open("搜狗词库导出_2014_1_6.txt").read().decode('utf16').encode('utf8')
lines = content.split('\n')
f=open('ibus.txt','w')