Skip to content

Instantly share code, notes, and snippets.

Alvin Liang aliang

  • Recovers
  • Burlingame, CA
Block or report user

Report or block aliang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 Sep 6, 2019
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 Jul 30, 2019
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 Dec 4, 2018 — 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 Sep 16, 2019
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
View gist:5469009
type T struct {
A int
B string
}
t := T{23, "skidoo"}
s := reflect.ValueOf(&t).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
@errordeveloper
errordeveloper / Unicorn_and_Upstart.md
Last active Mar 5, 2019
Upstart config for a Rails app using Unicorn HTTP server
View Unicorn_and_Upstart.md

Using Unicorn with Upstart

This configuration works with Upstart on Ubuntu 12.04 LTS

The reason why it needs to be done this way (i.e. with the pre-start and post-stop stanzas), is because Upstart is unable to track whever Unicorn master process re-execs itself on hot deploys. One can use it without hot-deploys and run Unicorn in foreground also, it then only needs one exec stanza.

This presumes you are not using RVM, so no voodoo dances.

You can’t perform that action at this time.