Skip to content

Instantly share code, notes, and snippets.

@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
@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:3052f7e9e7f34b92a40f
Created November 1, 2014 01:28
NSVisualEffectView undocumentation
NSVisualEffectMaterial constants, and the undocumented materials they coorespond to in various modes:
+----------------------+-------+----------+------+---------+
| MATERIAL # | LIGHT | LIGHT EM | DARK | DARK EM |
+----------------------+-------+----------+------+---------+
| | | | | |
| 0 - Appearance Based | 3 | 3 | 5 | 5 |
| | | | | |
| 1 - Light | 3 | 3 | 3 | 3 |
| | | | | |
| 2 - Dark | 4 | 4 | 4 | 4 |
@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) {

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: