Skip to content

Instantly share code, notes, and snippets.

View hackingbeauty's full-sized avatar
💯

Mark Muskardin hackingbeauty

💯
View GitHub Profile
# Josiah Carlson - Programming Challange from Erann Gat:
# http://www.flownet.com/ron/papers/lisp-java/
# Given a list of words and a list of phone numbers, find all the ways that
# each phone number can be expressed as a list of words.
from collections import defaultdict
import sys
MAPPING = {'e':0, 'j':1, 'n':1, 'q':1, 'r':2, 'w':2, 'x':2, 'd':3, 's':3,
'y':3, 'f':4, 't':4, 'a':5, 'm':5, 'c':6, 'i':6, 'v':6, 'b':7, 'k':7,
@hackingbeauty
hackingbeauty / task.js
Created June 10, 2011 06:35 — forked from sr3d/task.js
My own version of ActiveRecord that actually works on Titanium.
(function() {
App.Models.Task = App.Models.Base.createModel('Task', 'tasks', {
name: 'TEXT',
note: 'TEXT',
due_at: 'DATE',
is_completed: 'TEXT',
completed_at: 'TEXT',
category_id: 'TEXT',
event_id: 'INTEGER',
has_reminders: 'TEXT',
@hackingbeauty
hackingbeauty / no_console_log_errors
Created October 18, 2012 01:30
Avoiding console.log errors
// Avoid `console` errors in browsers that lack a console.
(function() {
var noop = function noop() {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
];
var length = methods.length;
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
<![endif]-->
@hackingbeauty
hackingbeauty / hamlfied-html5boilerplate
Created November 30, 2012 21:26
Hamlfied version of HTML5Boilerplate when using grunt-haml npm
!!!
/[if lt IE 7] <html class='no-js lt-ie9 lt-ie8 lt-ie7'>
/[if IE 7] <html class='no-js lt-ie9 lt-ie8'>
/[if IE 8] <html class='no-js lt-ie9'>
/ [if gt IE 8]><!
%html.no-js
/ <![endif]
%head
%meta{charset : "utf-8"}/
%meta{http-equiv : "X-UA-Compatible", content : "IE=edge,chrome=1"}/
def get_cache_path_url
if is_mobile_request?
"cached_page#{request.path.gsub("/","")}_mobile"
else
"cached_page#{request.path.gsub("/","")}_desktop"
end
end
var proto = {
sentence : 4,
probation : 2
}
var makePrisoner = function(name,id) {
var prisoner = Object.create(proto);
prisoner.name = name;
prisoner.id = id;
return prisoner;
@hackingbeauty
hackingbeauty / gist:5808543
Created June 18, 2013 19:36
Largest & Second Largest Algos
Array.prototype.largest_number =function() {
var largest;
for (var i=0; i<this.length; i++) {
var num = this[i];
if(largest === undefined){
largest = num;
} else if (num > largest) {
largest = num;
}
}
@hackingbeauty
hackingbeauty / gist:6224558
Last active December 21, 2015 00:59
Start of Game of Life challenge
var prompt = require('prompt');
GameOfLife = {
input: {},
grid: [],
init: function(){
this.prompt();
},
// Prompt for input
prompt: function(){
@hackingbeauty
hackingbeauty / gist:6441715
Created September 4, 2013 19:31
Find pairs that equal 100, remove duplicate pairs.
Array.prototype.sumPairs = function(){
var arr = this, pairs = [], subPair, currentElem, compareElem;
for(var i = 0; i < arr.length; i++){
currentElem = arr[i];
for(var j = i+1; j<arr.length; j++){
compareElem = arr[j];
if((currentElem + compareElem) === 100){
subPair = new Array();
subPair.push(currentElem);