Skip to content

Instantly share code, notes, and snippets.

Breaking things

Noel Cower nilium

Breaking things
Block or report user

Report or block nilium

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nilium / QKVOForwarding.h
Created Jan 31, 2014
Weird idea for converting KVO changes to messages specific to the key-path. Not at all an optimal idea.
View QKVOForwarding.h
#ifndef __guard_QKVOForwarding_h__
#define __guard_QKVOForwarding_h__
#import <Foundation/Foundation.h>
@interface NSObject (QKVOForwarding)
+ (NSUInteger)maxCachedSelectorCountForForwarding;
nilium /
Created Feb 1, 2014
Sublime Text plugin that wraps a selection in a comment banner. It is slightly weird and definitely poorly written, but it works.
import sublime, sublime_plugin
from math import ceil
def banner_comment_width(max_content_length, min_width, padding, wall_padding, comment):
width = (
+ (padding * 2)
+ (wall_padding * 2)
+ len(comment[0]) + len(comment[1])
View lex_lips.rb
class Lexer
include Enumerable
def self.const_set(sym, obj) const_set(sym, obj.freeze) end
class Error < ::Exception ; end
# Token =, :value, :position, :line, :column, :__mark)
class Token
View iterator.rb
class BlockIterator
def initialize(args, &block)
@block = block
@args = args
def each
if block_given?
while true ; yield @block[*@args] ; end
# -- signing utility for Android APKs
# Made by Noel Cower. This file is public domain, or at least I'm not
# going to care what you do with it.
#include <memory>
#include <type_traits>
#include <iostream>
class boxed_t
virtual ~boxed_t() = 0;
virtual int type_id() const = 0;
nilium / keypath.rb
Last active Aug 29, 2015
Fun little key path thing for Ruby.
View keypath.rb
# Key path constructor object. Builds up a key path for most instance methods
# called against itself.
class KeyPathCtor
def self.forwarding_method(name, old_name = nil)
old_name ||= name
define_method(name, -> (*args) do
if args.empty?
View pathto
#!/usr/bin/env ruby -w
# Copyright 2014 Noel Cower
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
nilium / go
Last active Aug 29, 2015
Utility to scan ascendant directories for .go-root files, add those directories to the GOPATH, then forward arguments to the next go command in the PATH.
View go
# Puts any directory with a .go-root file into the GOPATH then launches go.
__gopath_for_dir__() {
if [[ -f "$test_goroot" ]] ; then
echo "${2:+$2:}$1"
echo "$2"
View max.scala
def max(list: List[Int]): Int = list match {
case Nil => throw new NoSuchElementException
case List(x) => x
case x +: tail =>
val rhs = max(tail)
if (x >= rhs) x else rhs
You can’t perform that action at this time.