Skip to content

Instantly share code, notes, and snippets.

View ecleel's full-sized avatar

Abdulaziz Alshetwi ecleel

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

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 / 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 */