Skip to content

Instantly share code, notes, and snippets.

View jimsynz's full-sized avatar
💜

James Harton jimsynz

💜
View GitHub Profile
module Runtime
class Reference
attr_reader :object, :weight
def initialize(object, weight)
@object = object
@weight = weight
end
def self.create(object)
class Api::SessionsController < ApiController
def create
token = ApiToken.new(params[:api_token])
if params[:username] && params[:password]
user = User.find_by_username(params[:username])
if _user_is_authentic?
token.user = user
else
@jimsynz
jimsynz / po.sh
Created May 17, 2017 01:02
Try and guess where to push branches to based on convention.
#!/bin/bash
# This script tries to handle `git push` when the local branch isn't
# configured to track a remote branch.
#
# First, if the branch already tracks a remote branch then it just calls
# `git push` and we're done.
#
# Second, if the branch doesn't track a remote branch and there is a
# remote called "origin" present then it just makes an assumption and
require "rubygems"
require "colorize"
def desc(msg)
puts "Description".colorize(:yellow)
puts "===========".colorize(:yellow)
puts msg.colorize(:white)
end
def example(body)
Heap.User = DS.Model.extend
heaplogs: DS.hasMany('Heap.Heaplog')
name: DS.attr 'string'
nickname: DS.attr 'string'
location: DS.attr 'string'
image: DS.attr 'string'
description: DS.attr 'string'
extra_url: DS.attr 'string'
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
@jimsynz
jimsynz / gist:8679147
Created January 29, 2014 00:04
lame arguments I use to create dopodcast mp3s.
lame -V 6 --tt 'Do Podcast: Show 4, Ruby 2.1' --tg 0xc --ta 'Do Podcast' --ty 2013 --tc 'http://dopodcast.org' --ti '~/Dev/dopodcast/dopocast.github.io/source/images/ruby-latte-rss.jpg' 'Do Podcast - Show 4.wav' show_4_ruby21.mp3
@jimsynz
jimsynz / dev_log.txt
Last active December 31, 2015 18:49
Super weirdness:
[1] pry(main)> project = Fabricate(:project_with_attachments)
=> #<Project _id: Lo2ekuTh, created_at: 2013-12-18 04:28:41 UTC, updated_at: 2013-12-18 04:28:41 UTC, design: "design.brd", top_image: "i.png", bottom_image: "i.png", user_id: nil, upload_id: nil, license_id: nil, parent_project_id: nil, name: "Aliquam molestias id.", description: "Vel accusamus reiciendis officia voluptate.\nSed nihil sequi.", short_description: nil, notes: nil, version: nil, state: "CREATING", price: "3.9", email: "louvenia@gmail.com", width_in_mils: 1024, height_in_mils: 768, pcb_layers: 2, shared_at: nil, share_setup_state: nil>
[2] pry(main)> project.layers.size
=> 8
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (1.3313ms)
MOPED: 127.0.0.1:27017 INSERT database=playground_development collection=projects documents=[{"state"=>"CREATING", "price"=>"3.9", "width_in_mils"=>1024, "height_in_mils"=>768, "pcb_layers"=>2, "name"=>"Aliquam molestias id.", "description"=>"Vel accusamus reiciendis of
@jimsynz
jimsynz / 1_source.rb
Last active December 30, 2015 16:09
Surprised that you can't just ram a `rescue` or `ensure` inside a block without an enclosing `begin`.
puts "Trying Ruby #{RUBY_DESCRIPTION}"
eval <<-'EOF'
proc do
puts "hello"
rescue Exception => e
puts "Exception #{e}"
ensure
puts "goodbye"
end
require 'spec_helper'
describe WidgetController do
subject { query; response }
describe '#index' do
let(:query) { get :index, format: :json }
context "when there are widgets available" do
before { Fabricate(:available_widget) }