Skip to content

Instantly share code, notes, and snippets.

View nakajima's full-sized avatar
💭
you can have statuses now?

Pat Nakajima nakajima

💭
you can have statuses now?
View GitHub Profile
@nakajima
nakajima / blend mode playground.swift
Created July 29, 2023 08:11
blendmode playground
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
@State private var mode: BlendMode = .normal
let cases: [BlendMode] = [
.normal,
.multiply,
.screen,
[~/.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)
@nakajima
nakajima / launchpad-art.rb
Last active December 16, 2015 00:59
Draw crap on your Novation Launchpad. You'll need the unimidi gem. You know where to get it.
# 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"
// Speaker Clicker
int maxIndicatorPin = 1;
int okayIndicatorPin = 2;
int speakerPin = 13;
int pitchPin = 0;
int pitch = 750;
void setup() {
pinMode(speakerPin, OUTPUT);
@nakajima
nakajima / uʍop ǝpısdn.rb
Created February 10, 2012 00:05
this is why we pair
def sʇnd
:PUTS
end
BINDING = binding
class << self
define_method :method_missing do |sym, *args|
value = eval(sym.to_s, BINDING)
puts value
@nakajima
nakajima / fliptable.rb
Created January 24, 2012 00:40
¯\_(ツ)_/¯
#!/usr/bin/env ruby
flips = [
'(╯°□°)╯︵ ┻━┻',
'(ノಥ益ಥ)ノ ┻━┻',
'┬──┬ ¯\_(ツ)',
'┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻',
'┻━┻ ︵ ¯\(ツ)/¯ ︵ ┻━┻',
'┬─┬ノ( º _ ºノ)',
'(ノಠ益ಠ)ノ彡┻━┻'
coffee> if true then "OK" else "UH OH"
'OK'
coffee> if false then "OK" else "UH OH"
'UH OH'
@nakajima
nakajima / after_set.rb
Created September 29, 2011 20:06
activerecord after_set callback
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
it "saves cleanly from builder" do
create_${TM_FILENAME/(\w+)_spec\.rb/$1/}.should_not be_a_new_record
end
wget http://chromium.googlecode.com/files/chromedriver_mac_14.0.836.0.zip
unzip chromedriver_mac_14.0.836.0.zip
mv chromedriver /usr/local/bin/
rm -f chromedriver_mac_14.0.836.0.zip