Skip to content

Instantly share code, notes, and snippets.

@dgrtwo
dgrtwo / dice-rolls.R
Created February 25, 2019 23:56
Animation of die rolls
# Code behind this tweet: https://twitter.com/drob/status/1100182329350336513
library(tidyverse)
library(gganimate)
# Setup
options(gganimate.nframes = 200)
set.seed(2019)
simulation <- tibble(roll = 1:10000) %>%
mutate(result = sample(6, n(), replace = TRUE)) %>%
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active March 26, 2024 10:34
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@yeedle
yeedle / hourly-weather.R
Last active February 5, 2022 04:14
Temperature of every hour in NY since 1973
library(tidyverse)
library(R.utils)
library(glue)
library(magrittr)
library(weathermetrics)
library(padr)
library(ggExtra)
library(lubridate)
library(scales)
library(hrbrthemes)
library(mgcv)
library(ggplot2)
library(dplyr)
library(XML)
library(weatherData)
us.airports.url <- 'http://www.world-airport-codes.com/us-top-40-airports.html'
us.airports <- readHTMLTable(us.airports.url)[[1]] %>%
filter(!is.na(IATA)) %>%
library(CRF)
# there are 10 nodes. Each node can take on one of 3 states.
nNodes <- 10
nStates <- 3
# make the adjacency matrices for each graph
# a fully-connected graph of 10 nodes. Loopiest possible.
# we expect a lot of error: the inferred node beliefs should
@madjar
madjar / scrapper.py
Last active March 5, 2023 15:02
A example of scrapper using asyncio and aiohttp
import asyncio
import aiohttp
import bs4
import tqdm
@asyncio.coroutine
def get(*args, **kwargs):
response = yield from aiohttp.request('GET', *args, **kwargs)
return (yield from response.read_and_close(decode=True))
@dansku
dansku / dropboxOrganize.py
Created February 16, 2014 20:32
Script to organize pictures uploaded from Mobile Devices to Dropbox's Camera Upload folder
################################################################################################
#
# Script to organize pictures uploaded from Mobile Devices to Dropbox's Camera Upload folder
#
# Daniel Spillere Andrade - www.danielandrade.net
#
################################################################################################
import os, time
import glob
@alaiacano
alaiacano / all_yzt.sql
Last active January 2, 2016 15:58
`p(x|z,y,t)`, untested
select numerator.x, numerator.num/denominator.denom, numerator.y, numerator.z, numerator.t
(select sum(x) as num, x, y, z, t from table group by x, y, z, t) numerator
join
(select sum(x) as denom, y, z, t from table group by y,z,t) denominator
on (numerator.y=denominator.y and numerator.z=denominator.z and numerator.t=denominator.t)
@dgleich
dgleich / netflix_svd.m
Last active January 3, 2017 04:21
SVD testing code for the netflix matrix, by David F. Gleich and Yangyang Hou.
%% Read Netflix dataset
A = readSMAT('/scratch/dgleich/netflix/netflix.smat');
k = [10 25 50 100 150 200];
l = size(k,2);
%% Matlab's SVDS
for i= 1:l
tic;
[U,S,V] = svds(A,k(i));
@joshdick
joshdick / forecast_snapshot.sh
Created October 10, 2013 14:31
Forecast.io Snapshot
#!/bin/sh
# Forecast.io Snapshot
#
# Creates a snapshot of forecast.io embeds (http://blog.forecast.io/forecast-embeds/)
# for display on the desktop via GeekTool/Nerdtool.
#
# by Josh Dick - http://joshdick.net
#
# This script depends on: