Skip to content

Instantly share code, notes, and snippets.

View nijikokun's full-sized avatar
🍀
working

Niji nijikokun

🍀
working
  • Product Manager
  • San Diego, California
View GitHub Profile
@nijikokun
nijikokun / about.md
Last active August 29, 2015 14:23
jQuery Terminal Color Styles

jQuery Terminal Colorizer

If you've ever built a mock terminal application you'll know the pains that exist by not having a terminal coloring helper.

So here is a very basic one for the jQuery Terminal library.

Usage

function INFO (msg) {
@nijikokun
nijikokun / contains.js
Created May 12, 2015 21:02
String contains multiple values from either an array or multiple keys from object http://repl.it/ndH
function contains (string, map) {
var results = []
var value
for (var key in map) {
value = key
if (typeof map.length !== 'undefined') {
key = map[key]
}
@nijikokun
nijikokun / about.md
Last active August 29, 2015 14:20
Error signatures from common Node.js libraries

Node.js Module Specific Error Messages

Consolidated list and reference of error message signatures from commonly used Node.js libraries as I got tired of searching through source code / logging to ensure their commonly undocumented error message signatures.

Table of Contents

@nijikokun
nijikokun / m.component.js
Last active June 4, 2016 04:48
Mithril Templates / Helpers
// var ListComponent = m.component({ ... }) -> component
// var list = ListComponent() -> component instance
// list.view() -> view
m.component = function (component) {
return function (options, content) {
var controller = new component.controller(options)
controller.view = function () {
return component.view(controller, arguments[0] || options, arguments[1] || content)
}
@nijikokun
nijikokun / about.md
Last active August 29, 2015 14:19
LocalStorage / SessionStorage with expiration support written in LiveScript (can be compiled to JavaScript)

Corner Store

A full-featured and simple way to take advantage of localStorage or sessionStorage.

Features

  • Functional methods (forEach, every, some and map)
  • Ease of use methods (set, get, has, remove, clear and `empty)
  • Supports setting expiration (globally and per entry)
m.observable = (el={}) ->
_id = 0
callbacks = {}
el.on = (events, fn) ->
if typeof fn is 'function'
fn._id = if typeof fn._id is 'undefined' then _id++ else fn._id
events.replace /\s+/g, (name, pos) ->
callbacks[][name].push fn
fn.typed = pos > 0
@nijikokun
nijikokun / about.md
Last active August 4, 2017 04:47
Install Kong on Mac OS X

Mashape Kong OS X Installer

Current Version: 0.1.0

Installation

wget https://gist.githubusercontent.com/Nijikokun/189f84226f092dccd359/raw/22af60cb2d045f05ab9e59f657e0f2f97bf66ae9/kong-install
chmod +x ./kong-install
var m = require('mithril')
var h = require('virtual-dom/h')
var diff = require('virtual-dom/diff')
var patch = require('virtual-dom/patch')
var createElement = require('virtual-dom/create-element')
var validator = require('har-validator')
var app = {}
app.Har = function (data) {
@nijikokun
nijikokun / m.validator.js
Last active May 18, 2016 15:11
Mithril validation utility
m.validator = function (model, validations) {
this.errors = {}
this.validations = validations
this.model = model
}
m.validator.prototype.hasErrors = function () {
return Object.keys(this.errors).length
}
@nijikokun
nijikokun / flow.js
Last active August 29, 2015 14:17
Async flow for ES5/6 (Purely thought / psuedocode)
flo = flow
// Add method signature and arguments to be invoked
.add(/* [name, ]function[, arguments...] */)
// Attach thenable to previous method signature
.then(function () {
// skip(/* string name | int groups */)
flo.skip('name') // this.skip vs flo.skip vs (skip argument on argument list, after next)
// next(/* string name | int group */)