Skip to content

Instantly share code, notes, and snippets.

View kazjote's full-sized avatar

Kacper Bielecki kazjote

View GitHub Profile
#!/usr/bin/env ruby
# Simple script which can be used with couchapp to automatically
# push applications to couchdb on files update on systems supporting inotify.
#
# First install rubygems in your system, then:
#
# $ sudo gem install rb-inotify
# $ cd couchapp_project
# $ ./couchapp_updater
Selenium::WebDriver::Error::InvalidSelectorError:
The given selector "./descendant-or-self::*[contains(normalize-space(.), 'Who are you? Question number 1')] is either invalid or does not resultin a Webelement. The following error occurred:
[InvalidSelectorError] Unable to locate elements with the xpath expression ./descendant-or-self::*[contains(normalize-space(.), 'Who are you? Question number 1')] because of the following error:
[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMXPathEvaluator.createNSResolver]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://fxdriver/modules/atoms.js :: <TOP_LEVEL> :: line 2360" data: no]
# [remote server] file:///tmp/webdriver-profile20110824-22465-be82oi/extensions/[email protected]/components/driver-component.js -> file:///tmp/webdriver-profile20110824-22465-be82oi/extensions/[email protected]/components/firefoxDriver.js:466:in `unknown'
# [remot
@kazjote
kazjote / populate.rb
Created January 8, 2012 18:31
FnordMetric data generator
# Copy it to fnordmetric directory and run with
#
# bundle exec ruby -Ilib -I. populate.rb live
#
# to generate fake current traffic or
#
# bundle exec ruby -Ilib -I. populate.rb past
#
# to generate fake stats for last month.
#
@kazjote
kazjote / .vimrc
Created March 22, 2012 09:33
vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
@kazjote
kazjote / .Xmodmap
Created October 5, 2012 18:33
my keyboard mappings for typematrix keyboard
! Add right alt to control group
clear mod5
keycode 108 = Control_R
add control = Control_R
! Remap mail to page up and caps to page down
keycode 66 = Next
keycode 163 = Prior
(fn [n] (->>
(range 2 n)
(filter (fn [x]
(not (some #(and (= 0 (rem x %)) (= 0 (rem n %))) (range 2 (inc x))))))
count
inc))
@kazjote
kazjote / bloomd_crash.rb
Last active December 12, 2015 00:09
armon/bloomd will crash after a few runs of these
#!/usr/bin/env ruby
require 'socket'
ADDRESS = '127.0.0.1'
PORT = 8673
FILTER_NAME = 'filter_crasher'
20.times do |i|
require 'httparty'
Array.new(32) {|i| i}.map do |worker|
fork do
file = File.open("worker_#{worker}.log", "w")
1000.times do |i|
url = "http://localhost:9290/tests/test1.txt"
page = HTTParty.get(url)
file.puts("==============")
file.puts("url: #{url}")
const Gio = imports.gi.Gio;
let file = Gio.File.new_for_path('file.txt');
stream = file.replace(null, false, null, null, null);
let str = 'hello Kacper :)';
stream.write(str, null, null, null);
stream.close(null);
@kazjote
kazjote / benchmark
Created May 13, 2013 11:35
Ruby threads Threads are executed in parallel while waiting for external command to finish.
Using /home/kazjote/.rvm/gems/ruby-1.9.3-p327
➜ threads time ruby threads.rb 1
ruby threads.rb 1 0.02s user 0.01s system 0% cpu 10.054 total
➜ threads time ruby threads.rb 2
ruby threads.rb 2 0.02s user 0.02s system 0% cpu 6.049 total
➜ threads time ruby threads.rb 4
ruby threads.rb 4 0.01s user 0.02s system 0% cpu 4.040 total
➜ threads time ruby threads.rb 8
ruby threads.rb 8 0.02s user 0.02s system 1% cpu 3.037 total
➜ threads time ruby threads.rb 16