Skip to content

Instantly share code, notes, and snippets.

@jdanbrown
jdanbrown / CoreData+Extensions.swift
Created June 5, 2022 04:05 — forked from flaviodsilverio/CoreData+Extensions
Useful Extensions for NSManagedObject + NSManagedObjectContext
import CoreData
extension NSManagedObject {
class var entityName: String! {
get {
return self.entity().managedObjectClassName.components(separatedBy: ["."]).last!
}
}
# Sorted copy of https://gist.github.com/skfarhat/4e88ef386c93b9dceb98121d9457edbf
--------------------------------------------
Version: 1.45.1
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:33:47.663Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
@jdanbrown
jdanbrown / .sql
Created June 28, 2017 22:54
v1 sync runtimes
-- web_nightly fails
-- addresses takes ~6-7h
-- dwellings takes ~4-5h
-- web takes ~45m-1h >80% of the time, and 2-3h <20% of the time, probably due to whether it's running concurrently with the ones above
datawarehouse=> select completed_at - started_at as duration, * from etl.etl_logs where operation='etl' and created_at > now() - interval '14 days' order by duration desc, schema limit 180;
duration | id | operation | kind | schema | started_at | completed_at | created_at | updated_at | table_name
-----------------+---------+-----------+--------+-------------+----------------------------+----------------------------+----------------------------+----------------------------+------------
NULL | 2924404 | etl | schema | dwellings | 2017-06-15 08:00:00.355421 | NULL | 2017-06-15 08:00:00.355421 | 2017-06-15 08:00:00.355421 | NULL
NULL | 2949815 | etl | schema | mortgage
@jdanbrown
jdanbrown / zapier-bigquery.js
Last active January 2, 2019 00:16
Custom Zapier app for BigQuery
/*
1. Account -> Developers -> new app
2. Authentication: use "Unknown Auth", then manually adds fields `service_account_email` and `service_account_private_key_json`
- Auth is done manually via service account key in the js below
3. Triggers: add triggers with specific keys and fields to match the custom js code below, which overrides their behavior
- Create a "polling" trigger with key `test_trigger`, with field `project`
- Create a "polling" trigger with key `new_row`, with fields `project` and `query`
- Create a "polling" trigger with key `table_modified`, with fields `project`, `dataset`, and `table`
4. Scripting API: paste in this whole file as is
@jdanbrown
jdanbrown / bq.sql
Last active April 4, 2017 01:17
bq: unnest array vs. union select
# TODO(db): Figure out if either of these is better than the other
# - Both give "query resources exceeded" on what_is_junk with all of the homes/addresses fields
def template_unnest_array(table, fields):
df = bq.Query(with_od_homes('''
select * from unnest([
%(array_elems)s
])
order by i
''' % dict(
@jdanbrown
jdanbrown / py
Created March 28, 2017 22:14
Configs for grc/grcat: https://github.com/garabik/grc
# ~/.grc/py
# Skip if not a log line
regexp=^(?!.*\b(CRITICAL|FATAL|ERROR|WARNING|WARN|INFO|DEBUG|TRACE)\b)
colours=none
count=stop
======
# Everything before msg: <level> <timestamp> <module> <msg>
regexp=^(\S+\s+){3}
$ sudo mtr gmail.com
My traceroute [v0.85]
192-195-80-250.public.monkeybrains.net (::) Sun May 3 16:55:14 2015
Keys: Help Display mode Restart statistics Order of fields quit
Packets Pings
Host Loss% Snt Last Avg Best Wrst StDev
1. gw-227.IPv6.monkeybrains.net 0.0% 512 35.2 29.1 8.2 86.0 11.3
2. gw-214.IPv6.monkeybrains.net 1.6% 512 29.7 29.0 11.3 92.3 10.1
3. 2607:f598:0:527::1 1.2% 511 40.1 37.0 7.3 143.0 19.7
My traceroute [v0.85]
ip-192-168-0-197.ec2.internal (0.0.0.0) Mon Apr 20 22:16:59 2015
Keys: Help Display mode Restart statistics Order of fields quit
Packets Pings
Host Loss% Snt Last Avg Best Wrst StDev
1. gw-tiff-v227.static.monkeybrains.net 0.7% 418 93.0 135.9 34.5 265.2 40.7
2. ip-172-17-18-34.ec2.internal 2.6% 418 154.7 135.1 35.3 232.0 39.7
3. grillo.grillo-mosca-10GB.core.monkeybrains.net 5.0% 418 91.2 135.7 42.1 331.8 43.6
4. lemon.lemon-grillo.core.monkeybrains.net
$ json-diff <(curl -sfL https://gist.github.com/jdanbrown/027473f2fcec69919f22/raw/3dedaccd3fcf0cc7731a5deebdab4d4b62b6c681/-) <(curl -sfL https://gist.github.com/jdanbrown/7134d82810b4a8240058/raw/0c916ea3f632231b950f9ceb402c0f0339debd96/-)
{
Classpath Entries: {
- /etc/hadoop/conf: "System Classpath"
- /opt/cloudera/parcels/CDH-5.3.0-1.cdh5.3.0.p0.30/bin/../lib/hadoop/../hadoop-hdfs/./: "System Classpath"
- /opt/cloudera/parcels/CDH-5.3.0-1.cdh5.3.0.p0.30/bin/../lib/hadoop/../hadoop-hdfs/.//hadoop-hdfs-2.5.0-cdh5.3.0-tests.jar: "System Classpath"
- /opt/cloudera/parcels/CDH-5.3.0-1.cdh5.3.0.p0.30/bin/../lib/hadoop/../hadoop-hdfs/.//hadoop-hdfs-2.5.0-cdh5.3.0.jar: "System Classpath"
- /opt/cloudera/parcels/CDH-5.3.0-1.cdh5.3.0.p0.30/bin/../lib/hadoop/../hadoop-hdfs/.//hadoop-hdfs-nfs-2.5.0-cdh5.3.0.jar: "System Classpath"
- /opt/cloudera/parcels/CDH-5.3.0-1.cdh5.3.0.p0.30/bin/../lib/hadoop/../hadoop-hdfs/.//hadoop-hdfs-nfs.jar: "System Classpath"
- /opt/cloudera/parcels/CDH-5.3.0-1.c
@jdanbrown
jdanbrown / foo.sh
Created January 31, 2015 02:23
Scrape spark-1.2.0 /environment using pup + jq
$ for header in 'Runtime Information' 'Spark Properties' 'System Properties' 'Classpath Entries' ; do pbpaste | pup 'h4:contains("'"$header"'") > table tr json{}' | jq '{"key":"'"$header"'", "value":[.[].children | {key:.[0].text, value:.[1].text}] | .[1:] | from_entries}' -c ; done | jq --slurp '. | from_entries' --sort-keys