Skip to content

Instantly share code, notes, and snippets.

View erik-megarad's full-sized avatar

Erik Peterson erik-megarad

View GitHub Profile
@erik-megarad
erik-megarad / gist:fac21da9359d41549ed4
Created April 14, 2015 14:50
Get views dumped into schema.rb
module ActiveRecord
class SchemaDumper
def views(stream)
# Order by reltype is important so that the views are dumped in the order
# they are created, in case one view is dependent on others
views = @connection.query(%Q{
SELECT n.nspname AS schemaname,
c.relname AS viewname,
pg_get_viewdef(c.oid) AS definition
FROM pg_class c
@erik-megarad
erik-megarad / find_asset_replacement.rb
Created July 21, 2016 16:02
Sprockets 3.x find_asset replacement
# In Sprockets 2.x, you used to be able to find the location of an uncompiled asset by doing:
Rails.application.assets.find_asset(path)
# However, in Sprockets 3.x, `assets` is nil, `find_asset` isn't accessible without creating
# your own Sprockets::Manifest object, and there's no direct equivalent. The officially
# supported method is to use:
Rails.application.assets_manifest.assets[path]
# However, this only searches for *already compiled* assets.
#
aba
abac
abaca
abaff
abb
abba
abe
abed
acca
accede
/*
Settings to make Civ 6's loyalty system somewhat reasonable at high difficulties.
*/
update GlobalParameters set Value = "6" where Name="CAPITAL_IDENTITY_PRESSURE_TILE_RADIUS_MAXIUMUM_BASE";
update GlobalParameters set Value = "6" where Name="CITIZEN_IDENTITY_PRESSURE_RADIUS_CUTOFF";
update GlobalParameters set Value = "200" where Name="LOYALTY_AFTER_TRANSFERRED_BY_COMBAT";
update GlobalParameters set Value = "200" where Name="LOYALTY_AFTER_TRANSFERRED_BY_COMBAT_ORIGINAL_OWNER";
update GlobalParameters set Value = "200" where Name="LOYALTY_AFTER_TRANSFERRED_BY_COMBAT_OWNER_BEFORE_OCCUPATION";
update GlobalParameters set Value = "200" where Name="LOYALTY_AFTER_TRANSFERRED_BY_CULTURAL_IDENTITY";
@erik-megarad
erik-megarad / type_clipboard.applescript
Created June 2, 2020 21:02
Applescript to type from clipboard
on numberAsKeycode(theString)
tell application "System Events"
repeat with currentChar in (every character of theString)
set cID to id of currentChar
if ((cID 48) and (cID 57)) then
key code {item (cID - 47) of {29, 18, 19, 20, 21, 23, 22, 26, 28, 25}}
else
keystroke currentChar
end if
delay 0.03
@erik-megarad
erik-megarad / paired_commonality.json
Created January 21, 2022 22:16
Commonality of two-letter pairs by start position amongst the 3000 most popular five-letter words
{"aa": [1, 0, 1, 0], "ab": [10, 19, 4, 1], "ac": [9, 28, 25, 2], "ad": [11, 15, 17, 11], "ae": [1, 0, 0, 2], "af": [1, 4, 7, 0], "ag": [8, 17, 5, 0], "ah": [1, 3, 3, 5], "ai": [5, 42, 29, 5], "aj": [0, 2, 0, 0], "ak": [1, 13, 14, 10], "al": [29, 44, 22, 42], "am": [11, 24, 23, 7], "an": [17, 61, 48, 37], "ao": [0, 3, 1, 1], "ap": [7, 15, 14, 4], "aq": [0, 0, 1, 0], "ar": [19, 76, 54, 21], "as": [13, 32, 31, 14], "at": [4, 48, 26, 10], "au": [5, 21, 2, 1], "av": [4, 19, 10, 0], "aw": [5, 2, 8, 2], "ax": [2, 8, 0, 2], "ay": [0, 13, 5, 13], "az": [2, 4, 6, 1], "ba": [37, 0, 3, 4], "bb": [0, 3, 6, 0], "bc": [0, 0, 0, 0], "bd": [0, 0, 0, 0], "be": [29, 1, 18, 5], "bf": [0, 0, 0, 0], "bg": [0, 0, 0, 0], "bh": [0, 0, 0, 0], "bi": [16, 1, 9, 2], "bj": [0, 0, 0, 0], "bk": [0, 0, 0, 0], "bl": [31, 0, 8, 0], "bm": [0, 0, 0, 0], "bn": [0, 0, 0, 0], "bo": [35, 6, 12, 6], "bp": [0, 0, 0, 0], "bq": [0, 0, 0, 0], "br": [38, 0, 4, 0], "bs": [0, 0, 0, 17], "bt": [0, 0, 1, 1], "bu": [28, 1, 4, 0], "bv": [0, 0, 0, 0], "bw": [0,