Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View geedew's full-sized avatar

Drew geedew

View GitHub Profile
@geedew
geedew / vagrant-scp
Last active July 22, 2017 15:16
Copying files to a Vagrant VM from host
#!/bin/sh
# Change these settings to match what you are wanting to do
FILE=/File/To/Copy
SERVER=localhost
PATH=/Where/To/Put/File
OPTIONS=`vagrant ssh-config | awk -v ORS=' ' '{print "-o " $1 "=" $2}'`
scp ${OPTIONS} $FILE vagrant@$SERVER:$PATH
@geedew
geedew / gist:97c66b187db2ac8ecebaef535750a76b
Created December 2, 2017 14:53 — forked from mhawksey/gist:1170597
Google Apps Script to fill in a Document template with Spreadsheet data
function onOpen() {
var menuEntries = [ {name: "Create Diary Doc from Sheet", functionName: "createDocFromSheet"}];
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.addMenu("Fitness Diaries", menuEntries);
}
function createDocFromSheet(){
var templateid = "1O4afl8SZmMxMFpAiN16VZIddJDaFdeRBbFyBtJvepwM"; // get template file id
var FOLDER_NAME = "Fitness Diaries"; // folder name of where to put completed diaries
// get the data from an individual user
@geedew
geedew / Student Schedule
Created March 2, 2018 20:36
An Octothorpe delimited template for use with Google Sheets report creations.
##STUDENT_NAME##
Class Schedule
Teacher Name: ##TEACHER_NAME##
Grade: ##GRADE##
Session 1 Name: ##SESSION_1_NAME##
Teacher: ##SESSION_1_TEACHER##
When: ##SESSION_1_DATE##
Room: ##SESSION_1_ROOM##
@geedew
geedew / gist:41e4ba0e043efe645bdc95db1f9008dc
Created March 3, 2018 19:12
Generating reports from a G Sheet into a Doc
/**
* FOLDER_NAME
* The path, relative to the Sheet the script is running from, where new reports are created
*/
var FOLDER_NAME = "Schedules";
/**
* SPREADSHEET_MAPPING
* Contains Template variables and the columns
var SPREADSHEET_MAPPING = {
@geedew
geedew / unlink.sh
Created March 14, 2018 11:44
Removing a cross-platform symlink.
@geedew
geedew / whitelisted-x-frame-options
Created February 20, 2014 15:35
A whilte-listed Apache solution for X-Frame-Options SAMEORIGIN
<VirtualHost *:80>
# ...
<IfModule mod_headers.c>
# Allow some urls, block all others; whitelisting
<LocationMatch ^((?!(firstUrlAllowed|secondUrlAllowed)).)*$>
Header always append X-Frame-Options SAMEORIGIN # Block any site from applying an iframe.
</LocationMatch>
</IfModule>
</VirtualHost>
@geedew
geedew / remove-known-hosts.sh
Last active February 18, 2020 17:29
Quickly removing a ~/.ssh/known_hosts entry
# ssh-keygen -R hostname [-f known_hosts_file]
# ssh-keygen -r hostname [-f input_keyfile] [-g]
#e.g.
ssh-keygen -R 192.168.99.99
ssh-keygen -R mytestdomain.vagrant
@geedew
geedew / node-rm-rf.js
Last active February 3, 2021 12:36
Removing a directory that is not empty in NodeJS
var fs = require('fs');
var deleteFolderRecursive = function(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
@geedew
geedew / symlink.sh
Last active November 21, 2022 10:00
A cross platform symlink method in Bash