Discover gists
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
obiekt.tags << %w(szybki wolny 6_cylindrow) # dodawanie | |
obiekt.tags >> %w(wolny) # usuwanie | |
obiekt.tags # zwracanie | |
obiekt.tags=(tags) # przypisanie | |
szukanie obiektow po tagach, klasa moze byc automatycznym tagiem, jakies zdolnosci specjalne, cos jak duck typing ale bardziej przeszukiwalny itp | |
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
DIR=/(.*)\.(.*)/ | |
Dir.entries(Dir.pwd).each do |e| | |
next unless e.match(/[a-z]/) | |
puts 'moving ' + e + ' to ' + e.gsub(DIR, '\1') | |
`mkdir #{e.gsub(DIR, '\1')}` | |
`mv #{e} #{e.gsub(/(.*)\.(.*)/, '\1')}/` | |
end | |
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
drwxr-xr-x 21 leachim6 leachim6 4096 2008-07-25 20:58 . | |
drwxr-xr-x 27 leachim6 leachim6 4096 2008-07-21 23:20 .. | |
drwxr-xr-x 2 leachim6 leachim6 4096 2008-07-25 20:58 a | |
-rw-r--r-- 1 leachim6 leachim6 100 2008-05-03 08:01 ada.ada | |
-rw-r--r-- 1 leachim6 leachim6 53 2008-05-03 08:01 apc.apc | |
-rw-r--r-- 1 leachim6 leachim6 31 2008-05-03 08:01 applescript.scpt | |
-rw-r--r-- 1 leachim6 leachim6 47 2008-05-03 08:01 awk.awk | |
drwxr-xr-x 2 leachim6 leachim6 4096 2008-07-25 20:58 b | |
-rw-r--r-- 1 leachim6 leachim6 33 2008-07-25 20:27 bash.sh | |
-rw-r--r-- 1 leachim6 leachim6 27 2008-07-25 20:27 befunge.be |
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
BWPRICE = 0.045 | |
COLPRICE = 0.12 | |
unless ARGV[0] then | |
puts "Usage: #{$0} [#bwpages] [#colpages] [#copies] [binding-price/copy]" | |
exit 1 | |
end | |
binding_price = ARGV[3].to_f |
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 | |
PATH_TO_DIFFMERGE = "/Applications/DiffMerge.app" | |
at_exit { | |
call("rm -rf clone/") | |
} | |
def call(cmd) | |
IO.popen(cmd) {|io| io.read } |
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
# NOTE, all names, syntax, etc... are just off the top of my head to illustrate | |
# the general idea. Don't take anything too literally. | |
# I just started a blank project with DataMapper. DM Migrations knows | |
# that the current production database is empty because no schema has been "committed". | |
# | |
# I then created a new model: | |
class User | |
include DataMapper::Resource |
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
<?php | |
/** | |
* Returns a html to preload images using jQuery. | |
* | |
* @param array $urls An array of image URLs | |
* @return string HTML contents | |
*/ | |
function preload_images($urls) | |
{ | |
if (!is_array($urls)) { |
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
>> pounds = 1.5 | |
=> 1.5 | |
>> ounces = (1 - "0.#{pounds.to_s.split('.').last}".to_f) * 16 | |
=> 8.0 |
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
/** | |
* domready.js | |
* | |
* Cross browser mozilla's 'onDOMContentLoaded' implementation. | |
* Executes a function when the dom tree is loaded without waiting for images. | |
* | |
* Based on +Element.Events.domready+ from Mootools open source project, | |
* this tiny javascript library adds the emulated 'DOMContentLoaded' functionality. | |
* | |
* Features: |
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 'enumerator' | |
def random_string(length=10, s="") | |
length.enum_for(:times).inject(s) do |result, index| | |
s << rand(93) + 33 | |
end | |
end |