Skip to content

Instantly share code, notes, and snippets.

View wpiekutowski's full-sized avatar

Wojciech Piekutowski wpiekutowski

View GitHub Profile
<h1>New phrase</h1>
<% form_for(@phrase) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :content %><br />
<%= f.text_field :content %>
</p>
<p>
require 'rubygems'
require 'mongo_mapper'
require 'pp'
class Person
include MongoMapper::Document
key :name, String, :default => 'John Doe'
end
require 'RNotify'
notify_status = Notify.init('rstakeout')
raise 'Failed to initialize libnotify' unless notify_status
notification = Notify::Notification.new 'rstakeout', nil, nil, nil
# many times
notification.update "test", "message", nil
notification.timeout = 1
notification.urgency = 0
notification.show
class User
attr_accessor :first_name, :last_name
def full_name
"#{@first_name} #{@last_name}"
end
def full_name=(full_name)
@first_name, @last_name = full_name.split(' ')
end
uri = URI::HTTP.build :host => 'www.google.com',
:path => '/ig/calculator',
:query => "q=1#{from.iso_code}%3D%3F#{to.iso_code}"
data = uri.read
@wpiekutowski
wpiekutowski / gist:785376
Created January 18, 2011 23:30
parse.rb
def parse(name)
pattern = /
(?:\[(\w+)\])?
(\w+)
(?:\[(\w+)\])?
/x
words = pattern.match(name).captures
combinations = [words[1]]
if words[0]
combinations << words[0] + words[1]
$ python buildscripts/smoke.py --mode=files jstests/drop2.js
['jstests/drop2.js']
cwd [/home/wojtek/hdd_home/projects/mgr/mongo_db/src]
num procs:217
removing: /data/db/sconsTests//mongod.lock
removing: /data/db/sconsTests//test.0
removing: /data/db/sconsTests//test.ns
removing: /data/db/sconsTests//test.1
running /home/wojtek/hdd_home/projects/mgr/mongo_db/src/mongod --port 32000 --dbpath /data/db/sconsTests/
Mon May 16 13:05:30 [initandlisten] MongoDB starting : pid=9575 port=32000 dbpath=/data/db/sconsTests/ 64-bit
Device: sat16:/dev/sda
Type: 16 Byte SCSI ATA SAT Passthru
Size: 114473 MiB
Model: [INTEL SSDSA2CW120G3]
Firmware: [4PC10302]
SMART Available: yes
Quirks: 232_AVAILABLERESERVEDSPACE 233_MEDIAWEAROUTINDICATOR 225_TOTALLBASWRITTEN 4_UNUSED 226_TIMEWORKLOADMEDIAWEAR 227_TIMEWORKLOADHOSTREADS 228_WORKLOADTIMER 3_UNUSED
Awake: yes
SMART Disk Health Good: yes
Off-line Data Collection Status: [Off-line data collection activity was never started.]
@wpiekutowski
wpiekutowski / .synergy.conf
Created October 3, 2011 14:59
My synergys config with PC-style Mac keyboard
# ~/.synergy.conf
# http://synergy2.sourceforge.net/configuration.html
# run with synergy -f
section: screens
morpork:
mac-mini:
alt = super
# Mac -> Mac
# ctrl = ctrl
# super = alt
@wpiekutowski
wpiekutowski / kleisli_example.rb
Created April 13, 2016 13:46
kleisli gem: raise exception on None or unwrap value
require 'kleisli'
result = Maybe(something)
case result
when None()
raise 'operation failed'
else
puts result.value
end