Skip to content

Instantly share code, notes, and snippets.

@irrationalistic
irrationalistic / index.html
Last active August 29, 2015 14:00
PaperJS Qber
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Untitled</title>
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
@irrationalistic
irrationalistic / keymap.cson
Last active August 23, 2016 08:24
Vim + Colemak on Atom
# Override Vim Bindings for Colemak
'.editor.vim-mode:not(.command-mode)':
'cmd-k': 'vim-mode:activate-command-mode'
'cmd-shift-k': 'vim-mode:activate-command-mode'
'cmd-h': 'core:move-left'
'cmd-i': 'core:move-right'
'cmd-e': 'core:move-up'
'cmd-n': 'core:move-down'
@irrationalistic
irrationalistic / snippets.cson
Last active August 29, 2015 14:01
Atom: Template tag snippet
'.html':
'Template Tag':
'prefix': 'tp'
'body': '<template name="$1" id="$1">\n\t$2\n</template>'
@irrationalistic
irrationalistic / parseTweet.js
Created May 29, 2014 20:55
Parse Tweets - Simple
var parseTweet = function(tweetText) {
var reghash, reguri, regusername;
reguri = /(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/=]*))/g;
regusername = /([@]+([A-Za-z0-9-_]+))/g;
reghash = /[#]+([A-Za-z0-9-_]+)/g;
tweetText = tweetText.replace(reguri, "<a href='$1' target='_blank'>$1</a>");
tweetText = tweetText.replace(regusername, "<a href='http://twitter.com/$2' target='_blank'>$1</a>");
tweetText = tweetText.replace(reghash, "<a href='http://twitter.com/search?q=%23$1' target='_blank'>#$1</a>");
return tweetText;
};
@irrationalistic
irrationalistic / app.js
Created June 5, 2014 00:52
Deep async for parsing RxTerm data
app.get('...', function(req, res){
var lines = [...];
var lineFns = lines.map(function(line){
return function(cbLines){
var words = line.split(' ');
var wordFns = words.map(function(word){
return function(cbWords){
Model.find({term: word}, function(err, docs){
if(docs.length === 0)
@irrationalistic
irrationalistic / require_snippet.sublime-snippet
Created June 10, 2014 21:54
sublime text nodejs "require" snippet
<snippet>
<content><![CDATA[
var ${2:${1/.*\/([^\.]+)[\.]?(.*)/$1/g}} = require('${1:lib}');
]]></content>
<tabTrigger>req</tabTrigger>
<scope>source.js</scope>
</snippet>
@irrationalistic
irrationalistic / main.js
Created June 20, 2014 19:21
Coderbyte - Array Addition
function ArrayAddition(arr) {
// calculate the largest possible number
var startArr = arr.sort(function(a,b){return b-a});
var largest = startArr.shift();
// return true if the current total plus any number is
// the largest option
var checker = function(curArr, curTotal){
// Go through each item in the current set
@irrationalistic
irrationalistic / Default (OSX).sublime-keymap
Last active May 1, 2017 02:41
Vim Colemak keybindings in ST3
[
// movement in command mode
// up
{
"keys": ["e"],
"command": "set_motion",
"args": {
"motion": "move",
"motion_args": {"by": "lines", "extend": true, "forward": false }
@irrationalistic
irrationalistic / main.js
Created June 25, 2014 17:35
Common JS Built-In Functions
// STRING FUNCTIONS
console.log('----- STRINGS -----');
// indexOf( substr )
// return -1 if not found
// return index of string found
console.log('String indexOf:', 'hello world'.indexOf('l') );
// ^ String indexOf: 2
console.log('String indexOf:', 'hello world'.indexOf('nope') );
// ^ String indexOf: -1
@irrationalistic
irrationalistic / main.js
Created July 1, 2014 20:01
Get the word with the highest character repetition
var getReps = function(str){
return _.chain(str.split(' '))
.map(function(w){
return {
word: w,
reps: _.chain(w.toUpperCase().split(''))
.groupBy(_.identity)
.max(function(g){
return g.length;
})