Skip to content

Instantly share code, notes, and snippets.

function nextCssColor() {
function random(min, max) {
min = +min || 0;
max = +max || 0;
return Math.round(Math.random() * (max - min) + min);
}
var colors = [
"aliceblue",
"antiquewhite",
@lamchau
lamchau / fixture-url-parser.js
Last active August 29, 2015 14:10
fixture pattern matcher
function parseUrl(url) {
url = String(url);
// expects api calls to be "/some/api/v(#)/some/path" with optional query params
// examples: http://regex101.com/r/vO8mU5/1
var regex = /.*\/v(\d+)((?:\/\w+)+)\??(.+)?$/i;
var match = url.match(regex);
console.assert("Invalid URL '" + url + "'", match);
var result = {
@lamchau
lamchau / helpers.js
Created November 17, 2014 04:40
Ember.js - Immutable check for production mode (FF4+, IE9+, Chrome 5+; modern browsers)
if (!Ember.productionMode) {
// relies on ember build tools which turn `Ember.assert` into a NOOP
Object.defineProperty(Ember, 'productionMode', {
value: Ember.assert && Ember.assert.length == 0
});
}
// more correct name name
// if (!Ember.assertionsEnabled) {
// // relies on ember build tools which turn `Ember.assert` into a NOOP
@lamchau
lamchau / lodash.padding.js
Last active August 29, 2015 14:09
underscore/lodash
_.mixin((function() {
function createPadding(value, pad, character) {
character = _.isValue(character) ? String(character) : " ";
var strPadded = "";
var length = pad - value.length;
while (strPadded.length < length && character.length) {
strPadded += character;
}
@lamchau
lamchau / experiment.sh
Created November 9, 2014 02:42
Homework assistance
#!/bin/bash
clear
BORDER=$(printf '=%.0s' {1..80})\\n
HEADER="%-10s %8s %-10s %24s %11s\n"
FORMAT="%-10s %8d %-10s %11.2f\n"
WIDTH=150
# not defined, what should this be?
# DIVIDER="DIVIDER"
@lamchau
lamchau / Aprosopo [email protected]
Created November 8, 2014 21:01
https://github.com/facelessuser/Aprosopo - Customizations for Aprosopo Dark ST3 - Blue/Red (Active/Dirty)
[
// sidebar heading (bold/white)
{
"class": "sidebar_heading",
"color": [255, 255, 255],
"font.bold": true,
"shadow_color": [0, 0, 0],
"shadow_offset": [0, -1],
},
[
// highlight modified files (blue for dirty files, like default theme)
{
"class": "tab_label",
"settings": ["highlight_modified_tabs"],
"parents": [{
"class": "tab_control",
"attributes": ["dirty"]
}],
"fg": [20, 100, 220]
[
// highlight modified files (orange for dirty files, like default theme)
{
"class": "tab_label",
"settings": ["highlight_modified_tabs"],
"parents": [{
"class": "tab_control",
"attributes": ["dirty"]
}],
// "fg": [120, 170, 250], // blue
@lamchau
lamchau / README.md
Last active August 29, 2015 14:07 — forked from milroc/README.md
using System;
namespace ConsoleApplication
{
enum Suit
{
DIAMOND,
CLUB,
HEART,
SPADE