Skip to content

Instantly share code, notes, and snippets.

View jameshibbard's full-sized avatar

James Hibbard jameshibbard

View GitHub Profile
@jameshibbard
jameshibbard / validation_example_2.php
Created July 25, 2012 20:00
Simple HTML form with slightly more complicated PHP validation
<?php
if ($_POST['process'] == 1) {
$first_name = htmlentities($_POST['first_name']);
$last_name = htmlentities($_POST['last_name']);
if (empty($last_name)){
echo "<p class=\"error\">Your last name cannot be blank</p>";
} else {
echo "<p>Hello there, ".$first_name." ".$last_name."</p>";
}
}
@jameshibbard
jameshibbard / gist:3312803
Created August 10, 2012 09:14
CSS code to make the WordPress VideoJS plugin responsive
.videoWrapper {
position: relative;
padding-bottom: 55%; /* video dimensions - height/width */
padding-top: 0px;
height: 0;
z-index: 1000;
}
video {
position: absolute !important;
@jameshibbard
jameshibbard / hello_world.rb
Created September 2, 2012 18:52
Hello, World!
require 'fox16'
include Fox
app = FXApp.new
main = FXMainWindow.new(app, "Hello, World!" , :width => 200, :height => 50)
app.create
main.show(PLACEMENT_SCREEN)
app.run
@jameshibbard
jameshibbard / refactored_hello_world.rb
Created September 2, 2012 18:54
Refactored "Hello, World!"
require 'fox16'
include Fox
class HelloWorld < FXMainWindow
def initialize(app)
super(app, "Hello, World!" , :width => 200, :height => 50)
end
def create
super
show(PLACEMENT_SCREEN)
@jameshibbard
jameshibbard / hello_world_start-up_block.rb
Created September 2, 2012 18:55
Hello, World! - Start-up block
if __FILE__ == $0
FXApp.new do |app|
HelloWorld.new(app)
app.create
app.run
end
end
@jameshibbard
jameshibbard / password_generator_1.rb
Created September 2, 2012 18:57
Password Generator 1
require 'fox16'
include Fox
class PasswordGenerator < FXMainWindow
def initialize(app)
super(app, "Password generator", :width => 400, :height => 200)
hFrame1 = FXHorizontalFrame.new(self)
chrLabel = FXLabel.new(hFrame1, "Number of characters in password:")
chrTextField = FXTextField.new(hFrame1, 4)
hFrame2 = FXHorizontalFrame.new(self)
@jameshibbard
jameshibbard / password_generator_2.rb
Created September 2, 2012 18:58
Password Generator 2
def generatePassword(pwLength, charArray)
len = charArray.length
(1..pwLength).map do
charArray[rand(len)]
end.join
end
numbers = (1..9).to_a
alphabetLowerCase = ("a".."z").to_a
alphabetUpperCase = ("A".."Z").to_a
@jameshibbard
jameshibbard / fxbutton_connect.rb
Created September 2, 2012 18:59
FXButton.connect example
FXButton.connect(SEL_COMMAND)do
# This code fires when the button is clicked
p "Yay! I was clicked!"
end
@jameshibbard
jameshibbard / password_generator_3.rb
Created September 2, 2012 19:02
Password Generator 3
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)
@jameshibbard
jameshibbard / include_special_chars.rb
Created September 2, 2012 19:04
Include Secial Charaters
@includeSpecialCharacters = false
specialChrsCheck = FXCheckButton.new(hFrame2, "Include special characters in password")
specialChrsCheck.connect(SEL_COMMAND) { @includeSpecialCharacters ^= true }