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; }
};
@neanias
neanias / .vimrc
Last active February 25, 2020 10:52
Super basic (not so much anymore) vimrc, some shamelessly stolen from http://amix.dk/vim/vimrc.html
set nocompatible " be iMproved, required
" Load vim-plug
if empty(glob("~/.vim/autoload/plug.vim"))
execute '!curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.github.com/junegunn/vim-plug/master/plug.vim'
endif
call plug#begin('~/.vim/plugged')
" Dependencies
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 / Gemfile
Last active November 3, 2016 22:27
AT Labs Backend
source 'https://rubygems.org'
gem 'sinatra'
gem 'twilio-ruby'
gem 'thin'
@neanias
neanias / main.py
Last active November 3, 2016 22:26
AT Labs Backend in Python
from flask import Flask, request, Response
from twilio.rest import TwilioRestClient
from twilio import twiml
app = Flask(__name__)
account = 'Insert SID here'
token = 'Auth token'
client = TwilioRestClient(account, token)
@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]);
}