This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.c | |
// Mark Roberts | |
// Thanks: | |
// http://stackoverflow.com/questions/101439 | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stdint.h> // uint64_t => [0, ULONG_LONG_MAX] | |
// Same algorithm referenced on StackOverflow: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- Kaprekar Routine Visualization -} | |
-- Inspiration: http://mathworld.wolfram.com/KaprekarRoutine.html | |
import Data.Maybe | |
import Data.Word | |
import qualified List | |
import Data.Digits | |
import qualified Data.Vector.Storable as V | |
import Data.Array.Repa hiding ((++)) | |
import Data.Array.Repa.IO.DevIL | |
import Data.Array.Repa.ByteString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# stylecheck.sh: | |
# | |
# Find unused CSS class and id selectors, given a CSS file and a directory | |
# of HTML documents. | |
# | |
# $1 = CSS document, $2 = HTML directory | |
# | |
# Returns a report in YAML. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'css_parser' | |
puts "Report of Unused CSS Rules\n---\nHTML Path:\t" + ARGV[0] + "\n" | |
htmls = (`ack '' #{ARGV[0]} -l --type html`).split("\n").map { |html| Nokogiri::HTML(File.read(html)) } | |
styles = (1..ARGV.length-1).inject(Array.new) { |a, i| a | (`ack '' #{ARGV[i]} -l --type css`).split("\n") } | |
puts "\t- Checking " + htmls.length.to_s + " HTML file(s) against " + styles.length.to_s + " stylesheet(s)\n\n" | |
styles.each do |style| | |
puts "Stylesheet:\t" + style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Because Jinja2 is the default template loader, add any non-Jinja templated | |
# apps here: | |
JINGO_EXCLUDE_APPS = [ | |
'admin', | |
'registration', # Added registration | |
'debug_toolbar', | |
'debug_toolbar_user_panel', | |
'memcache_toolbar', | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Variable Scoping in JavaScript: A counter-intuitive example? */ | |
// Initally empty list of functions | |
fs = []; | |
// Populate `fs` with functions. | |
for (var i=0; i<10; i++) { | |
fs.push(function() { | |
console.log(i); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
static inline int | |
rand_in_range (int l, int u) | |
{ | |
assert (l <= u); | |
int r=(random () % (u-l+1)) + l; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
static char keypad[10][5]={"0","1","ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"}; | |
static char options[10] ={ 1 , 1 , 3 , 3 , 3 , 3 , 3 , 4 , 3 , 4 }; | |
static inline bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-#LANGUAGE TemplateHaskell #-} | |
import Control.Lens | |
import Control.Monad.State | |
data Tree a = Node a | |
| Branch a (Tree a) (Tree a) | |
childrenOf (Node _) = [] | |
childrenOf (Branch _ l r) = [l, r] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-#LANGUAGE TemplateHaskell, NoImplicitPrelude, StandaloneDeriving #-} | |
module StableMarriage | |
( -- * Usage | |
-- $usage | |
Id | |
, Rank | |
, stableMarriage | |
-- * Internals | |
-- ** Partner |
OlderNewer