Skip to content

Instantly share code, notes, and snippets.

Janko Marohnić janko

Block or report user

Report or block janko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:6819142
Date: Thu, 3 Oct 2013 17:16:51 -0700
From: Gary Bernhardt <>
Subject: Mailing practices
I suspect that you guys know this, but just in case: your emailing
practices have been resulting in... less than good impressions among the
people you aim to recruit. Here are some tweets, none of which were
written by me:
jordwalke / gist:6350319
Last active Sep 10, 2016
ReactJS: JavaScript just like you've always done it.
View gist:6350319
* ReactJS: JavaScript like you've always done it.
* This example renders your top ten most followed friends/followers, `filter`ing
* only your favorites, and putting a star on all verified accounts.
* With ReactJS, any time your data changes, the UI is always brought up to date
* automatically. If friends length changes, or followCount - it always shows what
* `render` describes.
mislav /
Last active Dec 19, 2015
Test-drive the new vim 7.4 prerelease
cd /tmp
wget -O- | tar -xj
cd vim74a
sudo mkdir -p /opt/vim
sudo chown $USER /opt/vim
PATH=/usr/bin:/usr/sbin:/bin:/sbin ./configure --prefix=/opt/vim --enable-rubyinterp | grep ruby
make && make install
steveklabnik /
Last active Dec 19, 2015
Gems that may not be rails 4 compatible
tenderlove / terrible.rb
Last active May 31, 2016
I am a terrible person
View terrible.rb
require 'fiddle'
module IAmAHorriblePerson
def unset flag
value = _wrap self
flags = { |i| value[i] }.pack('C8').unpack('Q').first
[flags & ~flag].pack('Q').unpack('C8').each_with_index { |n,i|value[i] = n }
def class= k
cobyism /
Last active Jan 27, 2020
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

myronmarston /
Last active Dec 14, 2018
Explanation for why `its` will be removed from rspec-3

its isn't core to RSpec. One the of the focuses of RSpec is on the documentation aspects of tests. Unfortunately, its often leads to documentation output that is essentially lies. Consider this spec:

User =, :email)

describe User do
  subject {"bob") }
  its(:name) { should == "bob" }
rgreenjr / postgres_queries_and_commands.sql
Last active Jan 28, 2020
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
cpjolicoeur / gist:3590737
Created Sep 1, 2012
Ordering a query result set by an arbitrary list in PostgreSQL
View gist:3590737

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri

You can’t perform that action at this time.