Skip to content

Instantly share code, notes, and snippets.

@JoshTGreenwood
JoshTGreenwood / testdouble.rb
Created Oct 18, 2016
the beginning of what testdouble.rb might look like
View testdouble.rb
class TestDouble
attr_accessor :instance, :when_stack
def initialize(instance)
@instance = instance
@when_stack = []
end
def when(&block)
fake_method_call = FakeMethodCall.new(block)
@JoshTGreenwood
JoshTGreenwood / ar_merge.md
Created Mar 24, 2016
Active Record Merge
View ar_merge.md

TIL #merge is a thing on AR models.

Useful for joining + using a named scoped on the joined table:

class Post; end
class Comment; scope :approved, -> {approved: true}; end
Post.joins(:comments).merge(Comment.approved)
@JoshTGreenwood
JoshTGreenwood / gist:443253f42fb80455792f
Created Dec 1, 2015
Automatically add magit cloned repos to the projectile project list
View gist:443253f42fb80455792f
(defun add-project-to-projectile-known-projects (_ directory)
(projectile-add-known-project directory))
(advice-add 'magit-clone :after 'add-project-to-projectile-known-projects)
View .spacemacs.el
;; -*- mode: dotspacemacs -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration."
(setq-default
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (ie. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()
@JoshTGreenwood
JoshTGreenwood / .spacemacs
Created May 30, 2015
Spacemacs not starting correctly
View .spacemacs
;; -*- mode: dotspacemacs -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration."
(setq-default
;; List of additional paths where to look for configuration layers.
;; Paths must have a trailing slash (ie. `~/.mycontribs/')
dotspacemacs-configuration-layer-path '()
@JoshTGreenwood
JoshTGreenwood / Part 1
Created Sep 15, 2014
Microcomputer Design Lab 1
View Part 1
OPT MEX expand macro calling
OPT SEX expand structured statements
CODE EQU 0 define code and text sections
TEXT EQU 1
CR EQU $0D define CR and LF
LF EQU $0A
SECTION TEXT
ORG $800 sets the address for text code
@JoshTGreenwood
JoshTGreenwood / gist:27e81638428225e2bc0f
Created Jun 20, 2014
Assembly Code to search for a value in memory
View gist:27e81638428225e2bc0f
/*
* midterm.asm
*
* Created: 6/20/2014 11:41:46 AM
* Author: Josh
*/
.org 0x0
ldi r29,0x00
ldi r30,0x10
@JoshTGreenwood
JoshTGreenwood / gist:cab6f61e6160579ea10f
Created Jun 20, 2014
Assembly Code To Read In From Ports
View gist:cab6f61e6160579ea10f
/*
* midterm.asm
*
* Created: 6/20/2014 11:41:46 AM
* Author: Josh
*/
.org 0x0
ldi r30,0x00
ldi r31,0x10
View part_2.txt
.dseg
.org 0x2000
output: .byte 1 ; insert comment
.cseg
.org 0x0
jmp main ; partial vector table at address 0x0
.org 0x200 ; main entry point at address 0x200 (step though the code)
main: ldi ZL,low(2*table) ; insert comment
ldi ZH,high(2*table) ; insert comment
ldi r16,celsius ; insert comment
@JoshTGreenwood
JoshTGreenwood / _flash_messages.html.erb
Last active Jan 1, 2016 — forked from roberto/_flash_messages.html.erb
Flash messages for Bootstrap 3.
View _flash_messages.html.erb
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
You can’t perform that action at this time.