Skip to content

Instantly share code, notes, and snippets.

View brundage's full-sized avatar
🚲
Unscrambling eggs

Dean Brundage brundage

🚲
Unscrambling eggs
View GitHub Profile
/*
* ATTINY85 Sleep Example
* by kevinwatts
*
* Commenting added by Dustin Westaby
*/
#include <avr/sleep.h>
#inlcude <avr/io.h>
@brundage
brundage / gist:1e6734b3d5bae98676ce
Last active November 18, 2016 05:33 — forked from unnitallman/gist:944011
sqlite with activerecord outside rails
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = false
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => ":memory:"
)
@brundage
brundage / gist:5653017
Last active December 17, 2015 18:28
Linux kernel .config file for my gentoo UltraSPARC 25 workstation
#
# Automatically generated file; DO NOT EDIT.
# Linux/sparc64 3.5.7-gentoo Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_SPARC=y
# CONFIG_SPARC32 is not set
CONFIG_SPARC64=y
CONFIG_ARCH_DEFCONFIG="arch/sparc/configs/sparc64_defconfig"
CONFIG_BITS=64
@brundage
brundage / database.yml
Created November 16, 2012 22:05
Use sqlite in-memory database for rspec testing
test:
adapter: sqlite3
encoding: utf8
pool: 5
timeout: 5000
database: ":memory:"
verbosity: quiet
@brundage
brundage / nil_returning_coder.rb
Created October 10, 2012 18:35
Nil Returning ActiveRecord::Coders::YAMLColumn
require 'active_record/coders/yaml_column'
require 'active_support'
require 'yaml'
# This module defines an YAMLColumn coder that returns
# nil instead of a blank object. Useful when the class you are serializing
# to/from does not allow uninitialized objects (such as a unit measurement)
#
# See more: http://blog.deanbrundage.com/2012/10/rails-serialization-of-nil-values/
#
module NilReturningCoder
@brundage
brundage / gist:3831662
Created October 4, 2012 05:38
Facebook get mentions (tagged)
require 'koala'
me = Koala::Facebook::API.new 'AAAC...' # get this from https://developers.facebook.com/tools/explorer - get user_status,manage_pages permissions
pages = me.get_connections('me', 'accounts')
# Find your page's access token
nrb = Koala::Facebook::API.new 'AAAC...' # see acting as a page https://github.com/arsduo/koala/wiki/Acting-as-a-Page
feed = nrb.get_connection('me', 'tagged')
@brundage
brundage / gist:2951192
Created June 18, 2012 22:35
Replaces ActiveModel::Serializers with ActiveModel::Serializer
module JsonSerializationUnifier
# ActiveModel::Serializer only works in the controller's render method
# This modue replaces ActiveModel::Serializers with ActiveModel::Serializer
# yup, a little confusing. Include in in your model classes so to_json and
# as_json work as expected in the console and elsewhere.
extend ActiveSupport::Concern
def as_json(value=nil, use_options = true)
return active_model_serializer.as_json if active_model_serializer
@brundage
brundage / gist:2944801
Created June 17, 2012 15:16
Demo for ember.js issue
/*
* jsFiddle demo: http://bit.ly/NHVuBF
*
* Using ember.js built on 2012-06-17
* from commit 1b0a2339184a9d583270eca84ee10056b269858c
*
* The following code produces an exception
*
* assertion failed: You need to provide an object and key to `set`.
*
http://i.imgur.com/IhEFF.png
>>> var c = App.store.find(App.Citizen, 2);
{"citizen":{"biography":"Voter McVoter has nothing to say about herself","birth_date":null,"city":null,"country":null,"created_at":"2012-05-20T18:42:16Z","email":null,"first_name":"Voter","gender":"female","id":2,"invitation_id":2,"last_name":"McVoter","motto":null,"photo_content_type":null,"photo_file_name":null,"photo_file_size":null,"photo_updated_at":null,"region_state":null,"updated_at":"2012-05-20T18:42:16Z","zip":null}}
assertion failed: A data hash was loaded for a model of type App.Citizen but no primary key 'undefined' was provided.
deprecate(message="ember_assert is depreca...e Ember.assert instead.", test=false)ember.js?body=1 (line 94)
deprecateFunc()ember.js?body=1 (line 136)
load(type=App.Citizen, id=Object { biography="Voter McVoter has nothing to say about herself", created_at="2012-05-20T18:42:16Z", first_name="Voter", more...}, hash=Object { biography="Voter McVoter has nothing to say about herself", created_at="201