Skip to content

Instantly share code, notes, and snippets.

Avatar

Alvin Liang aliang

  • Burlingame, CA
View GitHub Profile
@statico
statico / purple-air-aqi.15m.sh
Last active Aug 26, 2020
Purple Air Sensor Plugin for BitBar
View purple-air-aqi.15m.sh
#!/usr/bin/env bash
#
# <bitbar.title>Purple Air PM2.5 AQI</bitbar.title>
# <bitbar.dependencies>bash,jq,node</bitbar.dependencies>
#
# Derived from https://github.com/matryer/bitbar-plugins/blob/master/Weather/aqi.15m.sh by Chongyu Yuan
COLORS=("#0ed812" "#ffde33" "#ff9933" "#cc0033" "#660099" "#7e0023" "#404040")
PURPLE_AIR_SENSOR_ID=5220
@montanaflynn
montanaflynn / main.go
Last active Nov 2, 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 Sep 29, 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 Nov 24, 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 Sep 14, 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

You can’t perform that action at this time.