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
=begin | |
Easy Basic Authentication for Sinatra actions. | |
USAGE | |
require 'rubygems' | |
require 'sinatra' | |
require 'sinatra-auth' | |
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
module Operations | |
def self.list | |
@list ||= [] | |
end | |
class Base | |
def self.inherited(klass) | |
Operations.list << klass | |
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
String.prototype.interpolate = function(object) { | |
return this.replace(/#{([\w0-9]+)}/g, function(val, match) { | |
return object[match]; | |
}) | |
} | |
String.prototype.evilInterpolate = function() { | |
return this.replace(/#{([\w0-9]+)}/g, function(val, match) { | |
return eval(match); | |
}); |
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
Here's an example of a few different ways to call a method on a Ruby object. | |
If you're a beginner, try running the code above to watch it in action. | |
If you're not a beginner, go ahead and tear me a new one for whichever techniques I forgot ;) | |
- Pat |
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 | |
require 'readline' | |
loop do | |
command = Readline.readline('> ') | |
command == "exit" && exit | |
puts "heroku #{command} --remote production" | |
system("heroku #{command} --remote production") | |
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
[~/.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 |
NewerOlder