Skip to content

Instantly share code, notes, and snippets.

View wondersloth's full-sized avatar

Matthew Edwards wondersloth

View GitHub Profile
@wondersloth
wondersloth / cc_validator.js
Created January 9, 2015 19:11
Validate Credit Card (Luhn Algorithm)
// http://en.wikipedia.org/wiki/Luhn_algorithm
var _ = require('lodash');
var cc = '7992739871';
function computeChecksum(cc) {
return _.reduce(cc, function (memo, value, index) {
var value = parseInt(value, 10);
@wondersloth
wondersloth / happy_number_finder.js
Last active December 19, 2015 21:59
Happy Number Finder
(function () {
var UNHAPPY_SEQUENCE = [4, 16, 37, 58, 89, 145, 42, 20, 4];
var UNHAPPY_SEQUENCE_LENGTH = UNHAPPY_SEQUENCE.length;
function calculate(number) {
var str = '' + number;
var length = str.length;
var total = 0;
@wondersloth
wondersloth / frim
Created March 11, 2013 21:41
Frimmin'
say -r 450 -v Trinoids "Frimmin' on the frim fram, frimmin on the frim"
@wondersloth
wondersloth / base.php
Created June 21, 2011 22:52
Kohana Page Rendering Scheme
<?php defined('SYSPATH') or die('No direct script access.');
abstract class Controller_SiteLayout_Base extends Controller {
public $template = 'layout/base/page';
public $auto_render = TRUE;
/**
* The before() method is called before your controller action.
@wondersloth
wondersloth / demo.html
Created April 15, 2011 22:59
An extension for LinkedIn's platform.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>LinkedIn Colleague Search</title>
<style type="text/css" media="screen">
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@wondersloth
wondersloth / template_anon_func.php
Created February 26, 2011 05:06
Template rendering with anonymous functions.
<?php
class Template
{
function __construct($items, Closure $render)
{
foreach ($items as $i) {