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 'sqlite3' | |
require 'sequel' | |
# Adding this monkey-patch makes it work on MacRuby. | |
module Sequel | |
class Dataset | |
def single_record | |
record = nil | |
clone(:limit=>1).each{|r| record = r; return r} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Testing HTML5 Canvas element</title> | |
<script src="jquery.min.js" type="text/javascript"></script> | |
</head> | |
<body> | |
This is a test of the HTML5 Canvas element. | |
<canvas id="drawing_canvas" width="800" height="600" style="position: absolute; top: 0; left: 0;"> | |
</canvas> |
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 | |
# | |
# Usage: | |
# security dump-keychain -d login.keychain > keychain_logins.txt | |
# # Lots of clicking 'Always Allow', or just 'Allow', until it's done... |
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
com = { cyberfox: {} }; | |
/** | |
* Convert a property name into a human readable string by replacing _ with | |
* spaces, and upcasing the first letter of each word. | |
* | |
* @param {string} property The property name to convert into a readable name. | |
* @return {string} The property name converted to a friendly readable format. | |
* @private | |
*/ |
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 'set' | |
# First I wanted to get an idea of the timing of the various approaches | |
def time | |
start = Time.now | |
yield | |
puts Time.now.to_f - start.to_f | |
end | |
# This optimizes for redundant strings of values, front-loading them to maximize duplicates |
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
if ARGV[0].nil? | |
puts "Usage:\n\truby #{__FILE__} {bad bottle#|test}" | |
exit | |
end | |
def guess_bottle(bad_bottle, silent=false) | |
waiters = [] | |
(0..9).each do |waiter_number| | |
waiters[waiter_number] = [] | |
(0..999).each do |bottle| |
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
# This shows the list of entities, and that they look like String objects to RubyMotion. | |
(main)> mapping = App.delegate.managedObjectContext.persistentStoreCoordinator.managedObjectModel.entitiesByName.keys.each_with_object({}) { |key, map| map[key.to_s] = key} | |
=> {"Auction"=>"Auction", "Category"=>"Category", "Entry"=>"Entry", "Host"=>"Host"} | |
# This is an example lookup for the Category entity, by name. It fails. | |
(main)> App.delegate.managedObjectContext.persistentStoreCoordinator.managedObjectModel.entitiesByName['Category'] | |
=> nil | |
# Here we try to insert a new object for an entity by name, using 'Category' as a raw string. It fails, unable to locate it. | |
(main)> begin |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Binary Entry JavaScript</title> | |
<style type="text/css"> | |
.box { | |
border: 1px solid black; | |
height: 32px; | |
width: 32px; | |
font-size: 24px; |
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 'sinatra' | |
require 'omniauth-twitter' | |
require 'omniauth-salesforce' | |
configure do | |
enable :sessions | |
end | |
helpers do | |
def h(text) |
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 'test_helper' | |
# ActiveRecord::Schema.define(version: 20170310085807) do | |
# create_table "forums", force: :cascade do |t| | |
# t.string "title" | |
# t.integer "posts_count" | |
# t.datetime "created_at", null: false | |
# t.datetime "updated_at", null: false | |
# end | |
# |