View binary.html
1 2 3 4 5 6 7 8 9 10
<!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;
View entity_weirdness.rb
1 2 3 4 5 6 7 8 9 10
# 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
View champagne.rb
1 2 3 4 5 6 7 8 9 10
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|
View string_permutations.rb
1 2 3 4 5 6 7 8 9 10
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
View humanize.js
1 2 3 4 5 6 7 8 9 10
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
*/
View keychain.rb
1 2 3 4 5
#!/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...
View canvas_test.html
1 2 3 4 5 6 7 8 9 10
<!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>
View database.rb
1 2 3 4 5 6 7 8 9 10
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}
View Move JBidwatcher files around.sh
1 2
mv ~/Library/Preferences/JBidwatcher/jbdb ~/Library/Preferences/JBidwatcher/jbdb.save
mv ~/.jbidwatcher/jbdb ~/Library/Preferences/JBidwatcher/jbdb
View TableDelegate.rb
1 2 3 4 5 6 7 8 9 10
# TableDelegate.rb
#
# An example of capturing double-clicks and a yellow-fade technique in MacRuby.
# The yellow fade technique implementation is a ruby-ized translation
# of http://www.bdunagan.com/2009/04/26/core-animation-on-the-mac/
# Created by Morgan Schweers on February 26, 2011.
 
framework 'Cocoa'
 
class TableDelegate
Something went wrong with that request. Please try again.