Skip to content

Instantly share code, notes, and snippets.

@smcl
smcl / gist:914591
Created April 11, 2011 23:20
I hate myself
--Project Euler problem 38
-- What is the largest 1 to 9 pandigital 9-digit number that can be formed as
-- the concatenated product of an integer with (1,2, ... , n) where n > 1?
import Data.List
pandigital9 = map (\x -> read x :: Integer) $ permutations "123456789"
main = print $ last $ sort $ takeWhile (<987654321) $ concat $ map (\y -> filter (`elem` pandigital9) $ takeWhile (<987654321) $ map (\x -> read (concat $ map (show) $ map (y*) [1..x]) :: Integer) [1..]) [1..]
P0 = 0x20000000; // P0 aligned on 32 bit boundary
R0.H = [P0++]; // P0 is 16 bit aligned, a 32 bit load would ...
R1 = [P0]; // awwwwww maaan!
@smcl
smcl / gist:923752
Created April 17, 2011 04:08
Not actually Javascript, but there's no "processing" option in the Language dropdown for a gist
void dump_image() {
beginShape(POINTS);
int i;
for(i=0; i<cols.length; i++) {
stroke(cols[i]);
vertex(xs[i], ys[i], zs[i]);
if(numPoints != 0 && i%numPoints ==0) {
endShape();
beginShape(POINTS);
@smcl
smcl / gist:1030252
Created June 16, 2011 20:55
Reading a video frame-by-frame with OpenCV in Processing (not javascript)
import hypermedia.video.*;
OpenCV opencv;
PImage frame;
void setup() {
size( 640, 360 );
frameRate(30);
opencv = new OpenCV( this );
opencv.movie( "mymovie.mov", width, height );
@smcl
smcl / gist:1034413
Created June 19, 2011 15:28
Markov Chain tweeter for @briancox
#!/usr/bin/python
import random
import oauth2 as oauth
import sys
import twitter
class Markov(object):
def __init__(self):
@smcl
smcl / Python.h
Created August 13, 2011 14:03
Where I'm adding my malicious preprocessor macro in Python
#ifndef Py_PYTHON_H
#define Py_PYTHON_H
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
/* Include nearly all Python header files */
/* Sean's changes go here */
#include "patchlevel.h"
/* etc ... */
@smcl
smcl / grep.h
Created August 13, 2011 14:40
Where I'm adding my malicious preprocessor macro in grep
/* Removed the GPL notice. Hopefully RMS won't come after me... */
#ifndef GREP_GREP_H
#define GREP_GREP_H 1
/* Sean's changes go here */
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__
# define __attribute__(x)
#endif
@smcl
smcl / darwin.h
Created August 13, 2011 15:28
Where I'm adding my malicious preprocessor macro in Emacs
/* Deleted GPL header - again hopefully RMS won't attack me with a Katana */
/*
* Define symbols to identify the version of Unix this is.
* Define all the symbols that apply correctly.
*/
#define BSD4_2
/* BSD4_3 and BSD4_4 are already defined in sys/param.h */
#define BSD_SYSTEM
@smcl
smcl / fix_xft.patch
Created September 30, 2012 09:59
stop build error in blackbox
--- configure 2012-09-30 11:28:14.000000000 +0200
+++ configure 2012-09-30 11:21:55.000000000 +0200
@@ -16031,14 +16031,16 @@
$as_echo "$XFT" >&6; }
if test "x$XFT" = "xyes"; then
- PKG_CHECK_MODULES(xft,
- xft >= 2.0.0,
- XFT="-DXFT"
- XFT_PKGCONFIG="xft >= 2.0.0"
- CXXFLAGS="$CXXFLAGS $xft_CFLAGS"
@smcl
smcl / bb_prereqs.sh
Created September 30, 2012 10:49
install blackbox prerequisites
install_tar_gz ()
{
curl -LO $1/$2.tar.gz
tar -xzf $2.tar.gz
cd $2
./configure
make
sudo make install
cd ..
}