Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View we4tech's full-sized avatar

Hossain Khan we4tech

View GitHub Profile
@we4tech
we4tech / before_all_tip.rb
Last active August 29, 2015 13:56
How to speed up your rspec execution
before(:all) { @stuff = create :stuff }
let!(:stuff) { @stuff }
before { Stuff.stub(:find).with(stuff.id.to_s).and_return(stuff) }
@we4tech
we4tech / Gemfile
Last active August 29, 2015 13:57
Basic standalone rake/thor based project bootstrap
source 'https://rubygems.org'
# Core libraries
gem 'rake'
gem 'activesupport'
gem 'bson_ext'
# Add gems related with content parsing
gem 'nokogiri'
@we4tech
we4tech / elasticsearch.conf
Last active August 29, 2015 13:58 — forked from rbscott/elasticsearch.conf
ElasticSearch upstart script
# ElasticSearch Service
description "ElasticSearch"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
@we4tech
we4tech / tomcat.conf
Last active August 29, 2015 13:58 — forked from witscher/tomcat.conf
Tomcat 7 configuration
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
limit nofile 32000 32000
console output
@we4tech
we4tech / nginx_tomcat
Last active August 29, 2015 13:58
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
we4tech / steps.md
Last active August 29, 2015 14:00
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
we4tech / bootstrap.sh
Last active August 29, 2015 14:01 — forked from elvio/bootstrap.sh
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 https://github.com/postmodern/ruby-install/archive/v0.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 https://gist.githubusercontent.com/plexus/10021261/raw/305492ebd17308e55eee1baab27568fafaa940cb/ruby-2.0-p451-readline.patch ruby 2.0
gem install chef --no-ri --no-rdoc
@we4tech
we4tech / convert_to_csv_from_mongodb.rb
Created June 12, 2014 08:41
Converts data from mongodb to CSV, just an example code (which utilizes multi threads and queue in ruby)
require 'rubygems'
require 'bundler/setup'
require 'csv'
require 'pp'
# Configure and load dependencies
env = :development
config = {
'development' => {
'uri' => 'mongodb://localhost:27017/some_database'
@we4tech
we4tech / common_api_response.rb
Last active August 29, 2015 14:02
A simple and quick way to generate restful api for any model.
# 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'
end
it "assigns #{param_key}" do
expect(assigns(param_key.to_sym)).not_to be_nil
end
@we4tech
we4tech / cleanup.rb
Created July 13, 2014 18:07
Replace none alpha numeric unicode characters.
text.gsub(/[^[[:alnum:]]]/, ' ').gsub(/\s+/, ' ')