Skip to content

Instantly share code, notes, and snippets.

View dplummer's full-sized avatar
🚘
robot cars!

Donald Plummer dplummer

🚘
robot cars!
View GitHub Profile
+++ New Roster (Warhammer 40,000 9th Edition) [106 PL, 9CP, 1,993pts] +++
++ Battalion Detachment -3CP (T'au Empire) ++
+ Configuration +
Battle Size: 3. Strike Force (101-200 Total PL / 1001-2000 Points)
Detachment Command Cost
@dplummer
dplummer / dplummer.zsh-theme
Created August 12, 2019 18:17
dplummer.zsh-theme
# vim:ft=zsh ts=2 sw=2 sts=2
#
# dplummer's theme, mostly copied from agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572).
#
@dplummer
dplummer / resolver.ex
Created October 5, 2016 17:27
recursive batch resolver for Absinthe
defmodule Grav.Resolver do
def resolve(protocol_module, args, field) do
{:ok, %{meta: meta} = root} = apply(protocol_module, :where, [args])
records_name = root |> Map.keys |> Enum.reject(& &1 in [:meta, :links, :linked]) |> hd
records = preload_associations(root[records_name], field |> derive_preloads)
{:ok, root |> Map.put(records_name, records) |> Map.merge(meta)}
end
@dplummer
dplummer / gist:c74cab74f4aca21bcc4b1381b642f4f3
Created January 30, 2017 17:04
rebar3 report "DEBUG=1 mix deps.compile cuttlefish"
Rebar3 report
version 3.3.2
generated at 2017-01-30T17:00:54+00:00
=================
Please submit this along with your issue at https://github.com/erlang/rebar3/issues (and feel free to edit out private information, if any)
-----------------
Task: DEBUG=1
Entered as:
DEBUG=1 mix deps.compile cuttlefish
-----------------
@dplummer
dplummer / client.ex
Created June 18, 2016 00:01
resistance client
defmodule Client do
def connect(false, :undefined) do
IO.puts "Connecting to node"
connect Node.connect(:"main@10.3.17.68"), :undefined
end
def connect(true, :undefined) do
IO.puts "Finding main name"
connect true, find_main
@dplummer
dplummer / json_spec.rb
Last active December 21, 2015 11:19
single file rails app and test to display json, */* returns html
require 'rails'
require 'action_controller/railtie'
require 'rspec'
require 'rack/test'
class JsonTestApp < Rails::Application
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: '****************************************'
config.secret_token = '****************************************'
config.secret_key_base = 'yup'
@dplummer
dplummer / .htaccess
Created August 21, 2013 17:35
same htaccess redirect
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.new-domain.com$ [NC]
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [L,R]
@dplummer
dplummer / gist:5513903
Created May 3, 2013 20:40
Compare two nested hashes
def compare_hashes(hash_a, hash_b, parent_keys = [])
keys_in_both = hash_a.keys & hash_b.keys
parent_name = parent_keys.map{|k| "['#{k}']"}.join
keys_in_both.each do |key|
if hash_a[key] != hash_b[key]
if hash_a[key].is_a?(Hash) && hash_b[key].is_a?(Hash)
compare_hashes(hash_a[key], hash_b[key], parent_keys + [key])
else
@dplummer
dplummer / gist:3778624
Created September 24, 2012 21:46
Struct.new block and constancts
1.8.7 :001 > Foo = Struct.new(:id) do
1.8.7 :002 > BAR = 5
1.8.7 :003?> end
=> Foo
1.8.7 :004 > BAR
=> 5
1.8.7 :005 > Foo::BAR
(irb):5: warning: toplevel constant BAR referenced by Foo::BAR
=> 5
@dplummer
dplummer / gist:3409229
Created August 20, 2012 23:27
order status count triggers
CREATE TRIGGER ai_order_statuses AFTER INSERT ON orders
FOR EACH ROW UPDATE order_status_counts
SET total = total + 1
WHERE status = NEW.status
AND order_type = NEW.type
AND (NEW.on_hold != 1 OR NEW.on_hold IS NULL)
CREATE TRIGGER ad_order_statuses AFTER DELETE ON orders