Skip to content

Instantly share code, notes, and snippets.

View andreif's full-sized avatar
👾
invading spaces

Andrei Fokau andreif

👾
invading spaces
View GitHub Profile
@andreif
andreif / db.rake
Created July 25, 2011 09:19 — forked from ches/db.rake
Rake task to open MongoDB console for a Rails app with Mongoid
namespace :db do
desc 'Open a MongoDB console with connection parameters for the current Rails.env'
task :console => :environment do
conn = Mongoid.master.connection
opts = ''
opts << ' --username ' << conn.username if conn.username rescue nil
opts << ' --password ' << conn.password if conn.password rescue nil
opts << ' --host ' << conn.host
opts << ' --port ' << conn.port.to_s
system "mongo #{opts} #{Mongoid.master.name}"
@andreif
andreif / .irbrc
Created July 25, 2011 09:20 — forked from ches/gist:630625
.irbrc for logging goodies like SQL/Mongo queries to $stdout if in Rails 3 console
# .irbrc to log goodies like SQL/Mongo queries to $stdout if in Rails 3 console
if defined?(Rails) && Rails.respond_to?(:logger)
require 'logger'
Rails.logger = Logger.new($stdout)
if defined?(Mongoid)
Mongoid.logger = Rails.logger
end
end
@andreif
andreif / bootstrap.sh
Created August 19, 2011 19:46 — forked from anonymous/bootstrap.sh
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@andreif
andreif / bootstrap.sh
Created August 19, 2011 19:56 — forked from utsengar/bootstrap.sh
Django on Heroku with Postgres, Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@andreif
andreif / create_django_heroku_project.sh
Created August 19, 2011 19:57 — forked from tkopczuk/create_django_heroku_project.sh
Script to create a new Heroku-ready Django project.
#!/bin/bash
mkdir prancing_heroku
cd prancing_heroku
django-admin.py startproject prancing_heroku
echo "Django==1.3" > requirements.txt
echo "psycopg2" >> requirements.txt
echo "web: prancing_heroku/run_heroku_run.sh" > Procfile
@andreif
andreif / ldap_admin.rb
Created September 8, 2011 19:22 — forked from tritonrc/ldap_admin.rb
Simple Sinatra based LDAP admin tool
require 'rubygems'
require 'sinatra'
require 'net-ldap'
require 'digest/sha1'
require 'base64'
require 'haml'
LDAP_HOST = 'localhost'
ADMIN_DN = 'cn=admin,dc=company,dc=com'
@andreif
andreif / readme.md
Created December 29, 2011 22:44 — forked from mralex/sinatra-memcacher.rb
Simple memcached helper for Sinatra.

Simple memcached module, derived from [gioext/sinatra-memcache][1], updated to use the 'memcached' gem.

Compatible with Sinatra 1.2

Usage

Activate in a modular Sinatra app:

 register Sinatra::Memcacher
@andreif
andreif / chat.rb
Created December 30, 2011 18:00 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
// ==UserScript==
// @name Show Full Domain on Hacker News posts
// @description Sets full domain on hacker news posts.
// @namespace http://userscripts.org/users/119115
// @include http://news.ycombinator.com/*
// @include https://news.ycombinator.com/*
// @match https://news.ycombinator.com/*
// @match http://news.ycombinator.com/*
// ==/UserScript==
@andreif
andreif / hack.sh
Created March 31, 2012 19:57 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#