Skip to content

Instantly share code, notes, and snippets.

@Dulani
Dulani / Simple Voice Intent Schema.json
Created December 19, 2016 04:26
Simple JSON "fact" intent schema for developing Alexa Skills with the Amazon Skills Kit
{
"intents": [
{
"intent": "GetNewFactIntent"
},
{
"intent": "AMAZON.HelpIntent"
},
{
"intent": "AMAZON.StopIntent"
@Dulani
Dulani / ThreeWayIPF.R
Last active November 20, 2016 04:49
Testing a Three Way IPF with combined margins and separate ones (using the mipfp library)
#Testing a three way IPF with combined and individual marginals.
library(mipfp)
library(dplyr)
pers <- data_frame(
gender = sample(c("m","f"),25,replace = T),
age = rep(1:5,5),
fpl = rep((5:1)/0.5,5),
w = rep(1,25)
@Dulani
Dulani / webdav.R
Created November 16, 2016 20:18
R helper functions for performing WebDAV tasks
library(curl)
library(XML)
listFiles <- function(username, password, relPath = "/", dav = "https://dav.box.com/dav") {
uri <- URLencode(paste(dav, relPath, sep=""))
# fetch directory listing via curl and parse XML response
h <- new_handle()
handle_setopt(h, customrequest = "PROPFIND")
handle_setopt(h, username = username)
@Dulani
Dulani / Ubuntu Mac Trackpad.md
Last active January 16, 2016 08:02
Trackpad Adjustments for Ubuntu on Mac

Examine sensitivities

  • List devices and find the trackpad's ID: xinput list
  • Monitor the input: xinput --test [id #]

Use Synclient to adjust things (what worked for me)

  • List the properties. synclient
@Dulani
Dulani / gist:0279f33148bde7247a05
Last active July 11, 2023 20:28
Installing R Studio Server on an Amazon Linux (Redhat) AMI

Installing R Studio Server on an Amazon Linux (Redhat) AMI

  • Drawn mostly from: http://www.rstudio.com/products/rstudio/download-server/

  • ssh into the instance.

  • Install any outstanding updates
    sudo yum update

  • Install R:
    sudo yum install R

@Dulani
Dulani / Fill Down
Created January 27, 2015 16:29
Excel style "fill down" in R using data.table
#An Excel style "fill down" for Data Table. (.SD is the Subset of Data for each 'by' group)
dataTable[,setId:=.SD[1,setId],by=setNum] #TAG:USEFUL (Excel style fill down)
@Dulani
Dulani / gist:985c32f5b14e64e3c792
Last active August 29, 2015 14:09
Geocoding in R using Google's API
# Geocoding in R using Google's API
require(RCurl)
require(XML)
require(data.table)
require(dplyr)
ridbLocs <- data.table(read.delim(file = "Data/ridbLocations.tsv"))
setnames(ridbLocs,c("original","locationType","simplified1","gCode","simplified","lat","lon"))
#' Model formula from my Google Sheet:
@Dulani
Dulani / SPARQL Lat Lon
Last active August 29, 2015 14:09
SPARQL Query for Army Installation lat/lon
# A quick way to pull a lat/lon table off Wikipedia for "all" US Army bases.
# SPARQL: on http://dbpedia.org/sparql
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@Dulani
Dulani / register doParallel for dplyr and foreach
Created October 23, 2014 18:16
The parallel back end CPU registration code for doParallel/foreach/dplyr
require(dplyr)
require(parallel)
require(foreach)
require(doParallel)
cpuCount <- detectCores() #From the parallel package
registerDoParallel(cores=cpuCount-1) #Don't take all cores.
dplyr({put dplyr data arguments here},.parallel=T) #Run dplyr in parallel.