Skip to content

Instantly share code, notes, and snippets.

Avatar

Abdulaziz Alshetwi ecleel

View GitHub Profile
@ecleel
ecleel / db_fixtures_dump.rake
Last active Jun 22, 2022 — forked from iiska/db_fixtures_dump.rake
Rails 5: Dump Rails db to fixtures
View db_fixtures_dump.rake
# Original from http://snippets.dzone.com/posts/show/4468 by MichaelBoutros
#
# Optimized version which uses to_yaml for content creation and checks
# that models are ActiveRecord::Base models before trying to fetch
# them from database.
namespace :db do
namespace :fixtures do
desc 'Dumps all models into fixtures.'
task :dump => :environment do
models = Dir.glob(Rails.root + 'app/models/**.rb').map do |s|
View moyasar.md

Sadad payment integration using moyasar gem

In this example, we will discuss step by step how to add sadad payment to your rails app using moyasar gem.

Requirments

View currencies.js
currencies = {
"aed": {
"priority": 100,
"iso_code": "AED",
"name": "United Arab Emirates Dirham",
"symbol": "د.إ",
"alternate_symbols": ["DH", "Dhs"],
"subunit": "Fils",
"subunit_to_unit": 100,
"symbol_first": false,
@ecleel
ecleel / season.rb
Created Jan 8, 2015
Season Function
View season.rb
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 Nov 30, 2014
Search for apps in iTunes and Google Play and return csv files for each store.
View apps_search.rb
require 'csv'
require 'json'
require 'itunes-search-api'
require 'market_bot'
query = ARGV.first
puts query
@ecleel
ecleel / diff.rb
Created Jun 5, 2014
SequenceMatcher class in ruby. credit to testunit folks.
View diff.rb
# port of Python's difflib.
#
# Copyright (c) 2001-2008 Python Software Foundation; All Rights Reserved
# Copyright (c) 2008-2011 Kouhei Sutou; All Rights Reserved
#
# It is free software, and is distributed under the Ruby
# license and/or the PSF license. See the COPYING file and
# PSFL file.
# Carry this code from testunit/testunit project.
@ecleel
ecleel / generate_object.py
Last active Sep 9, 2019
method to generate python object from array of kwargs
View generate_object.py
def generate_objects(object_type, obj_ary, default = {}, attr_names = {}):
"""Generate objects that is given in `obj_ary` of class `object_type`.
Parameters
----------
object_type : str
the class name
obj_ary : array
object attribute that will populate the object.
default : dict
@ecleel
ecleel / dabblet.css
Created Apr 27, 2013
Circular Tooltip (SO)
View dabblet.css
/**
* 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 Apr 27, 2013
Circular Tooltip (SO)
View dabblet.css
/**
* 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 / gist:5046107
Created Feb 27, 2013
Get this error when try to install ruby 2.0.0.p0
View gist:5046107
☺ 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...