Skip to content

Instantly share code, notes, and snippets.

View neanias's full-sized avatar

William Mathewson neanias

View GitHub Profile
@neanias
neanias / object.rb
Last active August 29, 2015 14:00
Object extension
class Object
def symbolize(target = nil)
target = self.clone if target == nil
if target.class == Hash
clone = target.clone
clone.each_pair do |key, value|
target[key] = value.symbolize! if [Array, Hash].include? value.class
@neanias
neanias / basic_testing.py
Created June 9, 2014 16:39
A small script to test autocorrect using the PyEnchant library
# -*- encoding: utf-8 -*-
from sys import argv
from enchant import request_dict
if len(argv) <= 1:
print "USAGE: python basic_testing.py <sentence>"
exit()
else:
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
Rectangle(int x, int y) : width(x), height(y) {}
int area(void) { return width * height; }
};
rotate :: Int -> [Char] -> [Char]
rotate k list | k >= 0, k <= length list = drop k list ++ take k list
| otherwise = []
makeKey :: Int -> [(Char,Char)]
makeKey n = zip xs ys
where
xs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -- You can use ['A'..'Z']
ys = rotate n xs
@neanias
neanias / virtualenv output
Last active August 29, 2015 14:11
virtualenv -p $(which python3) venv
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4'
New python executable in venv/bin/python3.4
Also creating executable in venv/bin/python
Failed to import the site module
Traceback (most recent call last):
File "/Users/williammathewson/Programming/Python/possel/venv/bin/../lib/python3.4/site.py", line 67, in <module>
import os
File "/Users/williammathewson/Programming/Python/possel/venv/bin/../lib/python3.4/os.py", line 616, in <module>
from _collections_abc import MutableMapping
~ ⌚ 19:34:44
$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr da:1f:52:45:d4:81
inet addr:185.17.149.144 Bcast:185.17.149.191 Mask:255.255.255.192
inet6 addr: 2001:1b40:3601:8:d81f:52ff:fe45:d481/64 Scope:Global
inet6 addr: 2001:1b40:3601:8:512c:8ac1:80b3:a738/64 Scope:Global
inet6 addr: fe80::d81f:52ff:fe45:d481/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:109702 errors:0 dropped:0 overruns:0 frame:0
TX packets:75583 errors:0 dropped:0 overruns:0 carrier:0
public class Mode {
public static void main(String[] args) {
int[] dataset = new int[args.length];
int[] count = new int[10];
int mode;
for (int i = 0; i < args.length; i++) {
dataset[i] = Integer.parseInt(args[i]);
}
@neanias
neanias / restaurants-queries.txt
Created March 4, 2015 11:25
Answers to XPath queries
/ > cat //address
-------
<address>27 Marshall Street, Edinburgh, EH8 9BJ</address>
-------
<address>26 Potterow, Edinburgh, EH8 9BT</address>
-------
<address>7 Nicolson Square, Edinburgh, EH8 9BH</address>
-------
<address>55 West Nicolson Street, Edinburgh, EH8 9DB</address>
-------
781 old man [#68388-#69168]
621 young lady [#112350-#112970]
575 old gentleman [#67050-#67624]
473 young man [#113014-#113486]
422 young gentleman [#111512-#111933]
396 old lady [#67925-#68320]
309 old woman [#70055-#70363]
283 long time [#54675-#54957]
253 last night [#46894-#47146]
241 great deal [#35038-#35278]
@neanias
neanias / gist:057348c63f6ea5c4b0b2
Created March 17, 2015 13:32
President Application blurb
I am a first year Computer Science student. I believe I am suitable as I am an active member of CompSoc, a regular face at TARDIS pub
meetings as well as being on the CompSoc IRC. I have thoroughly enjoyed being a member of CompSoc this year and so I would love to be
able to take on this fantastic society to even greater heights. My aims would be to try and keep alive the CompSoc culture that we
all know and love whilst also trying to expand the society and keep it being something that everyone can take part in.
I would like to have closer ties with Hoppers and Prewired, with perhaps making them SIGs within CompSoc if they are interested. In
relation to this, I would like to also try and establish connection to similar societies such as GameDevSoc and MathSoc, as well as
computing societies at other universities.
Having talked to some members of the society, I believe we should have more non-alcohol dependent socials; some ideas for this include