Skip to content

Instantly share code, notes, and snippets.

@xmlking
xmlking / Enum.es6.js
Last active June 25, 2019 18:09
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@zhhailon
zhhailon / rails_on_arch.sh
Created October 19, 2011 05:21
A quick and dirty Rails development environment using Arch Linux
### Get Repos Ready ###
# initial update & upgrade
sudo pacman -Syu
# install new apps
sudo pacman -Sy --noconfirm gcc patch curl zlib readline libxml2 libxslt git autoconf diffutils make libtool bison subversion vim-rails qgit
# configure git
git config --global user.name your-username
@msmhrt
msmhrt / client_handler.js
Created October 7, 2011 19:20
An example of ClientHandler of Google Apps Script Gadget
/*global UiApp:false, Utilities:false */
function apply_style(widget, styles) {
'use strict';
var key;
for (key in styles) {
if (styles.hasOwnProperty(key)) {
widget.setStyleAttribute(key, styles[key]);
@mloughran
mloughran / pubsub_example.rb
Created September 14, 2011 15:05
em-hiredis pubsub example
require 'em-hiredis'
EM.run {
require 'em-hiredis'
redis = EM::Hiredis.connect
# If you pass a block to subscribe it will be called whenever a message
# is received on this channel
redis.pubsub.subscribe('foo') { |msg|
p [:received_foo, msg]