This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Merb | |
module GlobalHelpers | |
def show_user | |
if session.authenticated? | |
@user ||= User.get(session[:user]) | |
@user.login | |
end | |
# with else confition doesn't work | |
else | |
display "Login" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/users/create" method="POST" accept-charset="utf-8"> | |
<input type="hidden" name="_method" value="POST" /> | |
<input type="text" name="user[login]" value="" id="user_login"> | |
<input type="password" name="user[password]" value="" id="user_password"> | |
<input type="password" name="user[password_confirmation]" value="" id="user_password_confirmation"> | |
<button type="submit">Register</button> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is the generated form. | |
<form method="post" action="/users"> | |
<label for="user_login">Login</label> | |
<input type="text" class="text" value="" name="user[login]" id="user_login"> | |
<label for="user_password">Password</label> | |
<input type="text" class="text" value="" name="user[password]" id="user_password"/> | |
<label for="user_password_confirmation">Confirm password</label> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merb : worker (port 4000) ~ Started request handling: Thu Dec 04 14:01:20 +0200 2008 | |
merb : worker (port 4000) ~ Routed to: {"user"=>{"password_confirmation"=>"mitko", "login"=>"mitko", "password"=>"mitko"}, "format"=>nil, "submit"=>"Create", "action"=>"create", "controller"=>"users"} | |
merb : worker (port 4000) ~ Params: {"user"=>{"password_confirmation"=>"mitko", "login"=>"mitko", "password"=>"mitko"}, "format"=>nil, "submit"=>"Create", "action"=>"create", "controller"=>"users"} | |
~ SELECT `id` FROM `users` WHERE (`login` = 'mitko') ORDER BY `id` LIMIT 1 | |
~ SELECT `id` FROM `users` WHERE (`email` IS NULL) ORDER BY `id` LIMIT 1 | |
merb : worker (port 4000) ~ {:before_filters_time=>5.8e-05, :dispatch_time=>0.011484, :action_time=>0.010302, :after_filters_time=>1.2e-05} | |
merb : worker (port 4000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Registration</h1> | |
<%= error_messages_for :user %> | |
<div id="stylized" class="myform"> | |
<%= form_for(@user, :action => resource(:users)) do %> | |
<label>Username | |
<span class="small">At least 4 characters</span> | |
</label> | |
<%= text_field :login %> | |
<label>Password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Category | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String | |
property :description, Text | |
property :url, String | |
property :created_at, DateTime | |
property :updated_at, DateTime | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shoes.setup do | |
gem 'twitter' | |
end | |
require 'twitter' | |
class TwitShoes < Shoes | |
url '/', :index | |
def index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Author : Mitko Kostov | |
E-Mail : [email protected] | |
Website : http://mitkokostov.info | |
""" | |
from math import log10 | |
def db2gain(n): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Author : Mitko Kostov | |
#E-Mail : [email protected] | |
#Website : http://mitkokostov.info | |
include Math | |
def db2gain(n) | |
x = (10**((n.to_f)/20)) | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bsort(list) | |
slist = list.clone | |
for i in 0..(slist.length - 1) | |
for j in 0..(slist.length - i - 2) | |
if ( slist[j + 1] <=> slist[j] ) == -1 | |
slist[j], slist[j + 1] = slist[j + 1], slist[j] | |
end | |
end |