Skip to content

Instantly share code, notes, and snippets.

View neatnick's full-sized avatar
⚖️
Weighing trash

Nick Balboni neatnick

⚖️
Weighing trash
  • Rezzi
  • Boston, Mass.
View GitHub Profile
@neatnick
neatnick / emoji-replace.js
Created October 21, 2016 22:17
Halloween Spirit
$("h1, h2, h3, h4, span, p").text(function(index, text){ return text.replace(/o/ig, "🎃").replace(/a/ig, "💀"); });
@neatnick
neatnick / gist:5ff3fc9c396190a302e9
Created June 26, 2015 22:29
Sublime text settings
{
"font_face": "Consolas",
"font_size": 8,
"ignored_packages":
[
"Vintage"
],
"tab_size": 4,
"translate_tabs_to_spaces": true
}
@neatnick
neatnick / format.js
Last active August 29, 2015 14:23
Python-like string formatting for JavaScript.
Array.prototype.flatten = function() {
return this.reduce(function(prev, cur) {
var more = [].concat(cur).some(Array.isArray);
return prev.concat(more ? cur.flatten() : cur);
},[]);
};
String.prototype.format = function () {
var content = this;
// regular for loop would probably be more efficient than the forEach
@neatnick
neatnick / pascal.py
Created May 5, 2015 17:43
Python script to generate Pascal's Triangle
from math import ceil, floor, log10
def pascal(rows, p_row):
print(" "*rows+ " ".join([" "*(3-floor(log10(x))) + str(x) for x in p_row]))
if rows:
p_row.append(1)
for i in reversed(range(ceil(len(p_row)/2)-1)):
p_row[i+1] += p_row[i]
p_row[-(i+2)] = p_row[i+1]
pascal(rows-1, p_row)