Skip to content

Instantly share code, notes, and snippets.

View HusseinMorsy's full-sized avatar

Hussein Morsy HusseinMorsy

  • morSystem GmbH
  • Düsseldorf, Germany
View GitHub Profile
@HusseinMorsy
HusseinMorsy / delicious.rb
Created May 12, 2009 06:23
HTTParty examples: Delicios and Twitter
# Example how to use HTTParty
# see http://railstips.org/2008/7/29/it-s-an-httparty-and-everyone-is-invited
require 'rubygems'
require 'httparty'
require 'pp'
config = YAML::load(File.read(File.join(ENV['HOME'], '.delicious')))
class Delicious
include HTTParty
curl -k --user username:password -o backup.xml -O 'https://api.del.icio.us/v1/posts/all'
# or with wget
# wget --no-check-certificate --user=username --password=password -Obackup.xml https://api.del.icio.us/v1/posts/all
require 'rubygems'
require 'sinatra'
set :views, File.dirname(__FILE__) + '/'
get '/formgen.js' do
# form kann z.B. aus Datei gelesen werden
content = '<form id="form">';
content += 'E-Mail: <input type="text" name="email" id="email"><br>';
content += 'Text: <input type="text" name="message" id="message"><br>';
content += '<input type="submit" value="send" id="send"></form>';
# ===================
# = Global Settings =
# ===================
set :application, "myapp"
set :domain, "family.bridge-mx11.de"
set :user, "deploy-familygame"
set :use_sudo, false
set :rails_env, "production"
# =======
mysql> select * from sites;
+----+-----------------------+-------------+--------------+----------+-------------+
| id | host | layout | cetrel_appid | show_all | redirect_to |
+----+-----------------------+-------------+--------------+----------+-------------+
| 3 | reisen.sales-lentz.lu | application | VSL | 1 | travels_url |
| 4 | reisen.travel.lu | travel_lu | TRR | 1 | travels_url |
| 5 | xmas.sales-lentz.lu | xmas | VSL | 1 | |
+----+-----------------------+-------------+--------------+----------+-------------+
3 rows in set (0.01 sec)
module ActionController
class Base < Metal
abstract!
include AbstractController::Callbacks
include AbstractController::Logger
include ActionController::Helpers
include ActionController::HideActions
include ActionController::UrlFor
module ActionController
# Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in
# repeated setups. The inclusion pattern has pages that look like this:
#
# <%= render "shared/header" %>
# Hello World
# <%= render "shared/footer" %>
#
# This approach is a decent way of keeping common structures isolated from the changing content, but it's verbose
# and if you ever want to change the structure of these two includes, you'll have to change all the templates.
migration 1, :shoe do
up do
create_table :shoes do
column :id, Serial, :nullable? => false
column :brand, String,, :nullable? => false
column :price, Float,, :nullable? => false
column :available, Boolean, :nullable? => false
column :created_at, DateTime, :nullable? => false
column :updated_at, DateTime, :nullable? => false
end
def initialize(params={})
@from_date=params["from_date"].to_date if params["from_date"]
@to_date=params["to_date"].to_date if params["to_date"]
@from_time=params["from_time"] if params["from_time"]
@to_time=params["to_time"] if params["to_time"]
@busroute_ids=params["busroute_ids"] if params
end
def initialize(params={})
if params.kind_of? Hash
@from_date=params["from_date"].to_date
@to_date=params["to_date"].to_date
@from_time=params["from_time"]
@to_time=params["to_time"]
@busroute_ids=params["busroute_ids"]
end
end