Skip to content

Instantly share code, notes, and snippets.

View nefarioustim's full-sized avatar

Tim Huegdon nefarioustim

View GitHub Profile
@nefarioustim
nefarioustim / nefarious-namespace.js
Last active February 25, 2018 10:35
JavaScript namespace helper
/* jshint esnext: true */
(function (){
"use strict";
let NEF = window.NEF || {};
NEF.namespace = function() {
let ln = arguments.length, i, value, x, xln, parts, object;
for (i = 0; i < ln; i++) {
(function (LocalStorage) {
var DELIM = "|";
LocalStorage.readit = function (key) {
console.log('FN .get for key', key);
var str = localStorage.getItem(key);
console.log('get raw=', str); // e.g. 't35'
if (str === null || str === ''){
return null
}
@nefarioustim
nefarioustim / .vimrc
Created June 12, 2013 13:45
Override read-only perms from within vim.
cmap w!! %!sudo tee > /dev/null %
@nefarioustim
nefarioustim / SublimeLinter.sublime-settings.js
Last active December 18, 2015 02:18
My SublimeLinter user settings
/*
SublimeLinter user settings
*/
{
"sublimelinter": true,
"sublimelinter_mark_style": "outline",
"sublimelinter_gutter_marks": true,
// CSSLint? GTFO
@nefarioustim
nefarioustim / input.rc
Created November 17, 2012 22:49
Better bash incremental searching
# Bash can cycle through lines starting in a particular way
#
# Just type in a few characters then press Up
# - Don’t need to press Up so many times
# - Don’t see lines that merely contain those letters
# - Don’t have to chance executing the wrong line
"\e[A": history-search-backward
"\e[B": history-search-forward
@nefarioustim
nefarioustim / perlin-noise-classical.js
Created November 10, 2012 18:25 — forked from banksean/perlin-noise-classical.js
two Perlin noise generators in javascript. The simplex version is about 10% faster (in Chrome at least, haven't tried other browsers)
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@nefarioustim
nefarioustim / wiki.md
Created September 19, 2012 15:34
Wikiman's Creed

This is my wiki. There are many like it, but this one is mine.

My wiki is my best friend. It is my life. I must master it as I must master my life.

My wiki, without me, is useless. Without my wiki, I am useless. I must wiki true. I must wiki better than my enemy who is trying to out wiki me. I must wiki him before he wikis me. I will...

My wiki and myself know that what counts in this war is not the docs we type, the users who read, or the communities we forge. We know that it is the wikis that count. We will hit...

My wiki is human, even as I, because it is my life. Thus, I will learn it as a brother. I will learn its weaknesses, its strength, its parts, its accessories, its widgets and its syntax. I will keep my wiki clean and ready, even as I am clean and ready. We will become part of each other. We will...

@nefarioustim
nefarioustim / largest-palindrome.js
Created July 31, 2012 17:19
Find the largest palindrome made from the product of two 3-digit numbers
function getPalindrome() {
var product, y,
x = 999,
largest = 0;
while (x > 99) {
y = x;
while (y > 99) {
product = x * y;
if (product <= largest) break;
@nefarioustim
nefarioustim / improved.js
Created July 31, 2012 09:34
Find the largest prime factor of a composite number
var x = 600851475143,
getLargestPrimeFactor = function(n) {
var largestPrimeFactor,
factor = 2;
while (n > 1) {
if (n % factor === 0) {
largestPrimeFactor = factor;
n = n / factor;
while (n % factor === 0) {
@nefarioustim
nefarioustim / world.js
Created April 18, 2012 08:59 — forked from andyhd/world.js
render with one loop
function drawMap(map) {
var x, y,
width = map[0].length,
current_node = map.length * width;
while (current_node--) {
x = current_node % width;
y = ~~(current_node / width);
drawTile({
x: x,
y: y