Skip to content

Instantly share code, notes, and snippets.

@Dulani
Dulani / Rcpp.R
Created August 5, 2017 03:17
A VERY simple example using C++ in R with the cppFunction() function.
#' Copied from Dirk Eddelbuettel's 2017 Rcpp Tutorial
#' http://dirk.eddelbuettel.com/papers/useR2017_rcpp_tutorial.pdf
#A very impressive little adaptation:
cppFunction(”
double m(int n, double x) {
for (int i=0; i<n; i++)
x = 1 / (1+x);
return x;
}”
@Dulani
Dulani / datatable.options.R
Created October 10, 2017 16:53
R DT datatable options
#Adjust the size of the scrollbar and the number of items on a "page" and also setting the height of the scroll bar.
library(tidyverse)
library(DT)
mtcars %>%
DT::datatable(., style ="default", options = list("scrollY" = "400px", "pageLength"= 120))
# An alternative style choice is style ="bootstrap"
@Dulani
Dulani / r_ubuntu_17_10.sh
Created October 22, 2017 14:23 — forked from pachadotdev/r_ubuntu_17_10.sh
Install R on Ubuntu 17.10
# Install R
sudo apt-get update
sudo apt-get install gdebi libxml2-dev libssl-dev libcurl4-openssl-dev r-base r-base-dev
# Install RStudio
cd Downloads
wget https://download1.rstudio.org/rstudio-xenial-1.1.383-amd64.deb
sudo gdebi rstudio-xenial-1.1.383-amd64.deb
printf '\nexport QT_STYLE_OVERRIDE=gtk\n' | sudo tee -a ~/.profile
@Dulani
Dulani / xpath examples.txt
Created November 14, 2017 21:50
Some working Xpath expressions.
Xpath
#Starting with what you know you want an xpath expression for, pick it out and then pick its parent out.
//*[Name="Q1"]
//*[Name="Q1"]/parent::*
//Grid[Name="Q1"]/parent::*
#All the text attributes of the name elements of the grid nodes:
//Grid/Name/text()
@Dulani
Dulani / python_logging_examples.py
Created November 18, 2017 03:19
Example logging code for Python (since I'm always having to look it up).
#!/usr/bin/env python
"""
Originally taken from my pandoc filter code.
It has good examples of logging in use.
"""
import logging
LOG_FILENAME = 'my_log_name_here.log'
@Dulani
Dulani / notify.py
Created November 18, 2017 04:43 — forked from lukaszb/notify.py
Simple Python script to send notification to the OSX Notifications Center (requires OS X 10.8+). Tested with pyobjc 2.5.1
#!/usr/bin/env python
from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
from Foundation import NSUserNotificationDefaultSoundName
from optparse import OptionParser
def main():
parser = OptionParser(usage='%prog -t TITLE -m MESSAGE')
@Dulani
Dulani / usingCodeCommitAWS.md
Created December 26, 2017 13:21 — forked from JohannMG/usingCodeCommitAWS.md
Setting Up AWS CodeCommit (Mac) with Sourcetree and disabling keychain

#Setting Up AWS CodeCommit (Mac)

For all possibilities, amazon has guides here: http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up.html

We chose to use HTTPS here

If git asks you to manually enter username or password it is incorrectly configured!

Similar to RSA, the AWS CLI credential-helper should be using your keys to create and send a dynamic password that updates every 15 minutes.

@Dulani
Dulani / strip-autocomplete.user.js
Created August 7, 2018 15:54 — forked from david0/strip-autocomplete.user.js
Greasymonkey/Tampermonkey script that strips "autocomplete" attributes from username and password fields
// ==UserScript==
// @name Strip autocomplete attributes
// @namespace david0
// @version 0.1
// @description This plugin gives the control about your passwords back to your browser and allows the browser to store every password.
// @include http://*
// @include https://*
// @copyright 2014, David
// ==/UserScript==
@Dulani
Dulani / gitlab-ci.yaml
Created August 8, 2018 00:22
Gitlab CI and deployment
image: php:5.6
stages:
- test
- build
- deploy
test:
stage: test
script: echo "Running tests"
@Dulani
Dulani / minecraft_commands.txt
Created September 30, 2018 02:26 — forked from Dinnerbone/minecraft_commands.txt
Minecraft Java Edition 1.13 changes
advancement grant <targets> everything
advancement grant <targets> from <advancement>
advancement grant <targets> only <advancement>
advancement grant <targets> only <advancement> <criterion>
advancement grant <targets> through <advancement>
advancement grant <targets> until <advancement>
advancement revoke <targets> everything
advancement revoke <targets> from <advancement>
advancement revoke <targets> only <advancement>
advancement revoke <targets> only <advancement> <criterion>