Skip to content

Instantly share code, notes, and snippets.

@agoodman
agoodman / filtered_scope.rb
Created August 5, 2011 20:40
Ruby on Rails scope filtering
# Model:
#
# class Example < ActiveRecord::Base
# end
#
# Controller:
#
# class ExamplesController < ActionController::Base
# def index
# @examples = Example.filtered_scope(params[:filter])
@alno
alno / gem-review
Created August 25, 2011 14:22
Краткое описание некоторых интересных гемов
== Resque
Гем для обработки фоновых задач. Использует Redis для хранения очереди.
+ redis
+ web-интерфейс для просмотра текущих задач, перезапуска зафэйленых и т.п.
+ разные очереди, можно создавать отдельные обработчики для них
+ можно обрабатывать задачи, не загружая полностью рельсовое окружение
- polling (так же как и в delayed_job)
@windix
windix / REMDME.md
Created May 27, 2012 10:33
nginx + php-fpm + passenger

NGINX

Installed: 1.3.4 manually

wfeng@ca2:~$ /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.3.4
built by gcc 4.4.5 (Debian 4.4.5-8) 
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-cc-opt=-Wno-error --add-module=/usr/local/src/passenger-3.0.14/ext/nginx
@awidegreen
awidegreen / vim_cheatsheet.md
Last active April 10, 2025 20:01
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@justinweiss
justinweiss / filterable.rb
Last active January 30, 2025 13:06
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@jamesyang124
jamesyang124 / ruby_meta.md
Last active February 21, 2025 22:26
Ruby meta programming

#!/bin/ruby --verion => 2.0.0-p353

Self

In Ruby, self is a special variable that always references the current object.

  • Inside class or module definition, self refer to the Class or Module object.
  • Inside instance method, self refer to future instance object.
  • Inside class method, self refer to the class.i
@rubencaro
rubencaro / install_elixir.md
Last active September 30, 2023 03:58
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

@seanmcn
seanmcn / gist:62a021a765ad4f8e593b
Last active July 20, 2024 16:30
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
@guiman
guiman / config.rb
Last active October 26, 2018 13:50
Example mina deploy script using docker
require 'mina/git'
require 'mina/nginx'
set :application, 'your_app_name'
set :domain, 'your_server'
set :user, 'ubuntu'
set :deploy_to, '/location/to/deploy'
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, 'your_repo'
set :branch, 'master'
@angelortiz-io
angelortiz-io / firebird-arch-setup.txt
Last active May 25, 2021 21:48
How to setup firebird super server on archlinux
# install with yaourt
yaourt -S firebird-superserver
# create symlink for firebird isql due to a conflict with unixODBC isql
# check with this command:
whereis isql (ENTER)
isql: /usr/bin/isql /opt/firebird/bin/isql /usr/share/man/man1/isql.1.gz
# creating symlink:
sudo ln -s /opt/firebird/bin/isql /usr/bin/isql-fb