This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 " <> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
NewerOlder