Skip to content

Instantly share code, notes, and snippets.

View srpouyet's full-sized avatar

Sebastiaan Pouyet srpouyet

View GitHub Profile
@srpouyet
srpouyet / sequel_scopes.rb
Created August 31, 2018 14:25 — forked from odigity/sequel_scopes.rb
The Sequel Gem: Everything About Scopes
# (I recommend understanding the basics of this first: http://sequel.jeremyevans.net/rdoc/files/doc/object_model_rdoc.html)
# Extending the underlying dataset (http://sequel.jeremyevans.net/rdoc/files/README_rdoc.html#label-Extending+the+underlying+dataset)
# The recommended way to implement table-wide logic by defining methods on the dataset using dataset_module:
class Post < Sequel::Model
dataset_module do
def posts_with_few_comments
where{num_comments < 30}
DROP TABLE if exists d_date;
CREATE TABLE d_date
(
date_dim_id INT NOT NULL,
date_actual DATE NOT NULL,
epoch BIGINT NOT NULL,
day_suffix VARCHAR(4) NOT NULL,
day_name VARCHAR(9) NOT NULL,
day_of_week INT NOT NULL,
@srpouyet
srpouyet / RubyNext.tmLanguage
Last active December 6, 2017 22:51 — forked from edubkendo/RubyNext.tmLanguage
A better ruby syntax highlighter for sublime text. Combines the ruby bundle with ST, recent updates to the textmate bundle, and a tmLanguage file called "Experimental Ruby".
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>
TODO: unresolved issues
text:

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
# db/migrate/20131118172653_create_transactional_items_view.rb
class CreateTransactionalItemsView < ActiveRecord::Migration
def up
select_sql = File.open("#{Rails.root}/db/migrate/20131118172653_create_transactional_items_view.sql", 'r') { |f| f.read }
# for materialized view:
view_sql = "CREATE MATERIALIZED VIEW transactional_items AS (#{select_sql})"
# for normal view:
view_sql = "CREATE VIEW transactional_items AS (#{select_sql})"
# Outputs this at warn log level:
# 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]}
#
# Save as config/initializers/oneline_detailed_logging.rb. Consider
# decreasing the log level from "info" to "warn" (in production.rb) so
# the one-line log message replaces the standard request logs.
# override process_action to add 2 things to the payload:
# - remote IP
# include from an initializer
module HstoreAccessor
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def hstore_accessor(hstore_attribute, *keys)
Array(keys).flatten.each do |key|
@srpouyet
srpouyet / fix-nokogiri-libxml-warnings-mountain-lion.markdown
Last active December 14, 2015 14:18 — forked from devpuppy/nokogiri libxml homebrew lion
Get rid of those pesky "WARNING: Nokogiri was built against LibXML version X, but has dynamically loaded Z" warnings on Mac OS X (Mountain) Lion.

How to get rid of those pesky
WARNING: Nokogiri was built against LibXML version X, but has dynamically loaded Z
warnings on Mac OS X (Mountain) Lion:

  1. gem uninstall nokogiri libxml-ruby
    Continue to step 5 if you already recently brewed libxml2 and libxslt...
  2. brew update
  3. brew install libxml2 --with-xml2-config
  4. brew install libxslt
  5. gem install nokogiri -- --with-xml2-include=/usr/local/opt/libxml2/include --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xslt-dir=/usr/local/opt/libxslt

h1. Sublime Text 2 - Useful Shortcuts (Mac OS X)

h2. General

  • ⌘T go to file
  • ⌘⌃P go to project
  • ⌘R go to methods
  • ⌃G go to line
  • ⌘KB toggle side bar
  • ⌘⇧P command prompt
@srpouyet
srpouyet / .bash_login
Created November 1, 2012 13:52 — forked from jasoncodes/gist:1223731
Installing Ruby 1.9.3 with rbenv
# ~/.bash_login
export PATH="/usr/local/bin:$PATH"