Skip to content

Instantly share code, notes, and snippets.

View vilhalmer's full-sized avatar

Bill Doyle vilhalmer

View GitHub Profile
@vilhalmer
vilhalmer / NSObject+TryMethod.h
Created May 6, 2014 21:59
NSObject+TryMethod
//
// NSObject+TryMethod.h
// SUPER HAX
//
// Created by Bill Doyle on 2014-05-06.
//
#import <Foundation/Foundation.h>
@vilhalmer
vilhalmer / gist:85f08dca272a6ebfad51
Created February 21, 2015 00:14
NSCoder+KeyedSubscripting
// NSCoder+KeyedSubscripting.h:
@interface NSCoder (KeyedSubscripting)
- (id)objectForKeyedSubscript:(id <NSCopying>)key;
- (void)setObject:(id)object forKeyedSubscript:(id <NSCopying>)key;
@end
#import <Cocoa/Cocoa.h>
#define k_NSArrayTupleAssignment @"THISISAMAGICVALUELOL"
#define _(...) [NSArray arrayOfPointerValues:(void *)__VA_ARGS__, NULL][k_NSArrayTupleAssignment]
@interface NSArray (TupleAssignment)
+ (instancetype)arrayOfPointerValues:(void *)pointer1, ...;
#!/usr/bin/env ruby
# watch.rb by Brett Terpstra, 2011 <http://brettterpstra.com>
# with credit to Carlo Zottmann <https://github.com/carlo/haml-sass-file-watcher>
# modified for Chrome by vil, 2015-05-16
trap("SIGINT") { exit }
if ARGV.length < 2
puts "Usage: #{$0} watch_folder keyword"
puts "Example: #{$0} . mywebproject"
typedef BOOL (^ FilterBlock)(id _);
@implementation NSArray (Bifurcate)
- (void)bifurcate:(FilterBlock)test passing:(out NSArray **)passing failing:(out NSArray **)failing
{
NSMutableArray * passed = [NSMutableArray array];
NSMutableArray * failed = [NSMutableArray array];
for (id thing in self) {
@vilhalmer
vilhalmer / gist:3808134
Created September 30, 2012 18:52
A simple JavaScript quine. (Updated to not rely on the presence of window.)
this.quine = function ()
{
console.log("this.quine = " + this.quine.toString() + ";\nquine();");
};
quine();
@vilhalmer
vilhalmer / gist:3808763
Created September 30, 2012 23:49
A less "cheaty" quine in JavaScript.
(function()
{
var q = String.fromCharCode(34);
var quine = [
"(function()",
"{",
" var q = String.fromCharCode(34);",
" var quine = [",
" ",
" ];",
@vilhalmer
vilhalmer / Eva.rb
Last active December 11, 2015 01:09 — forked from nquinlan/Eva.rb
class Eva < Zebra
include MongoMapper::Document
include Vegan::Powers
include MongoMapperExt::Taggable
include MongoMapper::Tweetable
## Keys
key :scarves_count, Integer, :default => 20
key :compliments_count, Integer, :default => 100
key :hivemind_response_count, Integer, :default => 500

Keybase proof

I hereby claim:

  • I am vilhalmer on github.
  • I am vilhalmer (https://keybase.io/vilhalmer) on keybase.
  • I have a public key ASCFa936SL7xvlDDmKQQsOS2b22vRkVQPDwGT2c0N-FrGgo

To claim this, I am signing this object:

@vilhalmer
vilhalmer / nih-grab.py
Created January 27, 2017 01:06
Download a summary file from a search on https://www.ncbi.nlm.nih.gov/pmc/ (using the 'Send to' menu) and feed it to this script to archive everything.
#!/usr/bin/env python
from __future__ import print_function
import os
from sys import argv, exit
import re
from time import sleep
import requests