Skip to content

Instantly share code, notes, and snippets.

View heyitsjames's full-sized avatar

James Rasmussen heyitsjames

  • Salt Lake City, Utah
View GitHub Profile
#! /usr/bin/env python3
import sys
hosts_path = '/Users/james/Desktop/hosts'
def main(argv):
is_commented = False
hosts_file = open(hosts_path, 'r')
hosts_file_contents = hosts_file.readlines()
defmodule MyApp.Encoder do
@moduledoc """
General implementation for the Jason encoder to be used in Ecto schemas
"""
defmacro __using__(opts) do
drop_fields = Keyword.get(opts, :drop, [])
quote do
defimpl Jason.Encoder, for: [__MODULE__] do
@heyitsjames
heyitsjames / gist:c223376587a0900a7e4d8daa83aff7dd
Created May 25, 2021 05:30
35-39 Males competing in 2021 Ironman 70.3 Hawaii
ABBOTT ERIC MALE 35 USA
AIDO RICARDO MALE 39 PRT
ALFRED RYAN MALE 38 USA
ANDRADE JONATHAN MALE 35 USA
ANDREAS WITTMANN MALE 39 DEU
ARECHAVALETA RICHARD MALE 38 USA
AYTON TRISTAN MALE 37 AUS
BAIER-LENTZ MORITZ MALE 35 DEU
BARRAGAN ALFREDO MALE 37 USA
BARRAGAN ZAMUDIO JESUS EDUARDO MALE 35 MEX
@heyitsjames
heyitsjames / gist:288dcd865098cc3c730de0eed77509ae
Created May 25, 2021 05:13
35-39 Males competing in 2021 Ironman Coeur d'Alene
ABNEY DAVID MALE 37 US
ADAMS BROCK MALE 36 US
ADAMS MICHAEL MALE 35 US
ALDERSON ROBERT MALE 36 US
ALLEN ERIC MALE 37 US
ALLEN JOE MALE 37 US
AMADIO ANTHONY MALE 39 US
ANDERSON CHASE MALE 39 US
ANDERSON DEREK MALE 39 US
ANDERSSON TOBIAS MALE 36 US
@heyitsjames
heyitsjames / depths.get.ex
Created June 9, 2020 19:49
If you want depths, you shall have them
defmodule Mix.Tasks.Depths.Get do
@moduledoc """
Fetches all the depths
"""
use Mix.Task
def run(_args) do
IO.puts(
"Your eyes are endless pools reflecting every dying star and every emergent " <>
defp dedupe_chunk(chunk) do
chunk
|> Enum.reduce(%{}, fn(row, acc) -> Map.put(acc, row["email"], row) end)
|> Enum.reduce([], fn({_, values}, acc) -> [values | acc] end)
end
@heyitsjames
heyitsjames / swole.py
Last active August 27, 2015 04:47
here ya go mikey
# you'll need to import this guy
from datetime import datetime
date_created = datetime.strptime(d['DateCreated'], 'YYYYMMddThh:mm:ss Z')
name = d['Name']
contact_group = d['ContactGroup']
fk_dict = {
'contact_group': 'contact_group_id',
'other_thing': 'other_thing_id'
@heyitsjames
heyitsjames / census.py
Created August 22, 2015 00:11
% married by per capita, where per capita is defined as an individual > 18 years old.
import requests
import json
def test_api():
state_list = list(range(1, 52))
key = '76e9012372312829bbfd506cd2b9dcff63c58e75'
params = 'NAME,P0180003,P0100001'
url = 'http://api.census.gov/data/2010/sf1?key={0}&get={1}&for=state:{2}'
state_data = []
@heyitsjames
heyitsjames / clever.py
Last active August 29, 2015 14:20
Clever Sandbox API Question
import json
import requests
import statistics
class CleverAPI():
AUTH_HEADER = {'Authorization': 'Bearer DEMO_TOKEN'}
CLEVER_URL = 'https://api.clever.com'
def __init__(self, auth_header=None):
-- Get the average course rating for a specific subcategory
SELECT sub_id, AVG(3.15+predicted_nps*1.00/50) AS avg_new_score
FROM
(SELECT con.courseId, c.title, u.title AS name, chs.courseSubcategoryId as sub_id,
CASE
WHEN nps.size>40
THEN nps.nps
WHEN nps.size<10
OR nps.size IS NULL
AND rat.size<5