Skip to content

Instantly share code, notes, and snippets.

View zkat's full-sized avatar
🦀
Rusting it up

Kat Marchán zkat

🦀
Rusting it up
View GitHub Profile
@zkat
zkat / gist:5296480
Last active December 15, 2015 17:30
find/find_if search utilities
Array.prototype.find_if = function(test, opts) {
opts = opts || {};
var key = opts.key || identity;
var start = opts.start || 0;
var end = opts.end || this.length;
for (var i = 0; i < this.length; i++) {
if (test(key(this[i]))) {
return this[i];
}
}
@zkat
zkat / .vimperatorrc
Last active December 16, 2015 03:59
"loadplugins '\.(js|penta)$'
noremap <A-x> :
noremap <C-j> <Return>
noremap <C-f> <C-n>
noremap <C-b> <C-p>
noremap <C-a> 0
noremap <C-e> $
noremap <C-p> <Up>
noremap <C-n> <Down>
noremap <C-v> <PageDown>
@zkat
zkat / gist:6277858
Last active December 21, 2015 08:28
Some fun with obfuscation
[].__proto__.subsets=function f(s,c,t)[]+(t=this)?(c=Array.concat)((s=f.call(t.slice(1))).map(s=>c([t[0]],s)),s):[[]];
@zkat
zkat / gist:6479574
Last active December 22, 2015 13:29
  1. Navigate to your repository
  2. $ git remote update
  3. $ git checkout -b <"bugfix" or "feature">/<name> origin/develop
  4. Craft your amazing work of art with your favorite IDE/text editor.
  5. Type make and make sure the application builds successfully.
  6. $ git add <file or files that you changed>
  7. $ git commit -m "#<problemid> - <short text description>"
  8. $ git push -u origin HEAD
  9. ...process for asking branch to be merged...
@zkat
zkat / .XCompose
Last active December 1, 2023 03:05
# Compose key characters
# Default
include "/usr/share/X11/locale/en_US.UTF-8/Compose"
# Silly
<Multi_key> <colon> <parenright> : "( ´∀`)" U263A
<Multi_key> <less> <minus> : "←" U2190
<Multi_key> <minus> <greater> : "→" U2192
<Multi_key> <less> <greater> <minus> : "↔"
@zkat
zkat / gist:7049182
Last active December 25, 2015 22:19
// Inspired by https://twitter.com/nelhage/status/391265023357513728
function timeoutSort(array) {
var deferred = $.Deferred(),
res = [];
array.forEach(function(x) {
setTimeout(function() {
if (res.push(x) == array.length) {
deferred.resolve(res);
};
}, x + 15);
@zkat
zkat / domEqual.js
Last active December 26, 2015 08:39
Example dom comparison utility useful for testing
function domEqual(tree, expected, opts) {
function htmlNormalize(str) {
return str.replace(/\s+/gm, " ")
.replace(/>\s/gm, ">")
.replace(/\s</gm, "<");
}
tree = $(tree);
expected = $(expected);
opts = opts || {};
let treeHtml = tree[0].outerHTML,
@zkat
zkat / gist:8175523
Last active January 1, 2016 17:09
Solution for http://codecombat.com/play/level/gridmancer Relatively simple solution that solves the problem with 33 rectangles. Most of the code is spent handling an alternate grid that makes it easier to reason about tiles.
var tileSize = 4;
var makeGrid = function() {
var grid = [],
navGrid = this.getNavGrid().grid,
height = ~~(navGrid.length / tileSize),
width = ~~(navGrid[0].length / tileSize);
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
grid[y] = grid[y] || [];
@zkat
zkat / INSTALL.md
Created February 21, 2014 02:36 — forked from namuol/INSTALL.md

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.

@zkat
zkat / canjs-browserified.js
Last active August 29, 2015 13:56
CanJS browserify artifact generated from amd version
;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var can=require("can/util/library.js"),ThIsIsToTaLlYbeCaUsEiMlAzY=require("can/control/route.js"),ThIsIsToTaLlYbeCaUsEiMlAzY=require("can/model.js"),ThIsIsToTaLlYbeCaUsEiMlAzY=require("can/view/mustache.js"),ThIsIsToTaLlYbeCaUsEiMlAzY=require("can/component.js");module.exports=can;
},{"can/component.js":3,"can/control/route.js":7,"can/model.js":10,"can/util/library.js":20,"can/view/mustache.js":27}],2:[function(require,module,exports){
/*!
* jQuery JavaScript Library v2.1.0
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/