Skip to content

Instantly share code, notes, and snippets.

View ahoward's full-sized avatar
💭
probably outside if i'm not hacking.

ara.t.howard ahoward

💭
probably outside if i'm not hacking.
View GitHub Profile
@ahoward
ahoward / a.rb
Last active December 2, 2016 17:09
skip bower / bower_components during 'rails assets:precompile'
config = Rails.application.config
default_precompile = config.assets.precompile
config.assets.precompile = [
proc do |path|
if path =~ /bower_components/
false
else
default_precompile.call(path)
require 'tmpdir'
require 'securerandom'
class Assassin
def Assassin.ate(*args, &block)
new(*args, &block)
end
attr_accessor :parent_pid
attr_accessor :child_pid
# when you really, really, really want to make sure your children get cleaned up you can generate a script
# that detaches and monitors *you*. if you disappear the assassin can ensure cleanup happens. even if
# you are 'kill -9d' or call 'exit!'
assassin = <<-__
pid = #{ Process.pid }
4242.times do
begin
Process.kill(0, pid)
@ahoward
ahoward / a.rb
Created September 20, 2016 22:56
# encoding: utf-8
#
companies = Company.where(:locale => 'ko')
domains = Domain.where(:company_id.in => companies.map(&:id))
domains.destroy_all
companies.destroy_all
@ahoward
ahoward / a.html
Created September 15, 2016 16:46
<!--
using ids is effectively just like using a GOTO statement in code - it pins
logic to jump to a pre-labeled and identified spot by unique label/id. this
lets you avoid needing to make a good design.
-->
@ahoward
ahoward / a.rb
Created September 13, 2016 22:17
# mongoid style
#
module A
end
class B
include A
end
#
if ENV['DATO_DUMP']
command = "./bin/rake dato:dump"
STDOUT.puts command
unless system(command)
abort "command (#{ command }) failed with (#{ $? })"
end
end
@ahoward
ahoward / a.rb
Created September 7, 2016 15:17
#
require 'fileutils'
require 'dato'
require 'map'
require 'coerce'
require 'pry'
#
token = ARGV.shift
@ahoward
ahoward / a.rb
Last active May 15, 2016 11:45
# Util.bcall(arg_1, arg_2, &callback)
module Util
def bcall(*args, &block)
call(block, :call, *args)
end
def call(object, method, *args, &block)
args = args_for_arity(args, object.method(method).arity)
object.send(method, *args, &block)
key: val