Skip to content

Instantly share code, notes, and snippets.

View jarednorman's full-sized avatar
☹️
not actually grumpy

Jared Norman jarednorman

☹️
not actually grumpy
View GitHub Profile
jdjkelly> uh
jdjkelly> did anyone bring the buttfor?
mnote> *what's a buttfor*?
mnote> :)
jdjkelly> for pooping, silly
@jarednorman
jarednorman / roda-middleman.markdown
Created February 22, 2016 08:02
Roda to Middleman in 1 Easy Step

Roda to Middleman in 1 Easy Step

In an experiment to try to squeeze as many unicorns as I could out of a single dyno on Heroku, I built a version of this website on top of Roda, a thin routing layer for Rack.

It was successful experiment, between freezing about every object I could find, and a lot of other various tweaking, I had an app that provided me the convenicence of the workflow/tools I'm used to (code-reloading, Sprockets,

@jarednorman
jarednorman / setting-up-lua.markdown
Created February 22, 2016 08:07
Setting up a Lua/C Application

Setting up a Lua/C Application

My first exposure to Lua was in highschool. When I started seriously programming in tenth grade, it was in C (though I'd had some exposure to C++ as early as elementary school.) Being a nerdy teenager, all I wanted to do was make games, and I quickly discovered that doing everything in pure C had some downsides, and that embedding a scripting language within your application was commonplace for reasons that I have no intention of explaining here. I assume you already want to embed Lua in your C application, else why would you be reading this.

@jarednorman
jarednorman / teamocil-rails.markdown
Created February 22, 2016 08:08
Teamocil Makes Your Life Better: Rails Edition

Teamocil Makes Your Life Better: Rails Edition

I've never worked for a product company, and I have lots of personal projects. Because of this, I find myself jumping between different projects constantly. I manage this by keeping up to date Teamocil profiles for each project I work on, and using a development tools that fit completely inside of a tmux session (with the exception of my web browser, of course.)

There are lots of kinds of projects where your tools can't all run inside of

@jarednorman
jarednorman / react-phantomjs.markdown
Created February 22, 2016 08:05
Running React on PhantomJS

Running React on PhantomJS

I ran into an issue getting a simple Capybara/Poltergeist feature test suite running against a site that used React.js. The following failure was bubbling up to RSpec.

Failures:
@jarednorman
jarednorman / webpack-rails-2.markdown
Last active February 19, 2017 20:48
Webpack with Rails Part 2: Precompile Harder

Webpack with Rails Part 2: Precompile Harder

Note: This article is more generally about how to add dependencies to a Rake task, and why you might want to do that.

If you followed my previous article on webpack and Rails, you might have built yourself a trendy little React app. Then you tried to deploy it, and that didn't work, did it?

@jarednorman
jarednorman / webpack-rails-3.markdown
Created February 22, 2016 08:16
Webpack with Rails Part 3: Rake vs RSpec

Webpack with Rails Part 3: Rake vs RSpec

In part 2 we set up a Rake task to run webpack, ensuring that most deploy systems would build our entries for us.

I missed that we needed the webpack Rake task to be run before feature tests too. Without this, we need to run the task manually before running our test suite to avoid erroneous failures due to the assets not being up to date. Running Rake tasks from anywhere in your application in relatively easy, but we

Keybase proof

I hereby claim:

  • I am jarednorman on github.
  • I am creepywizard (https://keybase.io/creepywizard) on keybase.
  • I have a public key ASDrvCBc_NJVOP2fq5tqB-E9BN7ZtNAlWHZy5gnMbqORsAo

To claim this, I am signing this object:

@jarednorman
jarednorman / fzfgem.vim
Last active May 6, 2018 21:27
Search for a gem in the current project, and then search for (and open) a file within it (from Vim, requires fzf.vim)
" Gem search
function! GemSearch()
call fzf#run(fzf#wrap({'source': "bundle list | sed '1d;$d' | cut -d ' ' -f 4", 'sink': {gem -> GemFileSearch(gem)}}))
endfunction
function! GemFileSearch(gem)
let gemdir = substitute(system("bundle show " . a:gem), '\n\+$', '', '')
call fzf#run(fzf#wrap({'source': 'rg --files ' . gemdir . ' --color never | sed -e "s#^' . gemdir . '/##"', 'dir': gemdir}))
endfunction
@jarednorman
jarednorman / player.rb
Created July 1, 2018 00:39
The Elo handling from PorkChop, without the other stuff in the model. (Original source: https://github.com/PorkChopClub/porkchop/blob/master/app/models/player.rb)
class Player < ActiveRecord::Base
BASE_ELO = 1000
has_many :elo_ratings
after_save :record_rating
attr_writer :elo
def elo
elo_ratings.most_recent_rating || BASE_ELO
end