Skip to content

Instantly share code, notes, and snippets.

View gabrieljoelc's full-sized avatar

Gabriel Chaney gabrieljoelc

View GitHub Profile
public class ListPostsQuery
{
private readonly IDocumentSession session;
public ListPostsQuery(IDocumentSession session)
{
this.session = session;
}
public List<Post> Execute(int currentPage, int defaultPage, int pageSize, out RavenQueryStatistics stats)
@lucasdinonolte
lucasdinonolte / gist:4016361
Created November 5, 2012 09:45
Copy current git branch to clipboard
git branch | grep "*" | awk '{ print $2 }' | pbcopy
@willnet
willnet / gist:4128828
Created November 22, 2012 01:05
attributes custom matcher for minitest
# -*- coding: utf-8 -*-
class EqualAttributesMatcher
def initialize(attrs)
@attrs = attrs
end
def matches?(model)
@model = model
@attrs.all? { |k,v| @model.send(k) == v }
end
[AutoMap(typeof(ViewModel)]
public ActionResult View(int id)
{
var entity = LoadFromDatabase(id);
return View(entity);
}
@kljensen
kljensen / vj.sh
Last active November 14, 2018 17:37
A simple, encrypted journal using vim.
#!/usr/bin/env bash
##########################################################
#
# This is a shell script for keeping a journal that is
# * plaintext,
# * time-stamped,
# * encrypted, and
# * edited with vim.
#
@ryansobol
ryansobol / gist:5252653
Last active February 23, 2025 06:28
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@lmaccherone
lmaccherone / Working-with-Dates-Times-and-Timezones-Top-10-Tips-for-Developers.markdown
Last active May 29, 2018 23:15
What's the correct query clause to get all the transactions from March on the east coast of the US? The correct answer is `"2012-03-01T05" <= eventTimestamp < "2012-04-01T04"`. Notice how the timeshift for the beginning of March is different from the end. Getting this right is mind bendingly difficult. This blog post and the Lumenize/tzTime libr…

Working with Dates, Times, and Timezones

Top 10 recommendations for developers

Update: tzTime (documentation) is now available seperately from Lumenize. The examples below still work because tzTime is a dependency of Lumenize and included in that package (as well as Rally's App SDK v2.0p6 or greater). However, Lumenize includes a lot more functionality around time-series and temporal model aggregations, OLAP Cube, etc. If you just want the Time object, just grab tzTime.

What's the correct query clause to get all the transactions from March? The naive answer is "2012-03-01" &lt;= eventTimestamp &lt;= "2012-03-31" but what if the person worked in the eastern US and wanted timezone taken into account? Then the correct answer is "2012-03-01T05" &lt;= eventTimestamp &lt; "2012-04-01T04". Notice how the timeshift for the beginning of March is different from the end. Getting this right is mind bendingly di

@atenni
atenni / README.md
Last active May 5, 2025 08:06
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

@jboesch
jboesch / pg_import_csv_to_heroku.sh
Last active April 5, 2022 22:11
Importing a CSV dump of Postgres data into Heroku
# You have your csv data and it looks like so... It's in a file named "my_data.csv" and we want to import it into a table named "my_things".
"1", "Something", "0.50", "2013-05-05 10:00:00"
"2", "Another thing", "1.50", "2013-06-05 10:30:00"
# Now you want to import it, go to the command line and type:
$ PGPASSWORD=PWHERE psql -h HOSTHERE -U USERHERE DBNAMEHERE -c "\copy my_things FROM 'my_data.csv' WITH CSV;"
# Voila! It's impoted. Now if you want to wipe it out and import a fresh one, you would do this:
@maxim
maxim / rails_load_path_tips.md
Last active January 9, 2025 00:59
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/