Skip to content

Instantly share code, notes, and snippets.

rule '.o' => '.cpp' do |task|
puts "Building #{task.name}"
sh "g++ #{task.source} -c -o obj/#{task.name}"
end
def create_lib(task)
sh "ar rcs lib/#{task.name}.a #{task.prerequisites.join(' ')}"
end
desc "Builds only the memoryman static library"
@iand675
iand675 / bitcounter.hs
Created October 9, 2011 22:24
1 Bit counter for 32-bit integer lists
{-# LANGUAGE OverloadedStrings #-}
import System.IO
import Control.Monad
import Data.Bits
import Data.Int
import Data.List
import Data.Maybe
import Data.Serialize
import Data.Array.Unboxed
import qualified Data.ByteString.Lazy.Char8 as B
@iand675
iand675 / gist:2355188
Created April 10, 2012 22:40
Glitchy system calls via interrupt
align 16
exception_gate_06:
; treat invalid opcodes as system call.
; doesn't currently distinguish between invalid opcodes, which is not so good.
push rax
mov rax, [num_calls] ; increase count of number of system calls
inc rax
mov [num_calls], rax
mov rax, [rsp + 8] ; get ip
mov al, [rax + 1] ; get next byte
@iand675
iand675 / gist:3057260
Created July 6, 2012 00:13
Type-safe active-record fiddling
{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleInstances, EmptyDataDecls, TypeOperators #-}
import Control.Monad.Base
import Data.Tagged
{-
data Post = Post { user :: User
, title :: Text
, body :: Text
, comments :: [Comment]
@iand675
iand675 / pictures.markdown
Created August 29, 2012 18:00 — forked from sent-hil/pictures.markdown
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@iand675
iand675 / circle.yml
Created March 24, 2014 06:45
Haskell library Circle CI integration with GHC 7.8 RC2
machine:
environment:
PATH: $HOME/.cabal/bin:$HOME/installs/bin:$PATH
cache_directories:
- "~/installs"
dependencies:
cache_directories:
- "~/installs"
override:
- sh ~/$CIRCLE_PROJECT_REPONAME/install_deps.sh
-- | A measure of time statistics for the duration of an event
data Timer m = Timer
{ fromTimer :: !(MutVar (PrimState m) P.Timer)
, _timerGetTime :: !(m NominalDiffTime)
}
makeFields ''Timer
@iand675
iand675 / default.nix
Created January 14, 2015 03:50
NixOS AC_PROG_LIBTOOL undefined
{ stdenv ? (import <nixpkgs> {}).stdenv,
fetchurl ? (import <nixpkgs> {}).fetchurl,
lib ? (import <nixpkgs> {}).lib,
which ? (import <nixpkgs> {}).which,
makeself ? (import <nixpkgs> {}).makeself,
perl ? (import <nixpkgs> {}).perl,
pkgconfig ? (import <nixpkgs> {}).pkgconfig,
kernel ? (import <nixpkgs> {}).linuxPackages_3_18.kernel,
lvm2 ? (import <nixpkgs> {}).lvm2,
dev86 ? (import <nixpkgs> {}).dev86,
foreign import javascript safe "undefined()" alwaysFails :: IO Int
-- Should always return `Left ..`
makeItFail :: IO (Either JSException Int)
makeItFail = try alwaysFails