Skip to content

Instantly share code, notes, and snippets.

@sumskyi
sumskyi / README.md
Last active June 7, 2022 18:49
rails STI with custom "type" field and storing there value different from ClassName

GeoEntity.last

SELECT geo_entities.* FROM geo_entities ORDER BY geo_entities.id DESC LIMIT 1

returns:

County id: 4, eid: nil, pid: nil, ename: nil, etype: 2, created_at: "2011-11-21 06:26:37", updated_at: "2011-11-21 06:26:37"

@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@kylekeesling
kylekeesling / Old TableSorter Indicators
Created November 24, 2011 19:50
Incorporate Bootstrap Styling into Sortable Table Helper
Link to older version of the asset on github:
https://github.com/twitter/bootstrap/raw/96c3e709963516a06ad6e723a7bba3fbf5fc1ba2/assets/img/tablesorter-indicators.png
@tobyhede
tobyhede / postsql.sql
Created May 17, 2012 03:08
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@yoshiori
yoshiori / coderwall.html
Created July 12, 2012 07:54
octopress coderwall badges
{% if site.coderwall_user %}
<section class="well">
<ul class="nav">
<li class="nav-header">Coderwall Badges</li>
</ul>
<div id="coderwall_badges"></div>
<a href="http://coderwall.com/{{site.coderwall_user}}">@{{site.coderwall_user}}</a> on coderwall
<script type="text/javascript">
$(document).ready(function(){
$.getJSON("http://coderwall.com/{{site.coderwall_user}}.json?callback=?", function(data){
tell application "iTerm"
activate
tell (make new terminal)
tell (launch session "initial_session") to write text "cd ~/workspace/project1; clear"
tell i term application "System Events" to keystroke "D" using command down
tell last item of sessions to write text "cd ~/workspace/work/project2; clear"
tell i term application "System Events" to keystroke "d" using command down
tell last item of sessions to write text "cd ~/workspace/work/project3; clear"
@nlevchuk
nlevchuk / deploy.rb
Created November 29, 2012 09:02
config/deploy.rb
require 'bundler/capistrano'
require "rvm/capistrano"
require 'capistrano/ext/multistage'
load 'deploy/assets'
set :rvm_path, '/home/<USERNAME>/.rvm'
set :rvm_bin_path, '/home/<USERNAME>/.rvm/bin'
set :repository, 'git@github.com:<GIT_USERNAME>/<REPOSITORY_NAME>.git'
set :scm, :git
@somebody32
somebody32 / gist:5232120
Last active October 4, 2022 08:19
Список литературы для ознакомления с concurrent programming и реализацией этих принципов и подходов на ruby. Огромное спасибо @brainopia за составление.

Введение

Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой OS, эти термины практически везде одинаковые и здесь они изложены в понятной для начинающих форме.

http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_started/s1_procs.html

Прочесть нужно треть главы до подраздела "Starting a process", если С не пугает, читайте полностью. После прочтения вы будете понимать, что такое process, thread, mutex, priorites, semaphores, scheduler, contex-switch, kernel states.

Ruby

MyExceptions = [RangeError, RegexpError, IOError].freeze
begin
raise IOError, "should be rescued"
rescue *MyExceptions => e
puts e
end
@demirhanaydin
demirhanaydin / tire-parent-child-example.rb
Last active December 22, 2015 23:48
Elasticsearch parent/child example with tire
require 'rubygems'
require 'tire'
Tire.configure { logger 'elasticsearch.log', :level => 'debug' }
class Document
attr_accessor :title, :content
include Tire::Model::Persistence
include Tire::Model::Search
include Tire::Model::Callbacks