Skip to content

Instantly share code, notes, and snippets.

View cdimartino's full-sized avatar

Chris DiMartino cdimartino

View GitHub Profile
@cdimartino
cdimartino / article_submission.json
Created February 3, 2014 18:25
Example JSON blob for an Article (Post) type submission with nested associated image
{
"order_type": null,
"state": "draft",
"title": "This is a title",
"body": null,
"tag_list": "tag1, tag2, tag3",
"cover_image": {
"title": "",
"body": "data:imagegpng;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjExNjREMzcyODEzMzExRTNBODE2QTc4M
@cdimartino
cdimartino / gist:498ed0f1292c37270cde
Created May 5, 2015 14:54
Inheritance/Composition
module DBCLibrary
module Barcodable
attr_reader :location
attr_accessor :barcode
end
end
module DBCLibrary
class BluRay < LibraryItem
include Borrowable, Reservable

Keybase proof

I hereby claim:

  • I am cdimartino on github.
  • I am vwchris (https://keybase.io/vwchris) on keybase.
  • I have a public key whose fingerprint is CCA1 7267 35B9 D7D6 F10E B12C 799B 7E08 2A99 8CA9

To claim this, I am signing this object:

# SF
00 ac:87:a3:02:16:36
01 40:6c:8f:0d:51:35
02 3c:07:54:43:83:01
03 0c:4d:e9:a6:83:70
04 40:6c:8f:0d:4d:f8
05 3c:07:54:43:7d:68
06 68:5b:35:7f:1b:ba
07 3c:07:54:5c:d6:65
08 3c:07:54:43:96:69
controller.rb
class PostsController < ApplicationController
def index
@published_posts = Post.published
@unpublished_posts = Post.unpublished
end
def create
@post = Post.new params[:post]
if @post.save
controller.rb
class PostsController < ApplicationController
def index
@published_posts = Post.published
@unpublished_posts = Post.unpublished
end
def create
@cdimartino
cdimartino / pomodoroscript.scpt
Created July 24, 2012 04:49 — forked from puttiz/pomodoroscript.scpt
Things integrate with Pomodoro
-- End : Marking to-dos completed
tell application "Things"
tell list "Today"
set toDoToComplete to to do named "$pomodoroName"
set status of toDoToComplete to completed
set tag names of toDoToComplete to "⌘,✔"
end tell
move toDoToComplete to list "Next"
end tell
@cdimartino
cdimartino / bdd.vim
Created August 31, 2012 14:33
Run RSpec and Cucumber from vim, on the current spec/feature
" Vim functions to run RSpec and Cucumber on the current file and optionally on
" the spec/scenario under the cursor.
function! RailsScriptIfExists(name)
" Bundle exec
if isdirectory(".bundle") || (exists("b:rails_root") && isdirectory(b:rails_root . "/.bundle"))
return "bundle exec " . a:name
" System Binary
else
return a:name
@cdimartino
cdimartino / gist:3828379
Created October 3, 2012 17:11
Timery Search
<pseudo code>
timer = nil
onkeyup:
canceltimer timer
settimer timer +1s dosearch
</pseudo code>
# Cannot build EventMachine
```
bundle config --global build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
```
# Cannot build pg gem
```
bundle config --global build.pg --with-pg_config= /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config