Skip to content

Instantly share code, notes, and snippets.

View jameshibbard's full-sized avatar

James Hibbard jameshibbard

View GitHub Profile
@jameshibbard
jameshibbard / choose_charset_1.rb
Created September 2, 2012 19:05
Choose Charset 1
def chooseCharset(includeSpecialCharacters)
if includeSpecialCharacters
@charSets.first
else
@charSets.last
end
end
@jameshibbard
jameshibbard / choose_charset_2.rb
Created September 2, 2012 19:06
Choose Charset 2
charSets = [ALL_POSSIBLE_CHARS, NUMBERS + ALPHABET_LOWER + ALPHABET_UPPER]
PasswordGenerator.new(app, charSets)
@jameshibbard
jameshibbard / copy_button_connect_1.rb
Created September 2, 2012 19:07
Copy Button Connect 1
copyButton.connect(SEL_COMMAND) do
acquireClipboard([FXWindow.stringType])
end
@jameshibbard
jameshibbard / copy_button_connect_2.rb
Created September 2, 2012 19:08
Copy Button Connect 2
self.connect(SEL_CLIPBOARD_REQUEST) do
setDNDData(FROM_CLIPBOARD, FXWindow.stringType, Fox.fxencodeStringData(textArea.text))
end
@jameshibbard
jameshibbard / packer_1.rb
Created September 2, 2012 19:08
Packer 1
packer = FXPacker.new(self, :opts => LAYOUT_FILL)
groupBox = FXGroupBox.new(packer, nil, :opts => FRAME_RIDGE | LAYOUT_FILL_X)
@jameshibbard
jameshibbard / packer_2.rb
Created September 2, 2012 19:09
Packer 2
hFrame3 = FXHorizontalFrame.new(vFrame1, :opts => PACK_UNIFORM_WIDTH)
@jameshibbard
jameshibbard / password_generator_4.rb
Created September 2, 2012 19:12
Password Generator 4
require 'fox16'
include Fox
NUMBERS = (1..9).to_a
ALPHABET_LOWER = ("a".."z").to_a
ALPHABET_UPPER = ("A".."Z").to_a
ALL_POSSIBLE_CHARS = (33..126).map{|a| a.chr}
class PasswordGenerator < FXMainWindow
def initialize(app, charSets)
@jameshibbard
jameshibbard / gist:3697077
Created September 11, 2012 09:03
Check if HTML5 canvas element is supported
function isCanvasSupported(){
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
}
$(document).ready(function() {
if(isCanvasSupported()){
alert("Yay!");
}
});
@jameshibbard
jameshibbard / gist:3697359
Created September 11, 2012 10:03
Function to draw a rectangle on a canvas element
function clearCanvas(context, canvas) {
context.clearRect(0, 0, canvas.width, canvas.height);
var w = canvas.width;
canvas.width = 1;
canvas.width = w;
}
function highlightRoom(x, y, h, w){
var can = document.getElementsByTagName('canvas')[0];
var ctx = can.getContext('2d');
@jameshibbard
jameshibbard / gist:3697426
Created September 11, 2012 10:21
Canvas Lightbox Overlay - Example 2
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Lightbox 2 with &lt;canvas&gt; overlay - Example 1</title>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<style>
.plan{
display:none;
background-image: url(images/plan.jpg);