Skip to content

Instantly share code, notes, and snippets.

View umar-webonise's full-sized avatar

Umar Siddiqui umar-webonise

View GitHub Profile
@umar-webonise
umar-webonise / gist:2deec22b048e6fa02925
Created September 19, 2015 05:25
Sublime text settings
{
"theme": "El Capitan.sublime-theme",
"el_capitan_font_default": false,
"el_capitan_font_san_francisco": false,
"el_capitan_font_helvetica_neue": false,
"el_capitan_font_helvetica": false,
"el_capitan_sidebar_blue_folders": false,
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"draw_white_space": "all",
"font_size": 12,
@umar-webonise
umar-webonise / add_client.rb
Last active September 3, 2015 14:10
Added Client in treeni Data Management
client = Client.new(name: 'Treeni')
client.save!
files = Dir["app/models/*.rb"]
models = files.map { |file| file.split('/').last.sub(/\.rb/, '').camelize.constantize }.select { |i| i != Client }
models.each { |model| model.update_all(client_id: client._id) }
@umar-webonise
umar-webonise / ionic.setup
Last active September 8, 2015 09:25
Ionic Setup
# Install java
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
# Install ubuntu-developer-tools-center
sudo add-apt-repository ppa:didrocks/ubuntu-developer-tools-center
sections = Section.includes(:questions).as_json(
only: [:_id, :id, :name, :description, :template_id, :section_id],
include: {
questions: {
only: [:_id, :description, :helptext]
}
}
)
section_hash = sections.index_by { |node| node['_id'].to_s }
@umar-webonise
umar-webonise / include_extend.rb
Created July 21, 2015 13:13
Best Way to Include and Extend a Module Method
module Swingable
def self.included(base)
base.extend(Swingable)
end
def swing
puts 'Did a swing!'
end
end
@umar-webonise
umar-webonise / kiba_etl_aggr.etl
Created July 2, 2015 04:32
A way to handle aggregation
source CsvSource, {"type"=>"csv", "file"=>{"path"=>"/home/webonise/Projects/Data-Integration/dump/users.csv"}, "options"=>{"col_sep"=>";"}}
transform RenameField, {"from"=>"euro", "to"=>"amount_euro"}
destination AggregateFieldsDestination,{ 'file' => { 'path' =>'dump/1435811412.csv'}, 'options' => {"group_by"=>["name"], "sum"=>"amount_euro"} }
source CsvSource,{ 'file' => { 'path' => 'dump/1435811412.csv' },'options' => {'col_sep' => ',' } }
transform RenameField, {"from"=>"amount_euro", "to"=>"euro"}
@umar-webonise
umar-webonise / etl_script_request.rb
Created June 30, 2015 05:03
Request to generate etl script
{
'source' => {
'type' => 'csv',
'file' => {
'path' => '/home/webonise/Projects/Data-Integration/dump/test.csv'
},
'options' => {
'col_sep' => ','
}
},
@umar-webonise
umar-webonise / mongoid.yml
Created June 25, 2015 03:11
for treeni dp connectivity
development:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: treeni_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
@umar-webonise
umar-webonise / $oid omit
Created June 15, 2015 06:13
Work ignoring mongoid $oid
# Patch for mongoid to return $oid instead of active record id
class << self
def serialize_from_session(key, _salt)
to_adapter.get(key[0])
end
end
@umar-webonise
umar-webonise / bson.rb
Created May 27, 2015 05:30
Omiting $oid when coverting to json
# place code in config/initializers/bson.rb
module BSON
class ObjectId
def as_json(*args)
to_s
end
end
end