Skip to content

Instantly share code, notes, and snippets.

View nomeyer's full-sized avatar

Nick Omeyer nomeyer

View GitHub Profile
@nomeyer
nomeyer / create_app_from_pid.m
Last active September 4, 2021 18:05
Create an app reference from a PID (accessibility)
#include <CoreFoundation/CoreFoundation.h>
AXUIElementRef app = AXUIElementCreateApplication(pid);
@nomeyer
nomeyer / code.ts
Created September 11, 2019 17:54
Anonymised Abstract Syntax Tree example
const lines = [
'I am a string',
'I am not a string',
'Lies',
'You got me',
];
function printLines(callback: () => void) {
lines.forEach((line, i) => console.log(`Line ${i}: ${line}`));
callback();
@nomeyer
nomeyer / dict_object_attributes.py
Created May 30, 2016 12:25
Method to be able to call dict() on Python objects and get a dictionary of attribute values
def __iter__(self):
for attr, value in self.__dict__.iteritems():
yield (attr, value)
@nomeyer
nomeyer / tree.md
Created May 19, 2016 16:14 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

from xml.dom.minidom import parse, parseString
import urllib2
# note - i convert it back into xml to pretty print it
print parse(urllib2.urlopen("http://search.twitter.com/search.atom?&q=python")).toprettyxml(encoding="utf-8")
@nomeyer
nomeyer / torch_ubuntu_install.md
Last active April 2, 2016 18:26
Guide to setting up Torch on an AWS GPU instance (copied from https://github.com/brotchie/torch-ubuntu-gpu-ec2-install)

Installing Torch on Ubuntu 14.04 Amazon EC2 GPU Instances

This is a guide for installing the Torch machine learning ecosystem onto a GPU EC2 instance running Ubuntu 14.04.

Note: I have created and made available a Community EC2 AMI following these step with the name torch-ubuntu-14.04-cuda-7.0-28 and ami-id ami-c79b7eac. Simply search for ami-c79b7eac in Community AMIs when creating an instance to get up and running quickly.

Preliminary steps:

  • Start a g2.2xlarge or g2.8xlarge instance with the Ubuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-d05e75b8 base AMI;
  • On Step 4: Add Storage of the instance configuration, increase storage on the primary volume from 8GB to 16GB; the 8GB default is too small;
  • Ensure the SSH port is allowed in the security group;
@nomeyer
nomeyer / log_nsstring_c.m
Last active March 26, 2016 17:24
Logging an NSString in c
fprintf(stdout, "%s\n", [str UTF8String]);
fflush(stdout);