Skip to content

Instantly share code, notes, and snippets.

View pjho's full-sized avatar

Pat Horsley pjho

  • Wānaka, New Zealand
View GitHub Profile
// monokai
$pink: #ff6188;
$red: $pink;
$green: #a9dc76;
$yellow: #ffd866;
$orange: #fc9867;
$purple: #ab9df2;
$blue: #78dce8;
$black: #2c292d;
$white: #fdf9f3;
@pjho
pjho / Additional.md
Last active September 20, 2017 02:59
Setup Sublime

Add subl command to command line > ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Install

  • Sidebar Enhancements
  • Soda Theme Dark
  • Sass/Scss Syntax
  • Babel Syntax
  • Emmet
@pjho
pjho / csv-to-json.js
Last active August 15, 2017 23:46
Node CSV to JSON
// dependencies
// > yarn add csvtojson
// Usage:
// > node csv-to-json.js input.csv output.json
const fs = require('fs')
const path = require('path')
const csv = require('csvtojson')
@pjho
pjho / Basic Webpack 2 ES6 Build Config
Last active May 16, 2017 08:42
Basic Webpack 2 ES6 Build Config
// .babelrc
{
"presets": ["es2015"]
}
/*
{
"name": "language",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
@pjho
pjho / example.py
Created October 9, 2016 21:08
Wagtail Related Inline Model
from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Page, Orderable
# The Parent/Consuming page
class ExamplePage(Page):
content_panels = Page.content_panels + [
InlinePanel('related_sub_model_label', label="Ui Heading for inline model"),
]
# The abstract class defining the fields. Can be named whatever.
@pjho
pjho / index.md
Last active August 29, 2015 14:21 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

ActiveRecord cheat sheet / EXAMPLES
INSTALL
=======
$ gem install activerecord
in GEMFILE: gem ‘activerecord’
REQUIRE
=======
require ‘active_record’
@pjho
pjho / gist:bccdb3aa38f2e112499c
Created October 8, 2014 19:53
Rails - Convert Seconds to readable time - time_spent_in_words
# Source: http://snipplr.com/view/73984/human-readable-time-from-seconds-helper/
def time_spent_in_words seconds, params={}
time_periods_shown = params[:time_periods_shown] || 3
use_short_names = params[:use_short_names] || false
return "0 seconds" if seconds < 1
short_name = {:second => :sec, :minute => :min, :hour => :hr, :day => :day, :week => :wk, :year => :yr}
[[60, :second], [60, :minute], [24, :hour], [7, :day], [52, :week], [1000, :year]].map{ |count, name|
if seconds > 0