Skip to content

Instantly share code, notes, and snippets.

View dsernst's full-sized avatar
🧘‍♂️
practicing mindfulness

David Ernst dsernst

🧘‍♂️
practicing mindfulness
View GitHub Profile
@dsernst
dsernst / .eslintrc
Last active September 5, 2015 23:29
~/.eslintrc
{
"rules": {
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"comma-dangle": [1, "always-multiline"],
"indent": [1, 2],
"new-cap": 1,
"no-alert": 1,
"no-console": 1,
"no-debugger": 1,
"no-dupe-args": 2,
@dsernst
dsernst / os-specific-node_modules-packages.md
Last active November 4, 2015 07:58
How to use distinct npm packages across a host & VM when using a shared project folder

How to use distinctly compiled npm packages across a host machine & VM with a shared project folder

Use bcrypt and mongoose in each, with their own, OS-specific bindings
  1. Go to your ~/ home directory on the machine you want to install OS-specific module for, then run $ npm i compiled-package

  2. Move your package into ~/.node_modules folder (this is a special folder node knows to look in when requireing modules)

  • So probably: $ mv ~/node_modules/compiled-package ~/.node_modules/compiled-package
    • Shorthand: $ mv ~/{,.}node_modules/compiled-package
  • (consider rm -rfing the first node_modules folder to clean up after yourself)
@dsernst
dsernst / getSpreadsheetData.js
Last active February 21, 2019 04:31
getSpreadsheetData() utility function takes the name of a worksheet, then grabs all the data on the page and gives you back an array of objects, with the first row as property names.
function getSpreadsheetData(sheetName) {
// This function gives you an array of objects modeling a worksheet's tabular data, where the first items — column headers — become the property names.
var arrayOfArrays = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName || 'Sheet1').getDataRange().getValues();
var headers = arrayOfArrays.shift();
return arrayOfArrays.map(function (row) {
return row.reduce(function (memo, value, index) {
if (value) {
memo[headers[index]] = value;
}
return memo;
@dsernst
dsernst / squares.c
Created June 16, 2015 20:12
Compiling some C
#include<stdio.h>
void squares(int v)
{
for (int i=1;i<v+1;i++) {
printf("%d ", i*i);
}
printf("\n");
}
@dsernst
dsernst / Google Apps Script.md
Last active August 29, 2015 14:22
Outline from my "Google Apps Script" Lightning Talk @ Hack Reactor

Lightning Talk: Google Apps Script

  • What is Google Apps Script
    • Homepage: https://developers.google.com/apps-script/
    • Extend Google Apps: "Increase the power of your favorite Google apps — like Calendar, Docs, Drive, Gmail, and Sheets. Apps Script lets you do more with Google. All on a JavaScript platform in the cloud."
    • Written in Javascript
      • with lots of new Globals
      • everything is synchronous, no callbacks
      • have to use the Apps Script IDE
  • Runs on Google servers
@dsernst
dsernst / quicksort.hs
Created June 8, 2015 03:30
@nsluss shows me how to compile my first Haskell program
qs :: (Ord a) => [a] -> [a]
qs [] = []
qs (x:xs) = qs (lessThan x xs) ++ [x] ++ qs (greaterThan x xs)
where lessThan val ys = [y | y <- ys, val >= y]
greaterThan val ys = [y | y <- ys, val < y]
// requires ?id=<GOOGLE_SHEET_ID>
// you must have authorized access to the spreadsheet
function doGet(request) {
if (!request.parameter.id) {
return ContentService.createTextOutput(JSON.stringify(new Error('no Google Sheet id set')))
.setMimeType(ContentService.MimeType.JSON);
}
var cache = getNotesAndFormulas(request.parameter.id);
// ?id=<GOOGLE_SHEET_ID>
function doGet(request) {
if (!request.parameter.id) {
return ContentService.createTextOutput(JSON.stringify(new Error('no Google Sheet id set')))
.setMimeType(ContentService.MimeType.JSON);
}
var cache = cacheNotesAndFormulas(request.parameter.id);
// Return cache as JSON
@dsernst
dsernst / git-wiki-options.md
Created May 9, 2015 01:02
research on using git to power a wiki
@dsernst
dsernst / Unified-Cloud-Formation.json
Created March 24, 2015 18:17
Template for setting up your own private and secure VPN on AWS.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Setting up your own private and secure VPN. You can read instructions on our blog https://www.webdigi.co.uk/blog/2015/how-to-setup-your-own-private-secure-free-vpn-on-the-amazon-aws-cloud-in-10-minutes/ and you can follow video instructions on Youtube https://www.youtube.com/watch?v=fBBERp5CUgo",
"Mappings": {
"AWSInstanceType2Arch": {
"High.Speed.VPN-Paid": {
"InstanceType": "t2.medium"
},
"Standard.VPN-Free": {
"InstanceType": "t2.micro"