Skip to content

Instantly share code, notes, and snippets.

require 'sinatra'
require 'haml'
require 'hpricot'
require 'open-uri'
require 'RMagick'
get '/' do
haml :index
end
require 'isaac'
require 'nokogiri'
require 'open-uri'
page = Nokogiri(open("http://listverse.com/2007/10/08/40-quotes-of-oscar-wilde/"))
quotes = page.css(".post-content p").find_all do |line|
('1'..'9').include? line.text[0]
end
quotes.map! do |quote|
@dafrancis
dafrancis / index.html
Created August 21, 2011 15:31
Making a Sierpinski Triangle with JavaScript and Canvas
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sierpinski Triangle</title>
<script src="sierpinski.js"></script>
</head>
<body>
<h1>Sierpinski Triangle</h1>
<canvas width="500" height="500"></canvas>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void wheel(char name[])
{
char *track = malloc(strlen(name));
int i, ii;
for (i = 0, ii = strlen(name) + 1; i < ii; i++) {
printf("%s:wheel:%s\n", track, name);
@dafrancis
dafrancis / color.h
Created November 14, 2011 21:29
"Zed's Awesome Debug Macros" from Exercise 20 of "Learn C the Hard Way" (http://c.learncodethehardway.org/). Now with added colours! (Yes I know I use "color" in the code)
#ifndef __color_h__
#define __color_h__
/*
* I got some of the colour codes (as well as having the idea of putting them in a macro) from here:
* http://stackoverflow.com/questions/3506504/c-code-changes-terminal-text-color-how-to-restore-defaults-linux
*/
#define RED "\e[31m"
#define GREEN "\e[32m"
@dafrancis
dafrancis / .htaccess
Created January 23, 2012 23:57
FOSDEM Schedule Viewer. Parses the XML from the FOSDEM site to give a simple HTML interface (.htaccess is optional. This works without it as well!)
Options +FollowSymlinks
RewriteEngine on
RewriteBase /fosdem/
RewriteRule ^(.*) index.php?rewrit
var Matrix = function (rows, cols, bombs, rupoors) {
var i, j;
this.grid = [];
this.rows = rows;
this.cols = cols;
this.bombs = bombs;
this.rupoors = rupoors;
this.leftToDig = (rows * cols) - (bombs + rupoors);
// fill Matrix with empty holes...
@dafrancis
dafrancis / blog.css
Created April 14, 2012 14:05
Real Time Blog with Meteor
body {
background: #CCC;
}
h1 {
margin: 0;
}
#main {
min-width: 340px;
<snippet>
<content><![CDATA[
"""
:MI 8M:
DMMM. MMMM.
.MMM. .MMM
MM, IMM
8MM MMM
use strict;
use vars qw($VERSION %IRSSI);
use URI::Escape;
use Irssi qw(command_bind signal_add);
sub same {
my ($server, $msg, $nick, $address, $channel) = @_;
if($msg =~ /^same$/) {
$server->command("msg $channel same") if ($channel);