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
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
nilium / banner_comment.py
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.
View banner_comment.py
import sublime, sublime_plugin
from math import ceil
def banner_comment_width(max_content_length, min_width, padding, wall_padding, comment):
width = (
max_content_length
+ (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 = Struct.new(:kind, :value, :position, :line, :column, :__mark)
class Token
View iterator.rb
class BlockIterator
def initialize(args, &block)
@block = block
@args = args
end
def each
if block_given?
begin
while true ; yield @block[*@args] ; end
View sign.sh
#!/bin/sh
#
# sign.sh -- 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.
#
RED=''
GREEN=''
YELLOW=''
View box.cc
#include <memory>
#include <type_traits>
#include <iostream>
class boxed_t
{
public:
virtual ~boxed_t() = 0;
virtual int type_id() const = 0;
};
@nilium
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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@nilium
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
#!/bin/sh
# Puts any directory with a .go-root file into the GOPATH then launches go.
__gopath_for_dir__() {
test_goroot="$1/.go-root"
if [[ -f "$test_goroot" ]] ; then
echo "${2:+$2:}$1"
else
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.