Skip to content

Instantly share code, notes, and snippets.

Avatar
☁️

Dan Kohn dankohn

☁️
View GitHub Profile
View heroku-bin
macbookair:~/Documents/dev$ git clone https://github.com/dankohn/express-test
Cloning into 'express-test'...
remote: Counting objects: 863, done.
remote: Compressing objects: 100% (724/724), done.
remote: Total 863 (delta 81), reused 855 (delta 73)
Receiving objects: 100% (863/863), 1.06 MiB | 996.00 KiB/s, done.
Resolving deltas: 100% (81/81), done.
macbookair:~/Documents/dev$ cd express-test/
macbookair:~/Documents/dev/express-test (master)$ heroku create
Creating secret-escarpment-4221... done, stack is cedar
@dankohn
dankohn / test_csv.js
Last active Dec 18, 2015
Parsing double-nested CSV fields
View test_csv.js
var csv = require('csv')
var cat = "Text"
var commaCat = "A, B, and C"
var cat2 = "More text"
csv()
.from.array([[cat,commaCat,cat2]])
.to.string( function(innerNest){
console.log(innerNest)
csv()
@dankohn
dankohn / circle.yml
Created Jul 16, 2014
Configuring CircleCI, Coveralls, and CodeClimate
View circle.yml
## Customize test commands
test:
post:
- bundle exec rake coveralls:push
## Don't have CircleCI create coverage in an unexpected place, as coveralls wouldn't be able to find it.
general:
artifacts:
- "coverage"
View gist:e3896f9288d19ac1f7a5
def access_own_records
return if @user.super_administrator?
# Anyone can read or update anything they create
[Appointment, Claim, Referral, Study].each do |model|
can([:edit, :index, :read, :update], model,
model.where(created_id: @user.id)) do |instance|
instance.created_id == @user.id
end
end
end
@dankohn
dankohn / starbucks_us_locations.csv
Last active Sep 19, 2022
8902 locations of US Starbucks with addresses, latitude, and longitude
View starbucks_us_locations.csv
We can't make this file beautiful and searchable because it's too large.
-149.8935557,61.21759217,Starbucks - AK - Anchorage 00001,"601 West Street_601 West 5th Avenue_Anchorage, Alaska 99501_907-277-2477"
-149.9054948,61.19533942,Starbucks - AK - Anchorage 00002,"Carrs-Anchorage #1805_1650 W Northern Lights Blvd_Anchorage, Alaska 99503_907-339-0500"
-149.7522,61.2297,Starbucks - AK - Anchorage 00003,"Elmendorf AFB_Bldg 5800 Westover Avenue_Anchorage, Alaska 99506"
-149.8643361,61.19525062,Starbucks - AK - Anchorage 00004,"Fred Meyer - Anchorage #11_1000 E Northern Lights Blvd_Anchorage, Alaska 995084283_907-264-9600"
-149.8379726,61.13751355,Starbucks - AK - Anchorage 00005,"Fred Meyer - Anchorage #656_2300 Abbott Road_Anchorage, Alaska 99507_907-365-2000"
-149.9092788,61.13994658,Starbucks - AK - Anchorage 00006,"Fred Meyer - Anchorage (Dimond) #71_2000 W Dimond Blvd_Anchorage, Alaska 995151400_907-267-6700"
-149.7364877,61.19533265,Starbucks - AK - Anchorage 00007,"Safeway-Anchorage #1817_7731 E Northern Lights Blvd_Anchorage, Alaska 99504_907-331-1700"
-149.8211,61.2156
View k8s_contributors.sql
SELECT
actor.login as contributor,
COUNT(repo.name) AS commits,
FROM
[githubarchive:year.2016]
WHERE
type IN ("PushEvent") AND
repo.name = "kubernetes/kubernetes"
GROUP BY
contributor
View commits.sql
SELECT
repo.name AS repository,
COUNT(repo.name) AS commits,
EXACT_COUNT_DISTINCT(actor.login) AS contributors
FROM
[githubarchive:year.2016]
WHERE
type IN ("PushEvent")
GROUP BY
repository
@dankohn
dankohn / over_10_contributors.sql
Last active Feb 26, 2017
More than 10 contributors
View over_10_contributors.sql
SELECT
repo.name AS repository,
COUNT(repo.name) AS commits,
EXACT_COUNT_DISTINCT(actor.login) AS contributors
FROM
[githubarchive:year.2016]
WHERE
type IN ("PushEvent")
GROUP BY
repository
View issues.sql
SELECT
repo.name,
ROUND(COUNT(*)/EXACT_COUNT_DISTINCT(actor.login),2) comments_per_author,
EXACT_COUNT_DISTINCT(actor.login ) authors,
COUNT(*) comments
FROM
[githubarchive:year.2016]
WHERE
type IN ('IssueCommentEvent')
AND actor.login NOT IN (
View pull_requests.sql
SELECT
repo.name AS repository,
COUNT(*) AS pull_requests,
EXACT_COUNT_DISTINCT(actor.login) AS contributors
FROM
[githubarchive:year.2016]
WHERE
type IN ( 'PullRequestEvent')
AND JSON_EXTRACT(payload, '$.action') IN ('"opened"')
GROUP BY