Skip to content

Instantly share code, notes, and snippets.

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
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
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
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
#!/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 }
# 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
@juno
juno / PreloadHelper.php
Created July 26, 2008 02:12
Image preloading helper for symfony.
<?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)) {
>> pounds = 1.5
=> 1.5
>> ounces = (1 - "0.#{pounds.to_s.split('.').last}".to_f) * 16
=> 8.0
@ishikawa
ishikawa / gist:2580
Created July 26, 2008 02:49
domready.js
/**
* 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:
@ishikawa
ishikawa / gist:2582
Created July 26, 2008 02:53
Random ASCII Characters
require 'enumerator'
def random_string(length=10, s="")
length.enum_for(:times).inject(s) do |result, index|
s << rand(93) + 33
end
end