Skip to content

Instantly share code, notes, and snippets.

@JakubOboza
JakubOboza / pebble.rb
Created March 15, 2014 19:36
if you need a quick check on riak buckets
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require 'riak'
require 'optparse'
options = {}
OptionParser.new do |opts|
namespace :deploy do
task :starting do
invoke 'deploy:check'
end
task :updating => :new_release_path do
invoke "#{scm}:create_release"
invoke 'deploy:symlink:shared'
end

Sinatra like Web Framework for Scala

I tried few solutions like Scalatra, Play and for my POV Scalatra was a bit too bloated and big, didn't feel like sinatra at all. Play is more like Rails so you get everything. But spark is simple and easy to udnerstand. I didn't see any Scala example so i made one.

Sadly there are few things i don't like :(

If we would build DSL in a different way eg. we could have it like this:

 get(Route("/hello"){
@JakubOboza
JakubOboza / try_out_browser.scala
Last active August 29, 2015 14:05
super simple web browser using javafx.
import javafx.application.Application
import javafx.geometry.HPos
import javafx.geometry.VPos
import javafx.scene.Node
import javafx.scene.Scene
import javafx.scene.layout.HBox
import javafx.scene.layout.Priority
import javafx.scene.layout.Region
import javafx.scene.paint.Color
import javafx.scene.web.WebEngine
require 'minitest/autorun'
# Money are in floats for simplicity, it should be bigint
# Promotions are prioritized in order [A,B] => A rule is applied first, B rule is applied second
class Item
attr_accessor :name, :price, :product_code
def initialize(name, price, product_code)
@name = name
@price = price
data Configuration =
Configuration { path :: String,
localhost :: String,
remotehost :: String,
isguest :: Bool,
issuperuser :: Bool,
currentdir :: String,
homedir :: String,
timeconnected :: Integer
}
require 'rubygems'
require 'sinatra'
get '/' do
erb :index
end
use_in_file_templates!
get '/:permalink' do
# dopasowany wzorzec bedzie w params[:permalink]
end
@JakubOboza
JakubOboza / gist:30696
Created December 1, 2008 10:03
Using yaml dump with Active Record
class Comatose::Page < ActiveRecord::Base
end
desc "load pages"
task :load_pages_to_db => :environment do
YAML::add_private_type("Comatose::Page") do |type, value|
Comatose::Page.new(value)
end
# strona.rb
require 'rubygems'
require 'sinatra'
get '/' do
'Cze!'
end