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
-- See http://www.daigolab.org/instapaper-to-evernote-mac/ for instruction | |
-- Basic settings | |
set myNotebook to "Instapaper" | |
set delayInSeconds to 1 | |
set giveUpAfter to 30 | |
set oldToNewOrder to true | |
-- Function to make sure Evernote is up | |
to makeSureEvernoteIsUp(giveUpAfter) | |
tell application "Evernote" to activate |
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
Verifying that +daigo is my openname (Bitcoin username). https://onename.io/daigo |
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 imp | |
def rmarkdown_page(page_id, **kwargs): | |
page = Page.objects.get(id=page_id) | |
if not RPY2_INSTALLED: | |
logger.info("rpy2 not found. I won't convert the raw text.") | |
return page.body | |
with open("/var/tmp/tmp.Rmd", "w") as f: | |
f.write(page.body) | |
ro.r("library('knitr');" |
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
# Modify stdout by rChart so I can customize tooltip and etc | |
require(rCharts) | |
renderChart = function (ct, chartId, include_assets = F, ...) | |
{ | |
add_ext_widgets(ct$lib) | |
assetHTML <- ifelse(include_assets, paste(paste(add_lib_assets(ct$lib, | |
...), collapse = "\n"), "\n", add_style_(ct$params$width, | |
ct$params$height), collapse = "\n"), "") | |
chartDiv = render_template(ct$templates$chartDiv, list(chartId = chartId, | |
lib = ct$LIB$name, container = ct$container)) |
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
; the macro source | |
; To understand pub sub in clojure and ClojureScript, read this: | |
; https://yobriefca.se/blog/2014/06/04/publish-and-subscribe-with-core-dot-asyncs-pub-and-sub/ | |
; define this in my-app/src/my-app/macros.clj | |
(ns my-app.macros) | |
(defmacro defsubfn | |
"Macro for subscriber function in pub-sub pattern" | |
[fnname channel body] | |
`(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
# Caches the query result in rds file under `getwd()`/psql_cache. | |
# It assumes pg_host, pg_port, pg_dbname, pg_user, pg_password variables in the env. | |
# Remove the cache files if the update value is needed. | |
# Expire: | |
# positive integer n: Expire if the existing cache is older than n minutes | |
# 0: Expire now | |
# -1: Always use the existing cache if it exists | |
cachedPsqlQuery <- function(queryName, query, expire=-1, cachePath="./psql_cache") { | |
require(RPostgreSQL) | |
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
# Adopted from http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2) | |
# And uploaded as gist for my personal use. | |
# | |
# Multiple plot function | |
# | |
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects) | |
# - cols: Number of columns in layout | |
# - layout: A matrix specifying the layout. If present, 'cols' is ignored. | |
# | |
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), |
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
#stepwise VIF function | |
stepwiseVIF <- function(in_frame,thresh=10,trace=T){ | |
require(fmsb) | |
if(class(in_frame) != "data.frame") in_frame <- data.frame(in_frame) | |
#get initial vif value for all comparisons of variables | |
vif_init <- NULL | |
for(val in names(in_frame)){ | |
form_in <- formula(paste(val," ~ .")) |
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
#!/bin/bash | |
# Uninstall things you installed with a pkg on Mac | |
# Tested on El Capitan | |
# Please run this at your own risk | |
# Read: http://superuser.com/questions/36567/how-do-i-uninstall-any-apple-pkg-package-file | |
if [ "$EUID" -ne 0 ] | |
then | |
echo "Please run as root" |
OlderNewer