Skip to content

Instantly share code, notes, and snippets.

View daramcq's full-sized avatar

Dara McHugh daramcq

  • Dublin, Ireland
View GitHub Profile
# Decorating an anonymous function using a block is fairly easy
log_function = lambda do |fn, *args|
puts "About to call"
fn.call(*args)
puts "Did the call"
end
arrow_function = -> (*args) { puts "Being called now with #{args}" }
arrow_function = log_function.curry.(arrow_function)
@daramcq
daramcq / game.py
Last active January 12, 2016 22:05
#! /usr/bin/python
class Game(object):
def __init__(self, dimensions, cell_set):
self.dimensions = dimensions
self.cell_set = cell_set
def adjacent(self, a, b):
return abs(a[0] - b[0]) < 2 and abs(a[1] - b[1]) < 2
import sys
import xapian
import string
from config_file import *
def indexThread(thread_id, content):
try:
# Open the database for update, creating a new database if necessary.
database = xapian.WritableDatabase(db_global, xapian.DB_CREATE_OR_OPEN)
indexer = xapian.TermGenerator()
@daramcq
daramcq / handler.wsgi
Created October 9, 2013 22:17
Search engine using xapian
import sys
import xapian
import string
from config_file import *
def indexThread(thread_id, content):
try:
# Open the database for update, creating a new database if necessary.
database = xapian.WritableDatabase(db_global, xapian.DB_CREATE_OR_OPEN)
indexer = xapian.TermGenerator()
@daramcq
daramcq / pie.html
Created June 4, 2013 10:55
D3 Pie Chart
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Testing Pie Chart</title>
<script type="text/javascript" src="js/d3.v3.min.js"></script>
@daramcq
daramcq / 4chan-script.py
Last active December 15, 2015 11:08
Work in progress script to download threads from 4chan using their API
#!/usr/bin/env python
import requests
import json
import csv
import datetime
import os
from PIL import Image
from StringIO import StringIO
import fcntl
import sys
@daramcq
daramcq / tweet_output_txt.py
Created March 26, 2013 11:29
Output your tweets into a text file
import csv
text_file = open('tweet_output.txt','w')
cr = csv.reader(open("tweets.csv","rb"))
for row in cr:
text_file.write(row[5]+" "+row[7]+"\n")
text_file.close()
@daramcq
daramcq / Recdep.py
Created August 25, 2012 10:59
RecDep information retrieval system
'''
This is a python translation of RecDep.java (gist: 2883635) with minor improvements (nested dictionaries replacing nested Lists)
'''
import nltk
import nltk.data
import pprint
import string
def preprocess(word):
@daramcq
daramcq / LinkCheck.java
Created July 15, 2012 19:53
Program to check for broken links on a webpage
import java.net.*;
import org.htmlparser.beans.LinkBean;
import org.htmlparser.http.HttpHeader;
import java.util.*;
import java.io.*;
public class LinkCheck
{
@daramcq
daramcq / RecDep.java
Created June 6, 2012 18:03
RecDep Information Retrieval - Search documents based on keywords
/***********************************************
* RecDep - Information Retrieval System *
* @author - Dara McHugh *
* dara.mchugh22@student.computing.dcu.ie *
* *
* @version - 1.6 *
* @since - 2012 - 05 - 8 *
Screencast Available at: *
http://student.computing.dcu.ie/~mchugd22/java_ir.ogv
* *