code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
class LoggedController < Controller
def go e
if user = AppEngine::Users.current_user
e.data['user'] = User.for(user)
super
else
to = AppEngine::Users.create_login_url(e.url)
e.redirect to
end
end
end
| Ruby |
require 'appengine-apis/users'
class HomePage < Controller
plug ''
end
| Ruby |
class User
include DataMapper::Resource
property :id, Serial
property :name, String
property :nick, String
property :email, String
property :registered, Time
property :secret, String
def save
@secret ||= '123456789123456789123456789'
super
end
RANKS = {
(1..2) => 'zelenáč',
(3..4)... | Ruby |
AppEngine::Rack.configure_app(
:application => "program-123",
:precompilation_enabled => false,
:version => "3") | Ruby |
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
gem "appengine-rack"
gem "dm-appengine"
gem 'json-jruby'
gem 'snarl'
gem 'RedCloth'
gem 'htmlentities'
gem 'syntax'
| Ruby |
class MyCompositeDecorator < MyComposite
def << composite
raise 'already have child' if child
super composite
end
def child= composite
remove_children
self << composite
end
def child
@children[0]
end
end | Ruby |
class MyComposite < MyCompositeLeaf
attr_accessor :children
def initialize
remove_children
end
def << composite
#composite.parent_composite = self
@children << composite
end
def remove composite
@children -= [composite]
end
def remove_children
@children = []
end
def child... | Ruby |
class Widget < MyCompositeDecorator
attr_accessor :element, :parent
def initialize(attrs = {})
super()
init_element(Element.new(:div))
end
def << composite
if child
child << composite
else
super
end
end
def children
child.children
end
def children= ch
child.c... | Ruby |
class Form < FieldComposite
#Handler.enable self
attr_accessor :app, :page, :fields, :success, :request, :env, :e
def initialize
super
self.form = self
init_element Element.new(:form, :method => 'post')
self << InputHidden.new(:name => 'a', :value => self.class.to_s)
end
def recieve_event e... | Ruby |
class FieldComposite < FormField
#Handler.enable self
attr_accessor :app, :page, :fields, :success
def initialize(html_attrs = {})
init_element Element.new(:div, html_attrs)
@fields = []
end
def << something
super
if something.methods.include? :form=
something.form = self.form
end... | Ruby |
class FormField < Widget
attr_accessor :form
def name
@name
end
def name= name
@name = name
end
def value
raise 'implement me'
end
def dump
value
end
def fill data
self.value = data
self
end
def recieve data
self.value = data
self
end
def submit
d... | Ruby |
class InputDate < Widget
attr_accessor :day, :month, :year
attr_accessor :date
attr_accessor :day_field, :month_field, :year_field
def initialize(options)
super()
element.tag_name = 'span'
self << @day_field = el(:select, :name => options[:name]+"_day")
@day_field.options = (1..31).to_a
... | Ruby |
class Composite < Widget
def init_widget widget
@widget = widget
set_primary_classes [self.class.to_s.split('::').last]
end
def set_primary_classes classes
@widget.set_primary_classes classes
end
def add_primary_class class_name
@widget.add_primary_class(class_name)
end
def to_s
@... | Ruby |
class MyCompositeLeaf
attr_accessor :parent_composite
# this method is inheritd from Object
#def visit &block
# block.call(self)
#end
def children
[]
end
def to_s
self.class.to_s
end
end | Ruby |
class SelectElement < Element
Element.factory('select', self)
Element.factory(:select, self)
def options= o
remove_children
if o.first
if o.first.is_a? Array
o.each { |k, v| add_option k, v }
else
o.each { |v| add_option v }
end
end
self
end
def add_option... | Ruby |
class NamedDecorator < DecoratorThing
attribute :name
attribute :caption
def initialize name = nil
super()
@name = name.to_s
end
def header_label
s = add_button
s << human_name #label(:value, caption || name)
s << label(:name, "property") + InputText.new(
:name => form_id(:name),... | Ruby |
class DateRangeField < NamedDecorator
attribute :from
attribute :to
def class_body
if name && name.length > 0
"property :#{name}_from, Date\n"+
"property :#{name}_to, Date\n"
end
end
# def creator e
# InputText.new(:name => (form_id :value), :value => value)
# end
def thingswecana... | Ruby |
class StringField < NamedField
def class_body
if name && name.length > 0
"property :#{name}, String\n"#+
#"attr_reader :#{name}\n"+
#"def #{name}= v\n attribute_set(:#{name}, v)\nend\n"+
#"def #{name}\n attribute_get(:#{name})\nend"
end
end
# def creator e
# InputText.new(:na... | Ruby |
class NamedContainer < NamedField
def thingswecanadd
[TemplateThing]
end
end
| Ruby |
class BooleanField < NamedField
def class_body
if name && name.length > 0
"property :#{name}, Boolean\n"#+
#"attr_reader :#{name}\n"+
#"def #{name}= v\n attribute_set(:#{name}, v)\nend"
end
end
def validate value
!!value
end
def thingswecanadd
[CheckBoxThing]
end
end | Ruby |
class TextField < NamedField
def class_body
if name && name.length > 0
"property :#{name}, Text\n"#+
#"attr_reader :#{name}\n"+
#"def #{name}= v\n attribute_set(:#{name}, v)\nend"
end
end
def thingswecanadd
[PlainTextThing]
end
end | Ruby |
class IntegerField < StringField
def class_body
if name && name.length > 0
"property :#{name}, Integer\n"#+
#"attr_reader :#{name}\n"+
#"def #{name}= v\n attribute_set(:#{name}, v)\nend"
end
end
def validate value
value.to_i
end
def thingswecanadd
[TextThing]
end
... | Ruby |
class PlaceField < StringField
def initialize *a
super
self.caption ||= 'umístění'
end
def name
'place'
end
def thingswecanadd
[NodeChooserThing]
end
end
| Ruby |
class ImportStuff < Controller
def index e
doc = ''
if e.request.post?
require 'appengine-apis/urlfetch'
if e.params['import-templates']
(import_templates e)
else
doc << (import_everything e)
end
end
<<HTML
<h1>Import</h1>
<form method="POST">
F... | Ruby |
module Remote
class Query
def initialize url
@server = Server.new(url)
end
def all filter = {}
select :all, filter
end
def first filter = {}
select :first, filter
end
def first filter = {}
select :last, filter
end
def select kind, filter
@server.... | Ruby |
module Remote
class Server
def initialize url
@url = url
end
def ask url, question, params = {}
JSON.parse AppEngine::URLFetch::HTTP.get(
make_uri(url, question, params))
end
def ask_file url, question, params = {}
FileResponse.new(
AppEngine::URLFetch.fetch(
... | Ruby |
module Remote
class Export < Controller
plug 'export'
def index e
<<HTML
<h1>Hello!</h1>
<p>here you can<p>
<h2>Get data</h2>
<pre>
?json={"name" => 'select', "params" => {'filter' => { datamapper-filter-options }}}
</pre>
<h2>Grab images</h2>
<pre>
images?json={"name" => "get", "params" => {"id... | Ruby |
module Remote
class ImportImages
def initialize url
@server = Server.new(url)
@list = @server.ask('/export/images', :list)[0]['images']
end
def import_image
image = next_image
if image.save
shift
else
raise "Hm hm hmmm, could not save image."
end
... | Ruby |
class Admin < Controller
plug 'admin'
# every action under Admin controller is protected
def go e
if users.current_user
super
else
login e
end
end
def initialize
puts "why doesn't this get called?!"
end
def users
if @users
@users
else
require 'appengine-... | Ruby |
class Templates < Controller
def index e
s = '<div class="ContentTemplates">'
s << '<center><h1>Šablony obsahu</h1>'
s << '<p>'
s << Element.new(:a, '+ add', :href => e.link(:add), :class => 'button').to_s
s << '</p>'
s << '<div class="contentTemplateList">'
ContentTemplate.all.each { |t|... | Ruby |
class Content < Controller
def index e
s = ''
s << '<center>'
#s << '<h1>Obsah</h1>'
s << (content_type_chooser e)
s << '</center>'
s
end
def content_type_chooser e
s = ''
ContentTemplate.all.each { |template|
s << Element.new(:a,
template.template_title,
:... | Ruby |
class Structure < Controller
def menu e
if parent_node_id = e.params['subnode']
form = Node::ShortForm.new()
form.env = e.env
form.fill 'parent_node_id' => parent_node_id
if e.request.post?
form.handle e.params
end
end
NodeMenu.each { |n, li|
li.append_chil... | Ruby |
class DevConsole
@@commands ||= []
KNOWN_TYPES = [
Hash, Array, Fixnum, NilClass,
TrueClass, FalseClass, String, Symbol,
Class, Module,
Time
]
def initialize
@log = []
end
def clear
@log = []
end
def exec code
@@commands << code
log '> '+code, :code
begin
... | Ruby |
class Designer < Controller
def index e
if !e.request.post?
@css_files = CssFile.all.to_a.sort {|a, b| a.title <=> b.title}
end
if e.params['save']
@css_files.each { |file|
file.recieve e
}
end
if e.params['add']
file = ContentTemplate.all.select { |t| t.class_na... | Ruby |
class Layouts < Controller
def index e
layouts = PageThing.all.map { |page|
title = page.title
if title.nil? || title.empty?
title = page.identity
end
Element.new(:a, title, :href => e.sublink('show/'+page.id.to_s))
}.map { |i| ("<li>"+i.to_s+"</li>") }.join
"<dev class=... | Ruby |
class ImagesController < Controller
plug :images
def index e
if e.params['img']
image_data = e.params['img'][:tempfile].read
file = ImageFileRecord.new({})
file.data = image_data
#file.data = image.resize(100,100).data
if !file.save
raise 'shiiit'
end
end
... | Ruby |
class VisualEditor < Controller
def index e
<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script>
... | Ruby |
class Pages < Controller
def index e
s = '<h1>Stránky</h1>'
s << '<p><a href="'+link(:add)+'">přidej</a></p>'
Page.all.each { |page|
s << "<p><a href=\"#{link('edit/'+page.id.to_s)}\">#{page.title}</a></p>"
}
s
end
def add e
s = '<h1>Přidat stránku</h1>'
form = Page::AdminForm... | Ruby |
class DisplayLogs < Controller
def index e
if e.params['detail']
detail e
else
list e
end
end
def list e
if e.params['remove']
DmLogger::LogFile.get!(e.params['remove']).destroy
end
data = <<JSCRIPT
<script>
toggle_log = function(e) {
var p = e;
console.log(... | Ruby |
class Tree < MySingleton
def self.initialize_singleton
# pre index stuff, so the levels and order
# are properly setup
tree = new
tree.index_nodes
tree
end
def clear_cache
@__nodes = nil
@__children = nil
# the one who made the change should pay with his time
puts "INDEX... | Ruby |
class Renderer < Thing
def initialize
end
def creator e
end
def recieve e
Pattern::Property.properties(self.class, :attribute).each { |attr, definition|
if data = e.params[(form_id attr)]
self.send(attr.to_s+'=', data)
end
}
super
end
end
class ShortTextRenderer <... | Ruby |
class Loader
def self.load_files files
$files ||= {}
files.each { |f|
$files[f] ||= nil
}
files.each {|f|
reload f
}
end
def self.reload file
$files ||= {}
time = File.mtime(file)
if !$files[file] || time > $files[file]
loadfile file
$file... | Ruby |
class JsonHash < DataMapper::Type
primitive String
def self.dump(value, property)
(value || {}).to_json
end
def self.load(value, property)
if value.is_a? String
JSON.parse(value)
else
value
end
end
def self.typecast(value, property)
value
... | Ruby |
class Object
@@unprocessed ||= []
@@__once_helper ||= {}
def visit &block
block.call(self)
end
def self.once &block
if block_given?
unless @@__once_helper[self]
@@__once_helper[self] = true
@@unprocessed << block
end
else
r = @@unprocessed
@@unprocesse... | Ruby |
class Thing
# javascript style in the house
::Pattern::Property.enable(self, :attribute, {
:getter => lambda { |o, param|
o.recover_state
o.instance_variable_get('@'+param.to_s)
},
:setter => lambda { |o, param, v|
o.recover_state
o.instance_variable_set('@'+param... | Ruby |
class ContentInsertionThing < Thing
def creator e
"-- here will be the content of your page --"
end
def render e
e.page.content || '-- no content here --'
end
end
class SidebarContainer < ContainerThing
def thingswecanadd
[TextThing, MenuThing, ImageThing]
end
end
class ContentContainer < Co... | Ruby |
class PlainTextThing < Thing
attr_accessor :content
def recieve e
if content = e.params[form_id(:text)]
@content = content
end
super
end
def id
'o'+object_id.to_s
end
def creator e
Element.new(:textarea, @content.to_s,
{ :style => "width:99%;", :name => form_id(:text), :... | Ruby |
=begin
class ContentThing < ContainerThing
# def title
# # default title implementation
# # when there is no field named "title"
#
# # look for title thing
# each_thing { |thing|
# if thing.class == TitleThing
# return thing.content
# end
# }
# # if none, just return something uniq... | Ruby |
module VersionControl
def self.random_token len = 36
Tokenizer.token len
end
class Tokenizer
def self.token len = 36
max = 36**len
# 10 + rand(100 - 10) will allways have expected length
(max/10 + rand(max - max / 10)).to_s 36
end
class Test < FwTest
def test_guid_... | Ruby |
class MenuThing < Thing
attribute :max_depth
attribute :min_depth
def creator e
s = render e
s << "hloubka od:"
s << InputText.new(
:name => form_id(:min_depth),
:value => min_depth || 0,
:size => 3
).to_s
s << ' do: '
s << InputText.new(
:name => form... | Ruby |
class DecoratorThing < ContainerThing
#attribute :child
def add *a
if children.length == 0
super
else
raise 'There can be only one!'
end
end
def child= thing
children[0] = thing
end
def child
children[0]
end
def go e
if child
child.go(e)
end
super(e... | Ruby |
class NodeThing < ContainerThing
property :title, String
property :string_id, String
property :is_root, Boolean
property :parent_identity, String
property :order, Integer, :default => 10
attr_accessor :level
attr_accessor :parent_node
attr_accessor :first
attr_accessor :last
attr_accessor :tree
... | Ruby |
class NodeMenu < Widget
def initialize options = {}
@options = options.stringify_keys
super()
@root = multiple_item_wrapper self
end
def nodes
if !@nodes
@nodes = {}
NodeThing.all.each { |node|
(@nodes[node.parent_identity] ||= []) << node
}
end
@nodes
end
... | Ruby |
=begin
class InlineThing < Thing
def
end
end
=end | Ruby |
class MyContentContainer < Thing
attribute :content_type
attribute :items_per_page
def recieve e
['items_per_page'].each { |a|
if e.params[form_id a]
self.send(a+'=', e.params[form_id a].to_i)
end
}
['content_type'].each { |a|
if e.params[form_id a]
self.send(a+'=... | Ruby |
require 'dm-appengine/types'
require 'base64'
class ImageFileRecord
include DataMapper::Resource
property :id, Serial
property :data, Blob
property :original, Integer
property :original_name, String
property :width, Integer
property :height, Integer
property :resized_to_width, Integer
property :resi... | Ruby |
class ImageThing < Thing
#attr_accessor :image_id
attribute :image_id
attribute :desired_width
attribute :desired_height
attribute :float
DEFAULT_SIZE = ['400', '600']
def desired_width
@desired_width || DEFAULT_SIZE[0]
end
def desired_height
@desired_height || DEFAULT_SIZE[1]
end
d... | Ruby |
class PagerThing < Thing
attribute :content_type
attribute :items_per_page
attribute :template_name
def recieve e
['items_per_page'].each { |a|
if e.params[form_id a]
self.send(a+'=', e.params[form_id a].to_i)
end
}
['content_type', 'template_name'].each { |a|
if e.para... | Ruby |
class KeepWarm < Controller
plug 'keep_warm'
def index e
'Thanks for keeping me warm!'
end
end
| Ruby |
=begin
class Tree < MySingleton
def nodes
@nodes = NodeThing.all
end
def destination(e)
path_destination(e) || root_destination
end
def path_destination e
dest = nil
tail = e.env[:unprocessed_tail]
tail.reverse.each_with_index { |string_id, i|
if node = nodes.select {|n| n.string... | Ruby |
class TemplateThing < ContentWithFields
attribute :name
def recieve e
Pattern::Property.properties(self.class, :attribute).each { |attr, definition|
if data = e.params[(form_id attr)]
self.send(attr.to_s+'=', data)
end
}
super
end
def header_label
add_button+
self.c... | Ruby |
# contains information about the thing
# that is not displayed on front-end
class MetaContainer < ContainerThing
def render e
''
end
end | Ruby |
class ContentTemplate < ContainerThing
Event.on('app:init') {
begin
ContentTemplate.all.each { |template|
template.establish_class
}
rescue
end
}
property :template_title, String
property :template_class, String
def initialize *a
super
#show_window false
can_mov... | Ruby |
class ContainerThing < Thing
def add thing
@things ||= []
@things << thing
thing.parent_thing = self
end
def go e
children.each { |ch| ch.go(e) }
super(e)
end
def can_add_more yes
@canAddMore = yes
end
def recieve e
recover_state
if action = e.params[(form_id :action)... | Ruby |
class ContentWithFields < ContainerThing
Pattern::Property.enable(self,
:field,
:on_define => lambda { |*a|
a[0].define_field *a
},
:getter => false,
:setter => false
)
@@__fields ||= {}
def self.define_field klass, name, definition
name = name.to_s
field_instance = definit... | Ruby |
class FieldGroup < ContentWithFields
attribute :name
def on_plug klass, name, definition
@name = name
(@@__fields[self.class] || []).each { |name, field|
field.on_plug(klass, name, definition)
#field.freeze
}
end
def self.define_field klass, name, definition
field_instance = defi... | Ruby |
class Testing
require "test/unit"
class TestCase < ::Test::Unit::TestCase
@@test_cases ||= {}
def self.run
::Test::Unit::UI::Html::TestRunner.run(self)
end
def assert_equal actual, expected, message = nil
super(expected, actual, message)
end
def self.run_to_html
::Tes... | Ruby |
class RunTests
attr_accessor :test_cases
def fw_tests e
tests = FwTest.all
if e.request['suite']
suite_name = e.request['suite'].split('-').join('::')
tests = tests.select { |t| t.to_s == suite_name }
end
run_tests tests
end
def app_tests e
tests = AppTest.all
if e.reques... | Ruby |
=begin
class Service
Pattern::Property.enable(self, :input)
Pattern::Property.enable(self, :output)
class Validator
def error o
raise "#{o.inspect} does not pass #{self.class}."
end
def validate o
validates?(o) || error(o)
end
end
class IntegerValidator < Validator
def in... | Ruby |
class Event
@@subscriptions ||= {}
@@published_events ||= {}
attr_accessor :name, :data, :response
def initialize name = nil, data = {}
if !data.is_a? Hash
raise "Second argument must be a Hash! was #{data.inspect}."
end
if name
@name = name.to_s
end
@data = {}
data... | Ruby |
class Controller < MySingleton
@@callback ||= {}
@@path ||= {}
attr_accessor :layout, :path
def self.test_plug path
path = path.to_s
instance.path = @@path[self] = path
end
def self.plug path
path = path.to_s
#changes subscription
if @@callback[self]
RequestEvent.unsubs... | Ruby |
require 'cgi'
def el *a
Element.get(*a)
end
class Element < MyComposite
@@pair_tags = %w{a b div em i iframe label option select span script textarea}
attr_accessor :tag_name, :parent
def self.factory tag, klass
(@@factory ||= {}).merge!(tag => klass)
end
def self.get *a
(@@factory[a[0]] || E... | Ruby |
class RequestEvent < Event
class Redirect < Exception
attr_accessor :url
def initialize url
@url = url
end
end
def initialize name = nil, data = nil
if data == nil
data = name || {}
name = nil
end
strigified_keys = {}
data = data.keys.each { |k|
strigified_ke... | Ruby |
class CssFile < Thing
attribute :css_hash
def initialize
super
end
def default_template
#add TitleThing.new
#add TextThing.new
self
end
def file_name
'siteCss' #children[0].content
end
def render e
Rack::Response.new(
CssManager.new(css_hash || {}).to_s,
200,... | Ruby |
class TitleThing < HeadingThing
def creator e
creator = super
creator.children.last.autocomplete = "off"
creator
end
def render e
'<h1>'+(@content || '---')+'</h1>'
end
end
| Ruby |
class HeadingThing < InputThing
end
| Ruby |
class NodeChooserThing < Thing
attribute :content
def recieve e
if content = e.params[form_id(:node_identifier)]
@content = content
end
end
def creator e
s = Element.new(:select, :name => (form_id :node_identifier))
s << Element.new(:option, '--- nic ---', :value => '')
Tree.instan... | Ruby |
class CheckBoxThing < Thing
attribute :content
def recieve e
if e.params[form_id :present]
content = e.params[form_id(:value)]
if content == "checked"
@content = true
else
@content = false
end
end
end
def creator e
e = Element.new(
:input,
:type... | Ruby |
class InputThing < Thing
attribute :content
def initialize options = {}
@options = options.stringify_keys
end
def recieve e
if content = e.params[form_id(:value)]
@content = content
end
super
end
def render e
content
end
def creator e
div = Element.new(:div)
if @... | Ruby |
class MySingleton
@@instance ||= {}
def self.instance
@@instance[self] ||= initialize_singleton
end
def self.reset
@@instance[self] = reset_singleton
end
def self.reset_singleton
initialize_singleton
end
def self.initialize_singleton
new
end
class Test < FwTest
def test_in... | Ruby |
module Pattern
end
| Ruby |
module Pattern
class Property
@@keywords ||= {}
@@options ||= {}
def self.enable who, keyword, options = {}
who.class_eval <<RUBY
def self.#{keyword} attribute, *a
#{self.to_s}.define(self, '#{keyword}', attribute, a)
end
RUBY
@@options[who] ||= {}
@@options[w... | Ruby |
module Pattern
module Contract
def self.enable klass, &block
klass.class_eval {
def self.contract &block
::Pattern::Contract.set(self, &block)
contract = Module.new(&block)
(contract.instance_methods - Module.new.instance_methods).each { |m|
send(:alias_m... | Ruby |
class WrappedException < Exception
def initialize message, exception
@message = message
@exception = exception
end
def message
@message
end
def backtrace
@exception.backtrace
end
end
| Ruby |
require 'cgi'
require 'json'
$KCODE = "U"
require 'dm-core'
DataMapper.setup(:default, "appengine://auto")
require 'fw/modules/util/loader'
class App
@@instance ||= nil
def self.call env
begin
(@@instance ||= instantiate).wrap_call(
RequestEvent.from_env(env)
)
... | Ruby |
require 'appengine-rack'
require 'app/config'
require 'fw/app'
run App
| Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
name = "Danny"
Puts "hello" + "#{name}" | Ruby |
name = "jekankervader"
puts "Untouchable Bugatti".upcase + " #{name}" | Ruby |
name = "joey".capitalize
puts "hello".capitalize + " #{name}"
| Ruby |
def helloworld(name)
puts "Hello #{name}"
end
helloworld("hommie")
helloworld("People")
| Ruby |
def helloworld(name)
puts "Hello #{name}"
end
helloworld("hommie")
helloworld("People")
| Ruby |
require 'CSV'
class String
def is_number?
true if Float(self) rescue false
end
end
def syntax(message = nil)
puts message unless message.nil?
puts "Syntax: ./parser.rb [csv|xml|ids]"
exit
end
if ARGV[0].nil?
syntax("Please specify the first argument.")
end
dir = 'sources/anexa/'
idMiniste... | Ruby |
require 'CSV'
dir = 'sources/rogovdata1/'
idMinistere = []
idAltele = []
idSectiuni = []
Dir.glob(dir + '*.csv') do |file|
csv = CSV.read(file)
csv.shift
csv.each do |row|
numeInstitutie = row[4]
idInstitutie = row[0]
if numeInstitutie.start_with?("Minister")
idMinistere.push(idInstitutie)... | Ruby |
#!/usr/bin/env ruby
#
# Copyright 2011 Wade Alcorn wade@bindshell.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.