Skip to content

Instantly share code, notes, and snippets.

View dacook's full-sized avatar

David Cook dacook

  • Melbourne, Australia
View GitHub Profile
@dacook
dacook / duration-cheat-sheet.md
Created March 16, 2022 00:32
Rails Duration cheat sheet

I constantly find it hard to know how to express a duration, but once I figure it out, it's abundantly clear. So here's some helpful examples.

There are multiple methods that do the same thing, to help you express the intent the way that makes sense to you.

Past: ago/before/until

1.week.ago           # same as Time.current - 1.week
1.week.before(@date) # same as @date - 1.week

I can't think of a use for until

@dacook
dacook / .gitignore
Last active January 29, 2021 02:51 — forked from Jammizzle/export_multi_repo_issues_to_csv.py
Export Issues from Github repo to CSV (API v3 and ZenHub API)
config.ini
*.csv
bundle

ERROR :(

ERROR:  Error installing mysql2:
  ERROR: Failed to build gem native extension.

eg:

##
# Creates an alias called "git hist" that outputs a nicely formatted git log.
# Usage is just like "git log"
# Examples:
# git hist
# git hist -5
# git hist <branch_name>
# git hist <tag_name> -10
##
git config --global alias.hist "log --pretty=format:'%C(yellow)%ad%C(reset) %C(green)%h%C(reset) %C(red)%an%C(reset): %s %C(blue)%d%C(reset)' --graph --date=short"
[
{
"args": {
"setting": "tab_size",
"value": 4
},
"command": "set_setting"
},
{
"args":
@dacook
dacook / gist:9b08a34fb65cfe9c0b04
Last active August 29, 2015 14:01
Behaviours that I think should be standard on all web pages

which are not done by browsers by default. Therefore this list is a potential guide for a boilerplate JS/CSS. TODO: expand into a better format, with examples and reasoning behind each item.

Important

  1. Highlight elements that have been scrolled into view by the URL hash (eg #my-anchor) example
  2. All headings or sections should be linkable anchors (eg #my-heading). This might need a bit more defining.
  3. Any linkable anchors should indicate they're linkable with a hover state, and should be easy to copy the link. example
  4. Disable internal links with no target (ie href="#" -> on click{e.preventDefault()})

Less important

@dacook
dacook / fusionTablesQuery
Created January 15, 2014 01:32
Simple Javascript function to test a google.maps.FusionTablesQuery object, with JSON response. More improvements can be made..
/*
* fusionTablesQuery()
*
* Query a Fusion Table with JSON response.
*
* Parameters:
* @query: google.maps.FusionTablesQuery (only some options implemented so far) (ref: https://developers.google.com/maps/documentation/javascript/reference#FusionTablesQuery)
* @callback: function(jsonResult)
*
@dacook
dacook / database.yml
Last active December 20, 2015 03:59 — forked from hatboysam/database.yml
development:
adapter: postgresql
database: development
username: <%= ENV['PG_USER'] %>
password: <%= ENV['PG_PASS'] %>
host: localhost