This file contains hidden or 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
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; | |
} |
This file contains hidden or 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
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 |
This file contains hidden or 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
require 'rubygems' | |
require 'mechanize' | |
FIRST_NAME = 'FIRST_NAME' | |
LAST_NAME = 'LAST_NAME' | |
PHONE = 'PHONE' | |
EMAIL = '[email protected]' | |
PARTY_SIZE = 2 | |
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' } |
This file contains hidden or 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
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) |
This file contains hidden or 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 python | |
# | |
# cocoa_keypress_monitor.py | |
# Copyright © 2016 Bjarte Johansen <[email protected]> | |
# | |
# 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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
;; 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)) |