Skip to content

Instantly share code, notes, and snippets.

View ecleel's full-sized avatar

Abdulaziz Alshetwi ecleel

View GitHub Profile

Why Rails fit our needs?

  • Ruby!

  • With Rails you focus on delivering value to your users. => Dave Thomas

  • Active Record {:amazing_syntax, :migration, }

  • Fast development => {:plugins, :generators}

  • Easy deploy => Capistrano

  • Convention over Configuration

  • Less code

  • Work agile

@ecleel
ecleel / tree.rb
Created April 13, 2011 23:17
tree example
class Node
attr_accessor :dad, :name
def initialize(name='', dad=nil)
@name, @dad = name, dad
end
def inspect
"My dad is #{@dad} "
end
@ecleel
ecleel / dict_options.py
Created July 17, 2011 07:45
DictOptions is OrderedOptions copy for python
# DictOptions is OrderedOptions copy for python.
# Basic idea: insted of use dict like this d['key'] = value use it as proprties d.key = value
#
# Examples:
# config = DictOptions()
# config.app_name = "Dictionary Test"
# config.database = "mysql"
# config.server = DictOptions()
# config.server.processes = 5
# ...
require 'net/ssh'
host = IO.readlines('test1.txt') # full path of servers' list
port = 22 # SSH port
user = 'root' # username
pass = "123123" # password
i = 0
begin
cmd = ["sudo /sbin/ip addr | grep mtu | grep -v lo | awk '{print $2}'", # Interfaces
@ecleel
ecleel / mdb.rb
Created February 8, 2012 05:05 — forked from dtolj/gist:784634
Ruby MS Access adapter
require 'rubygems'
require 'win32ole'
require 'csv'
mdb_file="c:/Sites/labs/50q.bok"
class AccessDb
attr_accessor :mdb, :connection, :data, :fields, :catalog
def initialize(mdb=nil)
@ecleel
ecleel / matrix.rb
Created May 30, 2012 19:47
Example of how use matrix class in ruby
require 'matrix'
require 'pp'
a = Matrix[ [1,2], [3,4]]
b = Matrix[ [4,3], [2,1]]
pp a
pp b
# encoding: UTF-8
require 'csv'
require 'json'
columns = %w(trackName trackViewUrl artistName version price releaseDate formattedPrice fileSizeBytes description)
exclude = [] # Here you can execlude list of urls you want
data = JSON.load(DATA.read)
puts data.count
@ecleel
ecleel / gist:5046107
Created February 27, 2013 08:02
Get this error when try to install ruby 2.0.0.p0
☺ rvm reinstall ruby-2.0.0-p0 --with-openssl-dir=$HOME/.rvm/usr --verify-downloads 1 --debug ruby-1.9.3-p385 user bbc8e58 ✗
ruby-2.0.0-p0 - reinstall
Log file: /Users/ecleel/.rvm/log/ruby-2.0.0-p0/remove.src.log
[2013-02-27 10:53:16] __rvm_rm_rf
__rvm_rm_rf () {
__rvm_rm_rf_verbose "$@"
}
current path: /Users/ecleel/Codes/
command(2): __rvm_rm_rf /Users/ecleel/.rvm/src/ruby-2.0.0-p0
Removing /Users/ecleel/.rvm/src/ruby-2.0.0-p0...
@ecleel
ecleel / dabblet.css
Created April 27, 2013 08:09
Circular Tooltip (SO)
/**
* Circular Tooltip (SO)
* http://stackoverflow.com/q/13132864/1397351
*/
* { margin: 0; padding: 0; }
body {
overflow: hidden;
background: url(http://theearlcarlson.com/experiments/amTooltip/img/bg.jpg);
}
/* generic styles for button & circular menu */
@ecleel
ecleel / dabblet.css
Created April 27, 2013 08:10
Circular Tooltip (SO)
/**
* Circular Tooltip (SO)
* http://stackoverflow.com/q/13132864/1397351
*/
* { margin: 0; padding: 0; }
body {
overflow: hidden;
background: url(http://theearlcarlson.com/experiments/amTooltip/img/bg.jpg);
}
/* generic styles for button & circular menu */