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
| #!/bin/bash | |
| ## zip=94114 | |
| zip="ASI|SG|SN---|SINGAPORE" | |
| if [ -n "$1" ]; then | |
| zip="$1" | |
| fi | |
| ip=`ip addr show scope global | grep inet | cut -d' ' -f6 | cut -d/ -f1 | tr "\n" " "` | |
| oip=`wget -q -O - http://icanhazip.com/ | tail` |
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
| ## Compute the distances between all US Zipcodes. | |
| ## To save time we just compute the diagonal and use multiple cores. | |
| require(parallel) | |
| library(geosphere) | |
| library(MASS) | |
| library(zipcode) | |
| data(zipcode) | |
| ## Uncode for testing | |
| ## zipcode <- zipcode[1:10,] | |
| zips.num = dim(zipcode)[1] |
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
| class func bingReverseGeocode(inout location: CLLocation, | |
| callback: (CLLocation) -> Void) { | |
| var bingAPIKey = "ABCDEF-1234567890" | |
| var lat = location.coordinate.latitude | |
| var lon = location.coordinate.longitude | |
| var u = "http://dev.virtualearth.net/REST/v1/Locations/\(lat),\(lon)?o=json&key=\(bingAPIKey)" | |
| var url = NSURL(string: u) | |
| var request: NSURLRequest = NSURLRequest(URL: url!) | |
| let session = NSURLSession.sharedSession() | |
| let task = session.dataTaskWithURL(url!, completionHandler: {data, response, error -> Void in |
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
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ;; Jabber Terminal Notifier | |
| ;; requires 'init-terminal-notifier.el' | |
| ;; https://gist.github.com/ayman/bb72a25e16af9e6f30bf | |
| (defun jabber-info-terminal-notify (infotype buffer text) | |
| "Pushing info notifications through terminal-notify." | |
| (unless (get-buffer-window buffer) | |
| (terminal-notifier-notify "Jabber" (jabber-escape-xml text)))) |
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
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ;; Terminal notifier | |
| ;; requires 'sudo port install terminal-notifier' | |
| ;; stolen from erc-notifier | |
| ;; | |
| ;; (terminal-notifier-notify "Emacs notification" | |
| ;; "Something amusing happened") | |
| (defvar terminal-notifier-command | |
| (executable-find "terminal-notifier") |
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(RColorBrewer) | |
| library(maptools) | |
| library(ggplot2) | |
| library(mapproj) | |
| library(rgdal) | |
| ## make sure you call | |
| gpclibPermit() | |
| data(wrld_simpl) |
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
| f.name <- "file.csv" | |
| f.command <- paste("wc -l", | |
| f.name, | |
| "| cut -d \" \" -f 2") | |
| f.rows <- as.numeric(system(f.command, intern = TRUE)) | |
| f <- read.csv(f.name, | |
| nrows=f.rows, | |
| col.names=c("user", "phone", "total", "percent"), | |
| colClasses=c("numeric","numeric","numeric","numeric"), | |
| header=FALSE) |
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
| // | |
| // RGBCountrViewController.swift | |
| // RGBCountr | |
| // | |
| // Created by David A. Shamma on 4/9/15. | |
| // Some parts taken from around the web. | |
| // | |
| // Simply take one photo and remember it, | |
| // then count the RGB diff from the next photo. | |
| // Ideally one should do this via histograms but this was quick. |
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
| ### Get the DOIs for an ACM DL Citation. | |
| ### | |
| ### David A. Shamma - GNU 2.0 License | |
| ### | |
| ## Call like this: | |
| ## get_citations('1290082.1290120', True) | |
| ## or just the tail/acm id | |
| ## get_citations('1290120') | |
| ## | |
| ## Prints to the console: |
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
| # Type 0: stacked area, 1: themeriver, 2: streamgraph | |
| areaGraph <- function(thedata, type=2, smooth=TRUE) { | |
| ## Color palette | |
| nColors <- 15 | |
| ## pal <- colorRampPalette(c("#0f7fb4", "#e2e2e2")) | |
| ## pal <- colorRampPalette(c("#6364a9", "#e2e2e2")) # Purple | |
| pal <- colorRampPalette(c("#48611d", "#f0f0f0")) | |
| colors <- pal(nColors) | |
| weights <- rowSums(thedata) | |
| ## Sort the data |