Skip to content

Instantly share code, notes, and snippets.

View ecleel's full-sized avatar

Abdulaziz Alshetwi ecleel

View GitHub Profile
@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
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 / 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
# ...
@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

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 / season.rb
Created January 8, 2015 13:10
Season Function
require 'date'
def season(date)
case date.yday
when 80..202 then "Spring"
when 203..264 then "Summer"
when 265..355 then "Autumn"
else
"Winter"
end
@ecleel
ecleel / apps_search.rb
Created November 30, 2014 17:06
Search for apps in iTunes and Google Play and return csv files for each store.
require 'csv'
require 'json'
require 'itunes-search-api'
require 'market_bot'
query = ARGV.first
puts query