This file contains hidden or 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 'benchmark' | |
require 'rulebook' | |
class Foo | |
[:admin, :blah].each do |role| | |
define_method "is_#{role}?" do | |
true | |
end |
This file contains hidden or 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
class DSL | |
def initialize(*args, &blk); call(*args, &blk); end | |
def call(*args, &blk); instance_exec(*args, &blk); end | |
end | |
class Klass | |
def foo | |
print 'foo' | |
DSL.new do | |
def bar |
This file contains hidden or 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
Needs two 7-segment displays and a target finder. | |
Wire the 1 [ENT] to the chips 'Player' link and the 7-segments accordingly | |
----------------------------------------------------------------------------- | |
@name Speedometer | |
@inputs Player:entity | |
@outputs A1 B1 C1 D1 E1 F1 G1 A2 B2 C2 D2 E2 F2 G2 Speed FirstNum SecondNum |
This file contains hidden or 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
class Foo | |
def subject(&blk) | |
if block_given? | |
blk.call(@subject) # How do I pass by reference and not by value here? | |
else | |
@subject | |
end | |
end | |
end |
This file contains hidden or 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
test 'An Array containing numbers' do | |
p subject #=> <Subject @name='' @object=nil> | |
subject 'An Array' do | |
subject ['one', 'two', 'three'] | |
subject.pop | |
end | |
p subject #=> <Subject @name='An Array' @object=['one', 'two']> | |
end |
This file contains hidden or 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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'> | |
<head> | |
<title>Gridlock64</title> | |
<link href='reset.css' rel='stylesheet' type='text/css' /> | |
<link href='style.css' rel='stylesheet' type='text/css' /> | |
<meta content='mikey' name='description' /> | |
<meta content='cars' name='keywords' /> | |
</head> |
This file contains hidden or 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
#!/bin/bash | |
IFS="|" | |
#===--- | |
( | |
echo "1" | |
testconnection=`wget --tries=3 --timeout=15 www.google.com -O /tmp/testinternet &>/dev/null 2>&1` | |
if [ $? != 0 ]; then | |
echo "#Internet Connection: Not connected" |
This file contains hidden or 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
#!/bin/bash | |
#===--- | |
( | |
echo "1" | |
testconnection=`wget --tries=3 --timeout=15 www.google.com -O /tmp/testinternet &>/dev/null 2>&1` | |
if [ $? != 0 ]; then | |
echo "#Internet Connection: Not connected" | |
else | |
echo "#Internet Connection: Connected" |
This file contains hidden or 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
sudo -k | |
zenity --entry --hide-text \ | |
--width=350 \ | |
--title="Root Password" \ | |
--text="Enter your root password:" | sudo -S -v | |
if [ "$?" != 0 ]; then | |
zenity --error --text="Sorry, bad password" | |
exit | |
fi |
This file contains hidden or 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 token(size=6) | |
chars = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a | |
chars.sample(size).inject("") { |result, char| result << char } | |
end | |
p token # => "aN7drK" | |
p token # => "tVO3HG" | |
p token(8) # => "UqeYGPL2" | |
=begin |
OlderNewer