Skip to content

Instantly share code, notes, and snippets.

View mndrix's full-sized avatar

Michael Hendricks mndrix

View GitHub Profile
@mndrix
mndrix / gist:1339574
Created November 4, 2011 15:23
brew install swi-prolog
==> Downloading http://www.swi-prolog.org/download/stable/src/pl-5.10.4.tar.gz
File already downloaded in /Users/michael/Library/Caches/Homebrew
/usr/bin/tar xf /Users/michael/Library/Caches/Homebrew/swi-prolog-5.10.4.tar.gz
==> ./configure --prefix=/usr/local/Cellar/swi-prolog/5.10.4 --mandir=/usr/local/Cellar/swi-prolog/5.10.4/share/man --with-world
./configure --prefix=/usr/local/Cellar/swi-prolog/5.10.4 --mandir=/usr/local/Cellar/swi-prolog/5.10.4/share/man --with-world
checking builddir... src
checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
-- executes IO actions trying to maintain the rate of 'pace' seconds
-- per action
pacedSequence :: Double -> [IO ()] -> IO ()
pacedSequence paceSeconds ios = do
now <- getCurrentTime
pacedSequence' pace ios now 0
where
pace = fromRational $ toRational paceSeconds
pacedSequence' :: NominalDiffTime -> [IO ()] -> UTCTime -> Int -> IO ()
@mndrix
mndrix / gist:1400759
Created November 28, 2011 15:23
brew install --use-gcc swi-prolog
==> Downloading http://www.swi-prolog.org/download/stable/src/pl-5.10.5.tar.gz
File already downloaded in /Users/michael/Library/Caches/Homebrew
/usr/bin/tar xf /Users/michael/Library/Caches/Homebrew/swi-prolog-5.10.5.tar.gz
==> ./configure --prefix=/usr/local/Cellar/swi-prolog/5.10.5 --mandir=/usr/local/Cellar/swi-prolog/5.10.5/share/man --with-world
./configure --prefix=/usr/local/Cellar/swi-prolog/5.10.5 --mandir=/usr/local/Cellar/swi-prolog/5.10.5/share/man --with-world
checking builddir... src
checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
@mndrix
mndrix / gist:1960246
Created March 2, 2012 18:33
GetDebugLogName
string GetDebugLogName()
{
char pszFile[MAX_PATH+100];
GetDataDir(pszFile);
strlcat(pszFile, "/debug.log", sizeof(pszFile));
return pszFile;
}
@mndrix
mndrix / darcs-rebase.pl
Created March 8, 2012 00:23
darcs rebase
#!/usr/bin/perl
use strict;
use warnings;
use feature qw( say switch );
use autodie qw( system open unlink );
use Digest::SHA1 qw( sha1_hex );
use File::Copy;
use Perl6::Slurp;
sub darcs;
function add_to(start, others) {
for(var i=0; i<others.length; i++) {
start += others[i]
}
return start;
}
map _ [] = []
map f (x:xs) = f x : map f xs
append([], Ys, Ys).
append([X|Xs], Ys, [X|Zs]) :- append(Xs, Ys, Zs).
function real_roots(a, b, c) {
var A2 = a*2;
var D = b*b - A2*c*2;
if (D<0) return [];
if (D==0) return [-b/A2];
var xs = plus_minus( -b, Math.sqrt(D) );
return [ (xs[0])/A2, (xs[1])/A2 ];
}
function plus_minus(x,y) {
real_roots(A,B,C) = Roots :-
( D<0 -> Roots=[]
; D=0 -> Roots=[-B/A2]
; plus_minus(-B,sqrt(D), X0, X1),
Roots=[X0/A2,X1/A2]
),
D = B*B - A2*C*2,
A2 = A*2.
plus_minus(X,Y) = [X+Y,X-Y].