Skip to content

Instantly share code, notes, and snippets.

View Gwash3189's full-sized avatar

Adam Beck Gwash3189

View GitHub Profile
const twistUp = (str) => {
const lookup = {
'a': 'áăắặằẳẵǎâấậầẩẫäạàảāąåǻãɑɐɒ',
'b': 'ḅɓß♭␢Б',
'c': 'ćčçĉɕċ',
'd': 'ďḓḍɗḏđɖ',
'e': 'éĕěêếệềểễëėẹèẻēęẽɘəɚ',
'f': 'ƒſʃʆʅɟʄ',
'g': 'ǵğǧģĝġɠḡɡ',
'h': 'ḫĥḥɦẖħɧ',
const src = `
var a = 1;
var b:string = '123'
interface User {
name: string
}
`;
const getDataBetweenChars = (start, end, data) => {
const lines = cleanArray(data.split('\n'))
@Gwash3189
Gwash3189 / Either.js
Created September 30, 2015 00:33
either - left - right
const Left = function(x) {
this.__value = x;
};
Left.of = function(x) {
return new Left(x);
};
Left.prototype.map = function(f) {
return this;
@Gwash3189
Gwash3189 / index.html
Created September 20, 2015 06:49
mobile search input
<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<style>
.Form--search-input {
-webkit-box-sizing: border-box;
@Gwash3189
Gwash3189 / kofta.js
Last active August 30, 2015 22:25
Kofta currying library
const kofta = function(func) {
const OrEqualTo = (func, x, y) => func(x, y) || Equals(x, y);
const GreaterThan = (x, y) => x > y;
const Equals = (x, y) => x === y;
const True = (x) => Equals(x, true);
const Null = (n) => Equals(n, null);
const Maybe = (bool, func) => !!bool ? func() : undefined;
const MaybeOrElse = (bool, m, e) => Maybe(bool, m) || Maybe(!bool, e)
const handle = function(func) {
@Gwash3189
Gwash3189 / typr.js
Created July 6, 2015 07:49
runtime type checking idea with decorators
const _string = (v) => typeof v === "string"
const _none = (v) => v === undefined || v === null;
function string(target, name, desc) {
return createNewDescriptor("string", _string).apply(null, arguments);
}
function none(target, name, desc) {
return createNewDescriptor("undefined", _none).apply(null, arguments);
}
@Gwash3189
Gwash3189 / validator.coffee
Created June 23, 2015 03:51
basic fluid validation in coffeescript
class ValidationInstance
constructor: (@item, @rules...) ->
class Validation
flatten = (arr) ->
merged = [];
merged.concat.apply(merged, arr);
_toValidate = null
instances = []
@Gwash3189
Gwash3189 / bling.js
Last active August 29, 2015 14:23 — forked from paulirish/bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn)
}
NodeList.prototype.__proto__ = Array.prototype
@Gwash3189
Gwash3189 / curry.js
Created June 13, 2015 05:43
call a function curried instead of normally
Function.prototype.curry = function(){
var length = getParamNames(this); //get arguments length
if(arguments.length === length){ //if all the arguments are provided
return this.apply(null, arguments); //call itself with the provided arguments
} else { // if not enough arguments provided
var outterArgs = argumentsToArray(arguments); //convert the argument 'array-like object' into a real array
return cacheOutterArguments(outterArgs, this); //cache the arguments in a function,
//pass original 'this' and return a new function
}
@Gwash3189
Gwash3189 / fib.js
Created June 13, 2015 05:31
Recursive fibonacci sequence
function fib(prev=[], loop=100, cb=function(){}) {
if(!prev.length){
prev.unshift(0);
prev.unshift(1);
}
prev.unshift(prev[1] + prev[0]);
cb(prev);
if(loop === 0){
return prev;