Skip to content

Instantly share code, notes, and snippets.

@shime
shime / gist:1077934
Created July 12, 2011 13:04
Initialize compass in new rails app
compass init rails . --using blueprint
@shime
shime / instance_eval explanation.rb
Created January 14, 2012 00:14
instance_eval explanation
val = "pizdarija"
val.randomize
val.instance_eval do
def randomize
split(//).to_a.shuffle.join
end
#include <stdio.h>
int main(){
srand(time(NULL));
int i = 0;
int random;
for (i=0;i < 10;i++){
random = rand()%1000;
printf("%d\n",random);
}
return 0;
@shime
shime / hello.rb
Created January 20, 2012 15:13
hello world in sinatra
require 'sinatra'
get '/hi' do
"hello world!"
end
@shime
shime / example_controller.rb
Created February 16, 2012 17:52
sending errors to Exceptional with rescue_from
class ExampleController < ApplicationController
rescue_from Exception, :with => :render_custom
def render_custom(exception)
if Exceptional::Remote.error(Exceptional::ExceptionData.new(exception, "Test Exception"))
Rails.logger.info "Exceptional: #{exception.class} has been reported to Exceptional"
else
Rails.logger.error "Exceptional: Problem sending exception. Check your API key."
end
### Brojčano na ekranu ispišite koliko godina ima sekundi.
### Koliko imate godina ako ste stari 8286 dana?
### Ispišite svoje ime i prezime unatrag
### Ispišite trece slovo svog imena velikim slovom
@shime
shime / javascript_notifier.html
Created February 23, 2012 12:55
HTML code for Airbrake javascript notifier
<script type="text/javascript">
//<![CDATA[
(function(){
var notifierJsScheme = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + notifierJsScheme + "airbrake.io/javascripts/notifier.js' type='text/javascript'%3E%3C/script%3E"));
})();
//]]>
</script><script src="http://airbrake.io/javascripts/notifier.js" type="text/javascript"></script>
### Napišite program koji ce ispisivati string od 10 slova i 5 znamenki
### i to svaki put u drukcijem rasporedu
### Napišite program koji ce ispisati brojeve od 1 do 10, svaki u svom redu