Skip to content

Instantly share code, notes, and snippets.

@ziyan-junaideen
ziyan-junaideen / install-postgresql-9.6-in-ubuntu-16.04.md
Created February 21, 2017 06:33
How to install PostgreSQL 9.6 in Ubuntu 16.04

Background

I believe Ubuntu 16.04 comes with PostgreSQL 9.5. Thats good for a start, but it is a matter of time before you have the need of a PostgreSQL 9.6 cluster. For me it was to import a PG backup from Heroku.

The procedure couldn't have been any easier and is described below. If you are interested in upgrading your old cluster to 9.6 afterwards, you may be interested in this.

Instructions

@schneems
schneems / command-line-only-objectspace-trace.sh
Last active December 19, 2022 13:54
trace where Ruby objects come from with this handy bash 3 liner
echo 'require "objspace"; ObjectSpace.trace_object_allocations_start; Kernel.send(:define_method, :sup) do |obj| ; puts "#{ ObjectSpace.allocation_sourcefile(obj) }:#{ ObjectSpace.allocation_sourceline(obj) }"; end' > tmp/tmp-gemfile
cat Gemfile >> tmp/tmp-gemfile
cat tmp/tmp-gemfile > Gemfile
# $ bundle exec irb
# irb(main):001:0> require 'rails'
# => true
# irb(main):002:0> sup(Rails)
# /Users/richardschneeman/.gem/ruby/2.4.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:3
@skanev
skanev / rubocop.rb
Last active March 13, 2024 08:24
A Rubocop wrapper that checks only added/modified code
#!/usr/bin/env ruby
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
#
# Here are some options you can pass in addition to the ones in rubocop:
#
@leewaa
leewaa / rubymotion-specs.md
Created May 21, 2014 08:40
A small post about how I had been using rspec for rubymotion incorrectly and how it works properly.

Rubymotion notes

Testing

This line should be added to the app delegate didLaunchWithOptions method

class AppDelegate
  def application(application, didFinishLaunchingWithOptions:launchOptions)
 return true if RUBYMOTION_ENV == 'test'
@Kartones
Kartones / postgres-cheatsheet.md
Last active April 25, 2024 16:50
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@skmetz
skmetz / gilded_rose_test.rb
Last active May 30, 2017 18:42
Gilded Rose Test
# This simplest thing is to clone Jim's repo (https://github.com/jimweirich/gilded_rose_kata) and then
# put this file in the root directory.
gem 'minitest', '~> 4.7'
require "minitest/autorun"
require "minitest/reporters"
MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new
require_relative './gilded_rose'
@artem-mindrov
artem-mindrov / tags_controller.rb
Last active December 15, 2015 10:49
Helper for testing jquery tokeninput with Selenium & Capybara
class TagsController < ApplicationController
before_filter :authenticate_user!
respond_to :json
def index
q = params[:tag]
if q =~ %r{,|;}
q.gsub!(%r{(,|;).*}, "")
ActsAsTaggableOn::Tag.find_or_create_by_name(q)