Skip to content

Instantly share code, notes, and snippets.

View adkron's full-sized avatar

Amos King adkron

View GitHub Profile
@adkron
adkron / embeded_fields.js
Created October 26, 2010 01:53
mongodb document
{ "_id" : ObjectId("4cc624373437595e787c1d0e"), "attrs" : [
{
"name" : "First Name",
"value" : "Amos",
public : false
},
{
"name" : "age",
"value" : 29,
"public" : true
class Connection
include Mongoid::Document
references_one :originating_user, :inverse_of => :my_connections, :class_name => "User"
references_one :destination_user, :inverse_of => :other_connections, :class_name => "User"
end
@adkron
adkron / class_vs_style.html
Created November 5, 2010 02:28
A simple test for seeing if it is faster to change a style or a class of an element.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css" media="screen">
.hidden {
display:none;
}
</style>
</head>
<body>
require 'spec_helper'
require 'benchmark'
describe 'performance tracking for accessing sitewide information' do
include Mongo
describe 'sitewide privacy settings maintained in an user info attribute collection' do
before(:all) do
db = Connection.new.db('user-acl-specs')
@users = db.collection('users')
@adkron
adkron / explain.txt
Created December 16, 2010 20:02
The only user in the collection
Getting more duplicates
@adkron
adkron / problem.js
Created February 20, 2011 01:09
Remove all of one field from an array of fields in an entire collection
/*
I want to remove all the bool fields(inside the props array) from the following collection.
*/
//Initial state of collection
db.foos.find();
//#=>
{ "_id" : ObjectId("4d60699c768262073556634f"), "props" : [
{
"bool" : true,
"name" : "bob"
@adkron
adkron / broken_spec.rb
Created April 26, 2011 17:57
can not run focused specs
shared_examples_for 'example' do
it 'should pass' do
true.should == true
end
end
describe 'a new example' do
it_should_behave_like 'example'
it 'should fail' do
@adkron
adkron / blocks.rb
Created October 25, 2011 02:06
Ruby Blocks
# This passes the block to second_method
one_method second_method {...}
# This passes the block to one_method
one_method second_method do ... end
@adkron
adkron / carousel.rb
Created September 19, 2012 03:46
Looking for feedback on trial run of tell don't ask
@adkron
adkron / developer_levels.md
Last active September 21, 2016 20:51
What makes a certain level of developer?

Entry

  • Passion
    • Wants to learn
    • Eager to learn
  • Aptitude
    • Can learn a new language with little help
  • Understands basics to a Language
  • Language comprehension