This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import OSLog | |
// Measure how long stuff takes. | |
public enum Benchy { | |
public static func measure<T>(_ label: String, logger: Logger = Logger(subsystem: "Benchy", category: "measure"), block: () throws -> T) rethrows -> T? { | |
let clock = ContinuousClock() | |
var value: T? | |
let result = try clock.measure { value = try block() } | |
logger.trace("\(label) took \(result)") | |
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import PlaygroundSupport | |
struct ContentView: View { | |
@State private var mode: BlendMode = .normal | |
let cases: [BlendMode] = [ | |
.normal, | |
.multiply, | |
.screen, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[~/.js] cat github.com.js | |
// Hashtagify emoji | |
$(function() { | |
$('img.emoji').each(function() { | |
var name = $(this).attr("title").replace(/:/g, '') | |
if (name == '+1') { name = "thumbsup" } | |
if (name == '-1') { name = "thumbsdown" } | |
hashtag = $("<span>#" + name + "</span>"); | |
hashtag.css({ color: '#000', fontWeight: 'bold' }); | |
$(this).replaceWith(hashtag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE | |
# | |
# Make sure your launchpad is plugged in. | |
# | |
# $ ruby launchpad-art.rb | |
# | |
# Select your launchpad from the list of midi controllers, then start pushing | |
# buttons on your launchpad. | |
require "unimidi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Speaker Clicker | |
int maxIndicatorPin = 1; | |
int okayIndicatorPin = 2; | |
int speakerPin = 13; | |
int pitchPin = 0; | |
int pitch = 750; | |
void setup() { | |
pinMode(speakerPin, OUTPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sʇnd | |
:PUTS | |
end | |
BINDING = binding | |
class << self | |
define_method :method_missing do |sym, *args| | |
value = eval(sym.to_s, BINDING) | |
puts value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
flips = [ | |
'(╯°□°)╯︵ ┻━┻', | |
'(ノಥ益ಥ)ノ ┻━┻', | |
'┬──┬ ¯\_(ツ)', | |
'┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻', | |
'┻━┻ ︵ ¯\(ツ)/¯ ︵ ┻━┻', | |
'┬─┬ノ( º _ ºノ)', | |
'(ノಠ益ಠ)ノ彡┻━┻' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coffee> if true then "OK" else "UH OH" | |
'OK' | |
coffee> if false then "OK" else "UH OH" | |
'UH OH' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "acts_as_fu" | |
require "test/unit" | |
include ActsAsFu | |
class ActiveRecord::Base | |
def self.after_set(attribute, callback) | |
after_save callback, :if => "#{attribute}_set?" | |
class_eval <<-END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "saves cleanly from builder" do | |
create_${TM_FILENAME/(\w+)_spec\.rb/$1/}.should_not be_a_new_record | |
end |
NewerOlder