Skip to content

Instantly share code, notes, and snippets.

/*
* 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',
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);
};
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 ""
一只站在树上的鸟儿,从来不会害怕树枝断裂,因为她相信的不是树枝,而是她自己的翅膀
马行无力皆因瘦、人不风流只为贫
@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">
@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`"
# 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
// 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
@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.
"""
@a3linux
a3linux / gist:4d0ab1cf13d11fcf0f96281a47692e8f
Created November 3, 2016 01:35 — forked from rhelmer/gist:d3d99bd60e81be10f759
quick sync setup runner for symbols
#!/bin/bash
set -e
. /home/socorro/.virtualenvs/aws/bin/activate
PRIVATE_BUCKET="org.mozilla.crash-stats.symbols-private/v1"
PUBLIC_BUCKET="org.mozilla.crash-stats.symbols-public/v1"
TOP_DIR="/mnt/socorro/symbols"
PRIVATE_DIRS="symbols_adobe"