Skip to content

Instantly share code, notes, and snippets.

View elskwid's full-sized avatar
🤡

Don Morrison elskwid

🤡
View GitHub Profile
@jgaskins
jgaskins / ar_model.rb
Created March 28, 2014 01:19
ActiveRecord default attributes
require 'active_record'
require 'pg'
ActiveRecord::Base.establish_connection host: 'localhost',
database: 'jamie',
adapter: 'postgresql'
class ARModel < ActiveRecord::Base
def initialize(attributes={})
# AR::Base#create w/o args passes nil because lol.
@mbj
mbj / input.rb
Last active August 29, 2015 14:02
mutant longest prefix match configuration spike
{"*"=>{"isolation"=>true, "selector"=>"exact"}, "Foo::Bar"=>{"isolation"=>false, "selector"=>"Foo#bar"}}

Keep reading and watching videos, but cut that time down in half and use the rest of the time for exploring codebases and writing code of your own. If you do a code reading exercise, make sure you have the code open in your editor, and that you're able to interact with it via a REPL, its tests, etc.

Then from there, I'd recommend starting with very small, tiny projects. Ideally your first one should be something so simple you can do it in an hour or two.

Gradually work your way up from those tiny projects to slightly bigger ones. So start with one that takes an hour or two, then move up to one that might take 5-10 hours, then one that might take 20 hours, then 40 hours, etc. It's OK to stop at the size where you're feeling you're getting the most learning benefit.

Each time you try a new project, make it realistic if you can, but don't worry too much if you'll actually use it. The value is in having a rich context to try out ideas, not in the actual utility of whatever you build.

For each project you wor

I think you might benefit from a detailed study plan when you're a little further along with your studies. For now, I'd recommend following your interests, and taking a project-based approach towards learning.

Start with an idea of something you might want to build, and then make a list of all the stuff you'd need to learn to build it. Then, strip down the idea to make it a little more simple, and redo the list. Keep doing that until you have a list that's small enough to manage

Fair warning: full-scale applications tend to look like "first invent the whole world, then build your app", so you may need to come up with really simple ideas to start on. That's OK! You may also not know what you need to know until you try building things, that's OK too.

Once you have a few ideas, start reading and watching videos related to the technical tools and concepts you need. But only go just as deep into those resources as you need in order to build one small piece of a real project... you can always come back later i

@solnic
solnic / comp_relations.rb
Last active August 29, 2015 14:15
[ROM] composable relations with partial application prototype
require 'rom'
require 'rspec'
module ROM
class Relation
class Composite
attr_reader :left, :right
def initialize(left, right)
@left = left
@mcmire
mcmire / date_time_formats.md
Created October 28, 2011 18:57
Formatting dates/times in Rails 3 vs Rails 2

In Rails 2, if you wanted to define a named date/time format, the conventional way was to make an initializer which would modify the DATE_FORMATS hash that ActiveSupport mixed into Date and Time:

# config/initializers/date_and_time_formats.rb
def military_hour_to_civil_hour(hour)
  mod = (hour % 12)
  mod + (12 * (mod > 0 ? 0 : 1))
end

Date::DATE_FORMATS[:std] = lambda {|d| "#{d.month}/#{d.day}/#{d.year}" }
@ahoward
ahoward / a.rb
Created July 26, 2012 22:21
thread pipe
require 'thread'
class Thread
class Pipe
class Queue < ::Queue
attr_accessor :thread_id
end
def initialize
@queues = [Queue.new, Queue.new]
@mislav
mislav / gist:3313773
Created August 10, 2012 11:55
hosting one's own email

I want to get off Gmail for two reasons:

  1. my own *@mislav.net address
  2. to get my email under my own control so I can write scripts to process/analyze it

I've asked on Twitter what software should I use.
Here are the aggregated suggestions.

SMTP

@supernullset
supernullset / levenshtein_ranking.coffee
Created October 17, 2012 19:13
Fuzzy string comparison/sort in javascript
curry = (fn)->
slice = Array.prototype.slice
args = slice.apply arguments, [1]
return ->
fn.apply null, args.concat(slice.apply arguments)
levenshteinD = (s,t) ->
if !s.length then return t.length
if !t.length then return s.length
@wesgarrison
wesgarrison / gist:3921560
Created October 20, 2012 01:10
October 19 2012 - rubygems.org - notes on server

[transcript from http://www.youtube.com/watch?v=z73uiWKdJhw and irc]

Why is the server unhappy?

  • Bundle API is 70%-80% of traffic and it has to resolve the dependency graph and Marshal
  • x Processes are spinning in Ruby with 380% (of 400% total CPU [4 x 100%])
  • x Bundle can only use vanilla gems, so that's why we have to use Marshal
  • Redis Heapsize
  • Diskspace

Timing - middle of the day US