# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
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
## foo.rb [ruby] | |
require 'ramaze' | |
class User | |
def self.authenticate(credentials) | |
credentials if credentials['name'] == 'manveru' && credentials['pass'] == 'foo' | |
end | |
end | |
class Main < Ramaze::Controller |
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 nyan(&block) | |
yield | |
end | |
nyan do | |
printf "Nyan" | |
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
class Record < Sequel::Model | |
many_to_one :domain | |
plugin :validation_helpers, :composition | |
composition :serial, | |
:composer => proc { split(content) if type == 'SOA' }, | |
:decomposer => ( | |
proc do | |
.... |
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
# | |
# The purpose of the database is to hold nameserver zone records | |
# | |
# Unfortunately, the SOA type record contains several interesting space-separated | |
# "inner" fields we would like to access individually. | |
# | |
# The point is is to "autovivify" getters and | |
# setters for these "inner fields" | |
# | |
# I'll try to solve this using Sequel's composition plugin |
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
require 'sequel' | |
DB = Sequel.sqlite | |
DB.run "CREATE TABLE records (name VARCHAR(255) PRIMARY KEY NOT NULL, type VARCHAR(5), content VARCHAR(255))" | |
DB.run "INSERT INTO records VALUES ('example.com', 'SOA', 'ns.example.com root.example.com 2012333335 28800 86400 3600000 86400')" | |
Soa = Struct.new(:ns, :email, :serial, :refresh,:retry, :expiry, :minimum) | |
class Record < Sequel::Model | |
many_to_one :domain |
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
# Controller for Domains | |
# | |
class Domains < MainController | |
before_all do | |
# Context helps the default layout highlighting the good entry in the navbar | |
@context=:domains | |
end | |
render_custom :index do |action| |
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
PYTHONPATH=./lib nosetests -v | |
test_one (TestPlayBook.TestPlaybook) ... FAIL | |
test_async (TestRunner.TestRunner) ... FAIL | |
test_command (TestRunner.TestRunner) ... ok | |
test_copy (TestRunner.TestRunner) ... ok | |
test_facter (TestRunner.TestRunner) ... FAIL | |
test_fetch (TestRunner.TestRunner) ... ok | |
test_git (TestRunner.TestRunner) ... ok | |
test_ping (TestRunner.TestRunner) ... ok | |
test_service (TestRunner.TestRunner) ... ok |
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
# | |
# Example trimmed for brevity. | |
# | |
# | |
# ###################################### | |
# INPUT Dispatch | |
# ###################################### | |
-A INPUT -p tcp -j TCP_IN | |
-A INPUT -p udp -j UDP_IN | |
-A INPUT -p icmp -j ICMP_IN |
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
require 'redis' | |
require 'resque' | |
module Ramaze | |
module Helper | |
module EntId | |
def EntId.generate | |
r = Redis.new | |
Resque.enqueue(Ramaze::Helper::EntIdGenerator) if r.scard('laclasse.entid').to_i <= 1 | |
0 |