Skip to content

Instantly share code, notes, and snippets.

View rgbkrk's full-sized avatar
🌎
Think globally, act locally

Kyle Kelley rgbkrk

🌎
Think globally, act locally
View GitHub Profile
@rgbkrk
rgbkrk / random_image.py
Last active May 24, 2017 18:58
Query giphy for random images
import IPython.display
import requests
def random_image_url(tags=None):
query = ""
if tags is not None:
query = "&tag=" + "+".join(tags)
api_url = "http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC" + query
resp = requests.get(api_url)
@rgbkrk
rgbkrk / javascript-proposal.ipynb
Last active July 27, 2017 03:42
Proposing some javascript bits
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rgbkrk
rgbkrk / table-with-schema.ipynb
Last active September 7, 2017 06:40
Using the new table schema with Pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rgbkrk
rgbkrk / dabblet.css
Created January 12, 2017 01:32 — forked from LeaVerou/dabblet.css
The cicada principle in animations
/**
* The cicada principle in animations
* Remember the cicada principle that used prime numbers to make multiple overlaid repeated backgrounds seem more random?
* There’s no reason it can’t be applied to repeating linear animations too (using primes for the durations, divided by 10)
*/
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes radius { 50% { border-radius: 50%; } }
@keyframes color { 33% { color: rebeccapurple; } 66% { color: deeppink } }
@keyframes width { 50% { border-width: .3em; } }
@rgbkrk
rgbkrk / dabblet.css
Last active January 3, 2017 18:43 — forked from csssecrets/dabblet.css
Pseudorandom stripes
/**
* Pseudorandom stripes
*/
background: #D5D5D5;
background-image:
linear-gradient(89deg, #EEE 23px, transparent 0),
linear-gradient(97deg, #DDD 17px, transparent 0),
linear-gradient(101deg, #D0D0D0 23px, transparent 0);
background-size: 83px 100%, 61px 100%, 41px 100%;
@rgbkrk
rgbkrk / flights.R
Last active December 2, 2016 01:26
sparklyr
> flights_tbl
Source: query [3.368e+05 x 19]
Database: spark connection master=yarn-client app=sparklyr local=FALSE
year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time
<int> <int> <int> <int> <int> <dbl> <int> <int>
1 2013 1 1 517 515 2 830 819
2 2013 1 1 533 529 4 850 830
3 2013 1 1 542 540 2 923 850
4 2013 1 1 544 545 -1 1004 1022
@rgbkrk
rgbkrk / kernel.json
Created November 26, 2016 00:17
Spark kernel
{
"display_name": "Python 2 (PySpark 1.6.1)",
"argv": [
"/usr/bin/python2",
"-m",
"ipykernel",
"-f",
"{connection_file}",
"--IPKernelApp.file_to_run=/path/to/spark_home/python/pyspark/shell.py"
],
@rgbkrk
rgbkrk / interpreter.sh
Created November 23, 2016 22:06
nteract-foundations
>>> import pandas as pd
>>> pd.read_csv("./gboeing/urban-data-science/07-Intro-to-Pandas/data/countries.csv").head()
country google_country_code country_group name_en name_fr name_de \
0 at AT eu Austria Autriche Österreich
1 be BE eu Belgium Belgique Belgien
2 bg BG eu Bulgaria Bulgarie Bulgarien
3 hr HR non-eu Croatia Croatie Kroatien
4 cy CY eu Cyprus Chypre Zypern
latitude longitude
@rgbkrk
rgbkrk / sql-mixin.md
Last active January 24, 2022 22:56
Turning lodash into declarative SQL

Lodash has a sweet feature called a mixin that lets you alias function names. Below here I alias names that we're used to using in SQL to (roughly) equivalent functions in lodash.

_.mixin({
  select: _.map,
  from: _.chain,
  where: _.filter,
  groupBy: _.sortByOrder,
})
@rgbkrk
rgbkrk / node-repl.js
Last active October 6, 2016 05:49
Node REPL
const readline = require('readline')
const vm = require('vm')
const sandbox = vm.createContext(Object.assign({}, global))
const rl = readline.createInterface(process.stdin, process.stdout)
rl.setPrompt("> ")
rl.prompt()