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
@wxmn
wxmn / embedded_documents.rb
Created Nov 6, 2010
Examples of Atomic Operations on Embedded Documents in MongoMapper
View embedded_documents.rb
#Stories are embedded docs in a Feed
class Feed
include MongoMapper::Document
many :stories
end
class Story
include MongoMapper::EmbeddedDocument
key :title, String
@5v3n
5v3n / spec_helper.rb
Created Apr 13, 2011
in order to make spork reload routes & any rb file in the app folder:
View spec_helper.rb
Spork.each_run do
load "#{Rails.root}/config/routes.rb"
Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f }
end
@mrrooijen
mrrooijen / deploy.rb
Created Jun 26, 2011
Capistrano with Foreman Capfile
View deploy.rb
# encoding: utf-8
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :application, "hirefireapp"
set :repository, "git@codeplane.com:meskyanichi/myapp.git"
set :branch, "develop"
set :rvm_ruby_string, "1.9.2"
@reidmorrison
reidmorrison / collection.rb
Last active Sep 28, 2015
Mongo Reconnect logic for Connection Failures. Deprecated, moved to: https://github.com/reidmorrison/mongo_ha
View collection.rb
#
# NOTE: This gist is now deprecated and has been moved into a gem: https://github.com/reidmorrison/mongo_ha
#
require 'mongo/collection'
module Mongo
class Collection
alias_method :find_one_original, :find_one
def find_one(*args)
@hisea
hisea / nginx
Created Jan 1, 2012
ubuntu passenger nginx init.d script
View nginx
sudo cp nginx /etc/init.d/
sudo update-rc.d nginx defaults
sudo chmod +x /etc/init.d/nginx
/etc/init.d/nginx start
View yardoc_cheatsheet.md

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

# Namespace for classes and modules that handle serving documentation over HTTP
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active Oct 17, 2019
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
View gist:4353170
# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.
@dqminh
dqminh / applause_formatter.rb
Last active Dec 18, 2015
rspec formatter that applause you when your tests pass
View applause_formatter.rb
require "rspec/core/formatters/progress_formatter"
class ApplauseFormatter < RSpec::Core::Formatters::ProgressFormatter
def initialize(output)
super(output)
unless File.exists? "/tmp/applause.mp3"
p "Downloading applause for awesomeness"
system "wget http://www.soundjay.com/human/applause-1.mp3 -O /tmp/applause.mp3"
end
end
You can’t perform that action at this time.