Skip to content

Instantly share code, notes, and snippets.

View MilesMcBain's full-sized avatar

Miles McBain MilesMcBain

  • Queensland Fire and Emergency Services
  • Brisbane, Queensland
View GitHub Profile
@tslumley
tslumley / bentime.R
Created April 6, 2016 23:11
Times that don't turn into a pumpkin at midnight
"+.bentime"<-function(e1,e2){
e<-list(hour=e1$hour+e2$hour,min=e1$min+e2$min,sec=e1$sec+e2$sec)
sec_overflow<-e$sec>60L
e$sec<-e$sec %% 60L
e$min<-e$min+sec_overflow
min_overflow<-e$min>60L
e$hour<-e$hour+min_overflow
e$min<-e$min %% 60L
class(e)<-"bentime"
@evantoli
evantoli / GitConfigHttpProxy.md
Last active April 26, 2024 17:21
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@whophil
whophil / ipython-notebook.conf
Last active August 18, 2018 05:15
Upstart file (Ubuntu) for Jupyter / IPython notebook
start on filesystem or runlevel [2345]
stop on shutdown
description "Jupyter / IPython Notebook Upstart script"
script
export HOME="/home/phil/Notebooks"; cd $HOME
echo $$ > /var/run/ipython_start.pid
exec su -s /bin/sh -c 'exec "$0" "$@"' phil -- /home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config='/home/phil/.jupyter/jupyter_notebook_config.py'
end script
@jwolfson
jwolfson / readSQLite.R
Last active April 19, 2024 01:42
Reading an SQLite .db file into R
library(RSQLite)
filename <- "your_db_file.db"
sqlite.driver <- dbDriver("SQLite")
db <- dbConnect(sqlite.driver,
dbname = filename)
## Some operations
dbListTables(db)
mytable <- dbReadTable(db,"your_table_name")
@jennybc
jennybc / 2014-10-12_stop-working-directory-insanity.md
Last active September 23, 2022 04:43
Stop the working directory insanity

There are packages for this now!

2017-08-03: Since I wrote this in 2014, the universe, specifically Kirill Müller (https://github.com/krlmlr), has provided better solutions to this problem. I now recommend that you use one of these two packages:

  • rprojroot: This is the main package with functions to help you express paths in a way that will "just work" when developing interactively in an RStudio Project and when you render your file.
  • here: A lightweight wrapper around rprojroot that anticipates the most likely scenario: you want to write paths relative to the top-level directory, defined as an RStudio project or Git repo. TRY THIS FIRST.

I love these packages so much I wrote an ode to here.

I use these packages now instead of what I describe below. I'll leave this gist up for historical interest. 😆

@jennybc
jennybc / yaml_frontmatter_r_github_document.yaml
Last active February 9, 2022 21:36
YAML frontmatter for R Markdown to cause rmarkdown::render() to retain intermediate Markdown file for .R and .Rmd files, respectively
#' ---
#' title: "Something fascinating"
#' author: "Jenny Bryan"
#' date: "`r format(Sys.Date())`"
#' output: github_document
#' ---
@wch
wch / vega-legend-update.html
Last active November 2, 2017 05:27
Example of vega data and legend updates
<!DOCTYPE html>
<html>
<head>
<script src="http://trifacta.github.io/vega/lib/d3.v3.min.js"></script>
<script src="http://trifacta.github.io/vega/vega.js"></script>
</head>
<body>
<script type="text/javascript">
var iris_spec = {
@iamatypeofwalrus
iamatypeofwalrus / roll_ipython_in_aws.md
Last active January 22, 2024 11:18
Create an iPython HTML Notebook on Amazon's AWS Free Tier from scratch.

What

Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time
@pksunkara
pksunkara / config
Last active April 28, 2024 18:59
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta