Skip to content

Instantly share code, notes, and snippets.

View denysonique's full-sized avatar

Dennis Prochniak denysonique

View GitHub Profile
$sessions = {}
class Test
def initialize(session, &blk)
$last_session = session
yield
end
end
class User
def initialize
menu = Menu.new
menu << 'Quit' do
$app.quit
end
#this appends a menu item 'Quit' which exits the application when clicked
foo << 'bar' do
something
end
@denysonique
denysonique / gist:2019269
Created March 12, 2012 02:03
How to build Ruby Kdebidings (QtRuby) on Windows
1. Download and install Qt SDK 4.8 (http://qt.nokia.com/downloads/)
2. Build Smokegen (https://projects.kde.org/projects/kde/kdebindings/smoke/smokegen/repository)
3. Build Smokeqt (https://projects.kde.org/projects/kde/kdebindings/smoke/smokeqt/repository)
4. Build (https://projects.kde.org/projects/kde/kdebindings/ruby/qtruby/repository)
class Contacts::ApplicationController
respond_to :json, :html
def index
respond_with Contacts.all
end
end
has_and_belongs_to_many :followers,
class_name: 'User',
foreign_key: 'follower_id',
join_table: 'followers_followees'
has_and_belongs_to_many :followees,
class_name: 'User',
foreign_key: 'followee_id',
join_table: 'followers_followees'
require 'sinatra'
require 'haml'
get '/hi/:variable' do
@variable = params[:variable]
haml :template_file
end
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route("/dashboard/<variable>")
def dashboard():
return render_template('template_file.html', variable=variable)
if __name__ == "__main__":
[root@speedy dennis]# parted /dev/sda p free
Model: ATA Hitachi HTS54321 (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 32.3GB 32.3GB primary boot
32.3GB 33.4GB 1081MB Free Space
3 33.4GB 160GB 127GB extended
class Array
def to_proc
lambda { |o| o.__send__(first, *self[1..-1]) }
end
end
1.9.3-p0 :031 > [1,2,3].map(&[:+, 1])
=> [2, 3, 4]