Skip to content

Instantly share code, notes, and snippets.

View Gwash3189's full-sized avatar

Adam Beck Gwash3189

View GitHub Profile
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Immutable = (function () {
function Immutable() {
this.objectString = "object";
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script>
window.xinj = function(obj) {
debugger;
@Gwash3189
Gwash3189 / countGroupings.fs
Last active August 29, 2015 14:06
Count occurrences of the starting character in a sequence.
let createGroupings lineSeq =
lineSeq |> Seq.map (fun element -> element.[0])
|> Seq.countBy id
|> Seq.toList
let list = ["asd"; "dsa"]
createGroupings list
@Gwash3189
Gwash3189 / bus.js
Created October 6, 2014 05:35
Event / Subscribable bus system with Ko Subscribables.
window.Bus = function(name, funcs, parent) {
funcs = funcs instanceof Array === true ? funcs : [funcs];
var bus = {};
var sub = new ko.subscribable();
var functionType = "function";
bus.name = name;
bus.children = [];
bus.previousMessages = [];
bus.extend = function(name, funcs) {
var childBus = window.Bus(name, funcs, bus);
@Gwash3189
Gwash3189 / index.html
Last active August 29, 2015 14:07 — forked from anonymous/index.html
flippable D&D 5E monster card
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/knockout/3.0.0/knockout-min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
@Gwash3189
Gwash3189 / compose.js
Last active August 29, 2015 14:14
Pass unlimited amount of functions to compose to create a new function that builds on previous values.
var reverseForEach = function(arr, fun) {
for (var i = arr.length - 1; i > -1; --i) {
fun(arr[i], i, arr);
}
}
var compose = function() {
var funcs = Object.keys(arguments);
var outterArgs = arguments;
return function() {
@Gwash3189
Gwash3189 / is.js
Last active August 29, 2015 14:15
advanced_is.js
var chainedAndFuncs = [];
var chainedOrFuncs = [];
var lastIntentEnum = {
none: 0,
and: 1,
or: 2
};
var lastChainedIntent = lastIntentEnum.none;
var convertArgumentsToArray = function(args) {
var biker = {
parse: function(template) {
var rightCurly = "{";
var leftCurly = "}";
var cleanArray = function(x) {
return x;
};
var splitLeftCurly = function(x) {
var s = x.split(leftCurly)[0];
return s;
@Gwash3189
Gwash3189 / fizzBuzz.js
Created April 26, 2015 23:09
FizzBuzz Kata
var fizzBuzzKata = function() {
var limit = 100;
var mod = function(mod, value){
return (mod && value) ? value % mod === 0 : value;
};
var modFifteen = function(i){return mod(15, i);};
var modFive = function(i){return mod(5, i);};
var modThree = function(i){return mod(3, i);};
var fizzBuzz = function(){console.log("Fizz Buzz");};
var buzz = function(){console.log("Buzz");};
@Gwash3189
Gwash3189 / reFizzBuzz.js
Created May 6, 2015 10:47
FizzBuzz with recursion
function fizzBuzz(limit, logger, value){
value = value || 1;
var logged = false;
if(shouldLog(mod(value, 15), logged)){
logger("FizzBuzz");
setLogged();
} else if(shouldLog(mod(value, 5), logged)){
logger("Buzz");
setLogged();