Skip to content

Instantly share code, notes, and snippets.

@MatsuuraKentaro
MatsuuraKentaro / model1.stan
Last active July 11, 2020 18:36
COVID-19: estimate effective reproduction number
functions {
// calculating the convolutions
vector convolution(vector x, vector y_rev) {
int T = num_elements(x);
vector[T-1] res;
for (t in 2:T) {
res[t-1] = dot_product(x[1:(t-1)], y_rev[(T-t+2):T]);
}
return res;
}
@noamross
noamross / find_local_tweeps.R
Created August 14, 2017 23:43
A visit to Durham
library(rtweet) #rtweet API creds should already be set up
library(stringi)
library(dplyr)
friends = get_friends(user="noamross")
followers = get_followers("noamross")
tweeps_id = distinct(bind_rows(friends, followers))
tweeps_info = lookup_users(tweeps_id$user_id)
# A regex for a visit to Durham
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
@mauget
mauget / Neo4j shortest path
Last active March 3, 2019 23:10
Emits a Google KML stream of the shortest path between two points. A "point" is a Neo4j node having latitude and and longitude properties. The Neo4j A* algorithm does the work.
public void findShortestPath(PrintStream ps, long startNode, long endNode) {
try {
RouterService router = Initializer.getApplicationContext().getBean(RouterService.class);
router.emitShortestPathKML(ps, startNode, endNode);
} catch (Exception e) {
e.printStackTrace();
}
}
public void emitShortestPathKML(PrintStream ps, long keyValueA, long keyValueB)
@ljos
ljos / cocoa_keypress_monitor.py
Last active January 6, 2024 07:36
Showing how to listen to all keypresses in OS X through the Cocoa API using Python and PyObjC
#!/usr/bin/env python
#
# cocoa_keypress_monitor.py
# Copyright © 2016 Bjarte Johansen <Bjarte.Johansen@gmail.com>
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# “Software”), to deal in the Software without restriction, including
@tvladeck
tvladeck / Git color log
Created June 19, 2012 16:21
Better log for git
It's simple. Just type in:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
I guess that's a bit too long, eh? Let's just make an alias. Copy and paste the line below on your terminal:
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
And every time you need to see your log, just type in
git lg
;; Monty Hall problem (Let's Make a Deal gameshow)
;; http://www.marilynvossavant.com/articles/gameshow.html
(use '(incanter core stats charts))
;; set a simulation sample size
(def n 10000)
;; generate samples of initial-guesses, prize-doors, and switch decisions
(def initial-guesses (sample [1 2 3] :size n))
(def prize-doors (sample [1 2 3] :size n))