Skip to content

Instantly share code, notes, and snippets.

View mikz's full-sized avatar

Michal Cichra mikz

  • Prague, Czech Republic
View GitHub Profile
framework "CoreWLAN"
iface = CWInterface.interface
iface.disassociate
wlans = iface.scanForNetworksWithParameters(nil, error: nil)
wlan = wlans.find {|w| w.ssid == "WLAN_724A"}
p [wlan.bssid, wlan.ssid, wlan.securityMode, wlan.wlanChannel.channelNumber]
keys = File.read("./dictionary.txt").lines.to_a.reverse
Feature: Provider billing mode on
In order to bill active users
As a buyer
I don't want to be billed when I'm not active
Background:
Given the date is 10th January 2011
Given a provider "xyz.example.com" with billing enabled
And an application plan "Fixed" of provider "xyz.example.com" for 100 monthly
; <<>> DiG 9.7.3-P3 <<>> +trace developer.maxdome.de
;; global options: +cmd
. 60 IN NS e.root-servers.net.
. 60 IN NS f.root-servers.net.
. 60 IN NS g.root-servers.net.
. 60 IN NS h.root-servers.net.
. 60 IN NS i.root-servers.net.
. 60 IN NS j.root-servers.net.
. 60 IN NS k.root-servers.net.
; <<>> DiG 9.7.3-P3 <<>> developer.maxdome.de
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26621
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;developer.maxdome.de. IN A
;; ANSWER SECTION:
# Set Apple Terminal.app resume directory
if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
autoload -U add-zsh-hook
function lion_resume_chpwd {
# add support for OS X Lion window resume on Terminal.app relaunch
# straight port from /etc/bashrc on Lion
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
@mikz
mikz / reloader.rb
Created December 6, 2011 22:57
rails 3.1 reloader - holds reloading in dev mode untill some file is modified
module Reloader
def run_callbacks(*args)
case args.first.to_sym
when :prepare
# allow call to ActionDispatch.prepare!
# or when source was updated
# cleanup before every preload
if @app.nil? or changed?
reset!
super(:cleanup)
@mikz
mikz / currency_converter.coffee
Created November 5, 2011 23:04
Depends on money.js, nodejs, coffeescript and request
request = require('request')
money = require('money')
fs = require('fs')
arguments = process.argv.splice(2)
amount = arguments.shift()
try
loop
base = arguments.shift()
@mikz
mikz / gist:1337933
Created November 3, 2011 22:07
Rate current song in iTunes - Alfred Extension - requires macruby
read -s -r -d '' SCRIPT <<"EOF"
framework 'ScriptingBridge'
rating = ARGV.pop
itunes = SBApplication.applicationWithBundleIdentifier("com.apple.itunes")
track = itunes.currentTrack
track.rating = rating.to_f*20
puts "#{track.artist} - #{track.name} rated #{rating} stars"
EOF
@mikz
mikz / factory_girl.rb
Created September 5, 2011 21:39
factory_girl singleton helper
require 'factory_girl/step_definitions'
def FactorySingleton(*args)
FactorySingleton.find_or_self *args
end
module FactorySingleton
def find_or_self object, attribute = nil
# FIXME: instead of this probably could check validation reflection for unique attributes
attribute ||= case object
#!/usr/bin/env macruby
# encoding: utf-8
CALENDARS = ['Michal Cichra', 'Calendar'] # Set names of calendars to show
before = 3 # days to show before today
after = 10 # days to show after today
today = 'dnes'