Skip to content

Instantly share code, notes, and snippets.

nhm tanveer hossain khan (hasan) we4tech

Block or report user

Report or block we4tech

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@we4tech
we4tech / twitter_client_patch.rb
Created May 31, 2013
Twitter Client with control loop, If any too many requests error raised. It'll sleep for a certain time period and will wake up and continue from last batch. This is an addition to Twitter::Client 'gem twitter'
View twitter_client_patch.rb
# Twitter Client with control loop, If any too many requests error raised.
# It'll sleep for a certain time period and will wake up and continue from last batch.
#
# This is an addition to Twitter::Client 'gem twitter'
module BeatDeckMachine::Scrapers::OAuth::TwitterClientPatch
MAX_ATTEMPTS = 20
extend ActiveSupport::Concern
@we4tech
we4tech / thread_pool.rb
Last active Dec 16, 2015
Thread pool, and separate mongo client with each thread.
View thread_pool.rb
class ThreadPool
attr_accessor :size, :pool
def logger
BeatDeckMachine::logger
end
def initialize(size)
@size = size
@jobs = Queue.new
@we4tech
we4tech / db.bash
Created Jan 24, 2013
Simple bash script to quickly import an existing schema to a fixed database or get quick access to mysql console.
View db.bash
#!/bin/bash
echo "---------------------------------------"
echo " Welcome to Quick Schema Importer "
echo "---------------------------------------"
ROOT=$PWD
CONF=""
@we4tech
we4tech / export-mongo-collections.rb
Last active Dec 11, 2015
Export mongodb collections and their properties to HTML format
View export-mongo-collections.rb
# Export collection name and their properties list in HTML format.
require 'mongo'
include Mongo
# Connect with mongodb server
client = MongoClient.new('localhost', 27017)
# Load database
@we4tech
we4tech / pre-push
Created Nov 9, 2015
GIT Pre push script to prevent from accidental force push to master branch
View pre-push
#!/usr/bin/env ruby
# Make sure you have 'colorize' gem installed already.
require 'colorize'
current_branch = `git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,'`
push_cmd = `ps -ocommand | grep "git push"`
if current_branch =~ /\/master/ && push_cmd =~ /(\-f|force|delete)/
puts '*********************************************'.colorize(:red)
@we4tech
we4tech / lambda-example.rb
Created Jul 24, 2012
Ruby closure lambda example
View lambda-example.rb
l = lambda { |a, b| ... }
l.call('A')
#=> Error need to pass 2 arguments
@we4tech
we4tech / lambda-proc-diff.rb
Created Jul 24, 2012
ruby closure lambda proc difference
View lambda-proc-diff.rb
def whats_your_name?
l = Proc.new { return "Karim" }
l.call
return "Rahim"
end
#=> "Karim"
@we4tech
we4tech / method.rb
Created Jul 24, 2012
Ruby closure method
View method.rb
def hola
puts 'hola'
end
def say_hola(block)
block.call
end
say_hola method(:hola)
@we4tech
we4tech / proc-example.rb
Created Jul 24, 2012
Ruby closure Proc example
View proc-example.rb
def say_hi_to(block)
puts "Say hi #{block.call}"
end
say_hi_to Proc.new { "hasan" }
#=> Say hi hasan
@we4tech
we4tech / block-example.rb
Created Jul 24, 2012
Ruby closure - block code example
View block-example.rb
def say_hi_to(&block)
puts "Say hi #{block.call}"
end
say_hi_to { "hasan" }
#=> Say hi hasan
You can’t perform that action at this time.