Skip to content

Instantly share code, notes, and snippets.


nhm tanveer hossain khan (hasan) we4tech

View GitHub Profile
we4tech / before_all_tip.rb
Last active Aug 29, 2015
How to speed up your rspec execution
View before_all_tip.rb
before(:all) { @stuff = create :stuff }
let!(:stuff) { @stuff }
before { Stuff.stub(:find).with( }
we4tech / Gemfile
Last active Aug 29, 2015
Basic standalone rake/thor based project bootstrap
View Gemfile
source ''
# Core libraries
gem 'rake'
gem 'activesupport'
gem 'bson_ext'
# Add gems related with content parsing
gem 'nokogiri'
we4tech / nginx_tomcat
Last active Aug 29, 2015
View nginx_tomcat
server {
listen 80 default;
server_name _;
root /opt/apache-tomcat-7.0.53/webapps/ROOT;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_max_temp_file_size 0;
we4tech / elasticsearch.conf
Last active Aug 29, 2015 — forked from rbscott/elasticsearch.conf
ElasticSearch upstart script
View elasticsearch.conf
# ElasticSearch Service
description "ElasticSearch"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
we4tech / tomcat.conf
Last active Aug 29, 2015 — forked from witscher/tomcat.conf
Tomcat 7 configuration
View tomcat.conf
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn limit 10 5
limit nofile 32000 32000
console output
we4tech /
Last active Aug 29, 2015
Setting up a Mongodb instance with RAID 10 and separate disk for Journal and Log

Mongodb Server Setup

At the end of process we will have /mdb/data for mongodb database directory which is on RAID 10. /mdb/journal which is used for storing journal files with IOPS 250 and /mdb/log with IOPS 125.

  1. Let's assume we have xvdb, xvdc for /mdb/data
  2. We have xvdd for /mdb/journal
  3. And xvde for /mdb/log
  4. Let's follow the following commands
we4tech /
Last active Aug 29, 2015 — forked from elvio/
With ruby 2.0
#!/usr/bin/env bash
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev git
sudo mkdir /tmp/ruby_install && cd /tmp/ruby_install
wget -O ruby-install-0.4.2.tar.gz
tar -xzvf ruby-install-0.4.2.tar.gz
cd ruby-install-0.4.2/
sudo make install
sudo ruby-install -i /usr/local -p ruby 2.0
gem install chef --no-ri --no-rdoc
we4tech / convert_to_csv_from_mongodb.rb
Created Jun 12, 2014
Converts data from mongodb to CSV, just an example code (which utilizes multi threads and queue in ruby)
View convert_to_csv_from_mongodb.rb
require 'rubygems'
require 'bundler/setup'
require 'csv'
require 'pp'
# Configure and load dependencies
env = :development
config = {
'development' => {
'uri' => 'mongodb://localhost:27017/some_database'
we4tech / common_api_response.rb
Last active Aug 29, 2015
A simple and quick way to generate restful api for any model.
View common_api_response.rb
# spec/support/shared/common_api_response.rb
shared_examples 'common api response' do |param_key|
it 'responds in json' do
expect(response.content_type).to be == 'application/json'
it "assigns #{param_key}" do
expect(assigns(param_key.to_sym)).not_to be_nil
we4tech / cleanup.rb
Created Jul 13, 2014
Replace none alpha numeric unicode characters.
View cleanup.rb
text.gsub(/[^[[:alnum:]]]/, ' ').gsub(/\s+/, ' ')
You can’t perform that action at this time.