Skip to content

Instantly share code, notes, and snippets.

Alvin Liang aliang

  • Burlingame, CA
View GitHub Profile
@montanaflynn
montanaflynn / main.go
Last active Jun 21, 2020
Gin request timeout middleware and handler
View main.go
package main
import (
"context"
"log"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
@ryboe
ryboe / .travis.yml
Last active Jun 13, 2020
Example .travis.yml for Golang
View .travis.yml
# use the latest ubuntu environment (18.04) available on travis
dist: bionic
language: go
# You don't need to test on very old versions of the Go compiler. It's the user's
# responsibility to keep their compiler up to date.
go:
- 1.14.x
View app,assets,javascripts,static_resources.js
function requireAll(r) { r.keys().forEach(r); }
requireAll(require.context('../images/', true, /\..*$/));
requireAll(require.context('./vendors/', true, /\..*$/));
@jamesmartin
jamesmartin / application_controller.rb
Created May 25, 2015
Testing ApplicationController before_filter methods using RSpec's "anonymous" controller instance
View application_controller.rb
class ApplicationController < ActionControllerBase
helper :do_something
def do_something
@from_do_something = params[:for_do_something]
end
end
@voter101
voter101 / Gulpfile.js
Last active Jun 20, 2019
Gulpfile for Rails application with replaced Sprockets with Gulp
View Gulpfile.js
'use strict'
var gulp, sass, babelify, browserify, watchify, source, util;
gulp = require('gulp');
sass = require('gulp-sass');
babelify = require('babelify')
browserify = require('browserify');
watchify = require('watchify');
source = require('vinyl-source-stream');
@mikelehen
mikelehen / generate-pushid.js
Created Feb 11, 2015
JavaScript code for generating Firebase Push IDs
View generate-pushid.js
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@acolyer
acolyer / service-checklist.md
Last active Jun 16, 2020
Internet Scale Services Checklist
View service-checklist.md

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@pascalduez
pascalduez / SassMeister-input.scss
Last active Jun 1, 2020
Some Sass string functions: capitalize, ucwords, camelize, ...
View SassMeister-input.scss
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// Capitalize string
// --------------------------------------------------------------------------------
// @param [string] $string
// --------------------------------------------------------------------------------
// @return [string]
@dogoku
dogoku / A README.md
Last active May 1, 2020 — forked from tiffon/Find Results.hidden-tmLanguage
Search result syntax highlighting for Sublime Text
View A README.md

#ST2/3 Search result syntax highlighting

##Introduction and disclaimer

This is gist contains an edited Find Results.hidden-tmLanguage which adds syntax highlighting to your ST search results. As far as I know, there is no plugin that does this and for that reason it needs to be done via config.

DISCLAIMER: Use this HACK at your risk and backup the original files you are about to mess with.

##Usage Guide for Sublime Text 2

@mwhite
mwhite / git-aliases.md
Last active Jun 29, 2020
The Ultimate Git Alias Setup
View git-aliases.md

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
You can’t perform that action at this time.