Skip to content

Instantly share code, notes, and snippets.

View Vetal4eg's full-sized avatar
👌
getting the right things done

Vitaliy Esaulenko Vetal4eg

👌
getting the right things done
View GitHub Profile
# stick it in your ~/.pryrc
# use 'xsel' or 'xclip' if you're in a Linux environment
#
def _cp(obj = Readline::HISTORY.entries[-2], *options)
if obj.respond_to?(:join) && !options.include?(:a)
if options.include?(:s)
obj = obj.map { |element| ":#{element.to_s}" }
end
out = obj.join(", ")
elsif obj.respond_to?(:inspect)
@mislav
mislav / _notes.md
Created December 29, 2009 12:12
Install MongoDB using Homebrew and set it up for your user on OS X

This gist is outdated

Homebrew people have since included this in a recipe.

$ brew update
$ brew install mongodb

( follow the instructions given )

namespace :db do
desc "load data from csv"
task :load_csv_data => :environment do
require 'fastercsv'
FasterCSV.foreach("importdata/tarife.csv", :headers => true, :col_sep => ',') do |row|
Anbieter.find_or_create_by_name(
:name => row['Anbieter_Name']
:hotline => row['Hotline'],
:email => row['Email']
@tobym
tobym / redis_pubsub_demo.rb
Created April 1, 2010 16:50 — forked from pietern/redis_pubsub_demo.rb
Redis PubSub demo with EventMachine (chat service)
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
require 'active_support'
DEPLOY_CONFIG = YAML::load(File.open("config/deploy.yml"))
default_run_options[:pty] = true
#
# General Deployment settings
#
set :application, DEPLOY_CONFIG['application']
set :repository, DEPLOY_CONFIG['repository'] || 'master'
set :scm, :git
@vvalgis
vvalgis / Capistrano tasks for starting unicorn.rb
Created May 7, 2010 08:13
Capistrano tasks for starting unicorn
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
<skm> what happens if you have more data then you do ram
<ronr_> your machine explodes!
<ronr_> you can use it for remote sabotage that way.
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
user app;
worker_processes 2;
error_log /home/app/logs/nginx.error.log info;
events {
worker_connections 1024;
}
module CML2
# Includes to ProductCategory model
module ProductCategory
def import node_set
::ProductCategory.delete_all
::ProductCategory.import_categories \
node_set.xpath('/КоммерческаяИнформация/Классификатор/Группы')
end