Skip to content

Instantly share code, notes, and snippets.

View knorthfield's full-sized avatar

Kris Northfield knorthfield

View GitHub Profile
@knorthfield
knorthfield / gist:e9c0519a113f4ef4304f
Last active August 29, 2015 14:18
Remove an HTML element
var clear = document.getElementById('clear'),
overlay = document.getElementById('overlay');
clear.addEventListener('click', function(){
overlay.parentNode.removeChild(overlay);
})
@knorthfield
knorthfield / post_to_csv.php
Last active August 29, 2015 14:23
Add $_POST values to CSV
<?php
if( $_SERVER['REQUEST_METHOD'] == 'post' ){
$fp = fopen('../registrations.csv', 'a');
fputcsv($fp, $_POST);
fclose($fp);
}
?>
@knorthfield
knorthfield / numbers_explode.txt
Created May 31, 2016 09:54
Formulas for numbers to get first and last name from full name
LEFT(A2,FIND(" ",A2)−1)
RIGHT(A2,LEN(A2)−FIND(" ",A2))
@knorthfield
knorthfield / implode.php
Created July 21, 2016 16:58
Make text from array with keys
$message = implode("\n", array_map(function ($v, $k) { return $k . ': ' . $v; }, $_POST, array_keys($_POST)));
@knorthfield
knorthfield / kiosk.md
Last active July 25, 2016 15:21
Setting up Raspberry Pi Status Board
@knorthfield
knorthfield / mail.php
Created November 10, 2016 16:03
PHP basic mailer
<?php
if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
$message = implode("\n", array_map(function ($v, $k) { return $k . ': ' . $v; }, $_POST, array_keys($_POST)));
$headers = 'From: [email protected]';
mail('[email protected]', 'Website Contact Form', $message, $headers);
header("Location: http://www.example.com/thankyou");
die();
}
?>
@knorthfield
knorthfield / datetime_picker.js
Last active February 23, 2017 15:35
iOS like date and time pickers
'use strict';
// Making up for Safari's lack of native date picker
// Trying to ape the iOS one
var mac_os_safari_datetime_picker = {
init: function(){
document.querySelectorAll('input[type="date"]').forEach(function(date_input){
date_input.addEventListener('focus', mac_os_safari_datetime_picker.date.show_date_picker);
date_input.addEventListener('click', function(event){
@knorthfield
knorthfield / avatars.sh
Created September 11, 2017 07:30
Download a sequence of images
#!/bin/bash
for i in $(seq -f "%02g" 1 29)
do
curl -LO https://app.fullstory.com/s/img/avatars/[email protected]
done
### Keybase proof
I hereby claim:
* I am knorthfield on github.
* I am knorthfield (https://keybase.io/knorthfield) on keybase.
* I have a public key ASCBtEiD0LexEljuEE16WHUP6VUewBlyvyN0hB-waykjBAo
To claim this, I am signing this object:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.