Skip to content

Instantly share code, notes, and snippets.

View mwotton's full-sized avatar

Mark Wotton mwotton

View GitHub Profile
ab1de 2001 3 3 3
ab1de 2003 1 1 1
ab1de 2005 2 2 2
ab1de 2007 1 1 1
ab1l1ty 1865 1 1 1
ab1l1ty 1890 1 1 1
ab1l1ty 1892 1 1 1
ab1l1ty 1893 1 1 1
ab1l1ty 1894 1 1 1
ab1l1ty 1897 1 1 1
@mwotton
mwotton / gist:994493
Created May 27, 2011 01:44
json format
GET /comments/1,2
gives
{ 1 => {"ok": {
"email": "user@corp.com",
"text": "this is right on the money. let's invade lichtenstein.",
"created_at": "Tue, 04 Nov 2008 06:52:28 +0000",
solve :: [Int] -> Bool
solve (0:_) = error "stop playing around"
solve (_:pd:0:_) = pd == 0 -- if we've never won any ever, we can't have won today
solve (_:pd:100:_) = pd == 100 -- if we've never lost, we can't have lost today
solve (n:pd:_) = d_step <= n
where d_step = dotrace $ product $ primeFactors 100 \\ (primeFactors pd)
@mwotton
mwotton / gist:1010144
Created June 6, 2011 12:09
62% in floor?
-- diff_i = {-# SCC "diff_i" #-} floor2 . logged
-- floor2 = {-# SCC "floor" #-} floor
-- logged p = {-# SCC "logged" #-} (logBase (fromIntegral p) (fromIntegral no)) - 1
-- full app
{-# LANGUAGE ScopedTypeVariables #-}
-- highest is pretty easy to get - we're always going to end up at the LCM of 1..n
-- if you go in in order, then everyone's unhappy up to n
-- but then all bets are off. damn.
*Main Test.QuickCheck> logBase 1 1
NaN
*Main Test.QuickCheck> (floor $ logBase 1 1)
-269653970229347386159395778618353710042696546841345985910145121736599013708251444699062715983611304031680170819807090036488184653221624933739271145959211186566651840137298227914453329401869141179179624428127508653257226023513694322210869665811240855745025766026879447359920868907719574457253034494436336205824
@mwotton
mwotton / gist:1035287
Created June 20, 2011 08:14
bundler weirdness
root@ubuntu:/var/lib/gems/1.9.2/gems# gem list bundler
*** LOCAL GEMS ***
root@ubuntu:/var/lib/gems/1.9.2/gems# gem install bundler
Successfully installed bundler-1.0.15
1 gem installed
Installing ri documentation for bundler-1.0.15...
Installing RDoc documentation for bundler-1.0.15...
@mwotton
mwotton / gist:1150758
Created August 17, 2011 03:31
jshack
{-# LANGUAGE TemplateHaskell #-}
module Jshack where
import Language.Haskell.TH
import Data.Maybe
import Control.Applicative((<$>),(<*>))
-- we can allow maybe here fairly naturally, so let's do it.
data Foo = Bar { many::Int, heterogeneous::Maybe String }
-- this is pretty dumb. clearly we can't cope with Baz Float (Maybe Float) (Maybe Int) cleanly without backtracking.
-- | Baz Float (Maybe String)
{
"fireban": false,
"events": [
{
"id": "4e60e43235913b0044eebdfb",
"created_at": "2011-09-02T06:20:00Z",
"updated_at": "2011-09-02T06:20:00Z",
"lat": -32.8763,
"lon": 148.2286,
"title": "NEWELL HIGHWAY Hazard reduction",
<rss xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>NSW Rural Fire Service Current Incidents</title>
<description>Fire Incidents as at Wednesday, 9 December 2009</description>
<link>
http://www.rfs.nsw.gov.au/dsp_content.cfm?cat_id=683
</link>
<language>en-AU</language>
<webMaster>webmaster@rfs.nsw.gov.au (RFS Webmaster)</webMaster>
<docs>
{
"fireban": false,
"events": [
{
"id": "4e684d22043c4900d9548951",
"created_at": "2009-12-09T04:45:00Z",
"updated_at": "2009-12-09T05:45:00Z",
"lat": -33.6676,
"lon": 150.9362,
"title": "Stringer Road",