Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / Multiply matrix columns by vector.Rmd
Last active February 15, 2017 20:34
Multiply the columns of the data frame by the elements of the vector in R
---
title: "Multiply the columns of the data frame by the elements of the vector"
output: html_notebook
---
Matrix:
```{r}
(mat <- matrix(c(4:9),ncol = 2))
```
@Dulani
Dulani / Desc_JSON_to_df.md
Created March 17, 2017 18:17 — forked from gluc/Desc_JSON_to_df.md
Convert a complex JSON to an R data.frame

This gist shows how to convert a nested JSON file to an R data.frame. To do this, it uses jsonlite and data.tree.

The gist contains two examples: one is a bit simpler, the second one a bit more advanced.

Example 1

In the first example, we download all the repos from Hadley Wickham's Github account from https://api.github.com/users/hadley/repos . This JSON contains a nested owner object. The code shows how to convert that in a flat data.frame in three statements:

  1. line 5: download
  2. line 8: convert to data.tree
@Dulani
Dulani / index.html
Created March 22, 2017 23:34 — forked from anonymous/index.html
NIJ PCJNI Delphi // source http://jsbin.com/micekex
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<script src="delphi-nij.js"> </script>
<link rel="stylesheet" type="text/css" href="delphi-nij.css">
<title>NIJ PCJNI Delphi</title>
@Dulani
Dulani / pdfcrop.py
Created June 2, 2017 01:49 — forked from alexzhan/pdfcrop.py
Use pyPdf to crop a pdf file according to user inputs
#!/usr/bin/env python
import sys
if __name__ == '__main__' and len(sys.argv) > 5 and sys.argv[1][-3:].upper() == 'PDF':
original = sys.argv[1]
target = original[:-4] + '.cropped.pdf'
left = int(sys.argv[2])
top = int(sys.argv[3])
right = int(sys.argv[4])
@Dulani
Dulani / pandoc.css
Created July 28, 2017 20:31 — forked from killercup/pandoc.css
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}