Skip to content

Instantly share code, notes, and snippets.

@shime
shime / custom_sender_example.rb
Created February 28, 2012 14:23
conditioning airbrake at runtime
class CustomSender < Airbrake::Sender
alias_method :orig_send, :send_to_airbrake
def send_to_airbrake(data)
return if Random.new.rand(10..20).odd?
orig_send(data)
end
end
Airbrake.sender = CustomSender.new(Airbrake.configuration)
@shime
shime / test_airbrake.rb
Created March 9, 2012 18:35
test airbrake
(1..100).select { Airbrake.notify(:error_class => "Testing success rate",:error_message => "Error Message") }.length / 100.0
@shime
shime / console.js
Last active October 1, 2015 22:15
pick a random meetup attendee
// Paste this into your browser console to pick a random attendee
// from the list of users in the "Going" section of your
// event at meetup.com
//
// Skips the organizer (first in the list).
$('#rsvp-list li').eq(Math.floor(Math.random()*($('#rsvp-list li').length - 1)) + 1).find('a').text()

#RPPP INTERVJU

informatizacija vlastitog poslovanja - radimo projekte na zavodu

projekti: znanstveni, nastavni, međunarodni (fp6,fp7) - o rezultatima projekata pišu se neki radovi, evidentiraju se podaci

kad se napravi projekt, evidentira se rad i autori

različite vrste radova: studija, elaborat, članak u časopisu, diplomski, doktorska dizertacija, poglavlje u knjizi

@shime
shime / Gemfile
Created April 2, 2012 17:16
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@shime
shime / example.sh
Created April 3, 2012 11:04
Using a local clone of rails for development
$ ruby /path/to/rails/railties/bin/rails new myapp --dev
@shime
shime / airbrake.rb
Created April 4, 2012 16:23
[Airbrake] little hack to receive email on every occurrence of exception
Airbrake.configure do |config|
config.api_key = '092f2e6780f7c9117353d28dbe8486a3'
config.development_environments = []
end
module Airbrake
module Customization
def self.included(base) #:nodoc:
base.send(:alias_method_chain,:initialize,:customization)
end
@shime
shime / exceptions.rb
Created April 8, 2012 19:08
defining a lot of exceptions in a module
module Prawn
module Errors
exceptions = %w[ FailedObjectConversion InvalidPageLayout NotOnPage
UnknownFont IncompatibleStringEncoding UnknownOption ]
exceptions.each { |e| const_set(e, Class.new(StandardError)) }
end
end
@shime
shime / struct.rb
Created April 8, 2012 19:10
fun with struct
Contact = Struct.new(:first, :last, :email)
p Contact.new(*%w[James Gray james@grayproductions.net])
# >> #<struct Contact first="James",
# last="Gray",
# email="james@grayproductions.net">
p Contact.new(*%w[James Gray])
# >> #<struct Contact first="James", last="Gray", email=nil>
p Contact.new("James")
# >> #<struct Contact first="James", last=nil, email=nil>
@shime
shime / test.rb
Created April 10, 2012 14:11
Testing flattening of params with airbrake
require 'rubygems'
require 'airbrake'
Airbrake.configure do |config|
config.api_key = '092f2e6780f7c9117353d28dbe8486a3'
config.logger = Logger.new STDOUT
end
params = { 'blah' => 'blah', 'deeper_level' => {'stuff' => 'stuff', 'array' => ['a', 'b', 'c'] } }