-
First, configure Shrine. I'll leave this exercise to the reader as it's very dependent on how you'll be storing your files (on a server, on S3, etc.)
-
Define an alternate attachment module (instead of the ActiveStorage or Paperclip one):
module ShrineImageAttachment extend ActiveSupport::Concern included do # FIXME: Use whatever store you have defined that you want to use for product images. To avoid caching issues, I recommend using some kind of public store.
module OpenGraph | |
class << self | |
def fetch_data(url) | |
html = Nokogiri::HTML(body(url)) | |
{ | |
title: find_meta("og:title", html) || html.title.presence, | |
description: find_meta("og:description", html), | |
image: find_meta("og:image", html), | |
site_name: find_meta("og:site_name", html) |
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 |
" 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 |
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:
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
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?
I don't like Sprockets, but it's the easiest and best choice for lots of Ruby on Rails projects. When looking for a better way to manage my JavaScript assets and an improved developer story, my current tool of choice is webpack. While I wish Rails supported drop-in asset pipelines the way that Phoenix does, it's not hard to use webpack with Rails.
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
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.