Skip to content

Instantly share code, notes, and snippets.

View daviseford's full-sized avatar

Davis Ford daviseford

View GitHub Profile
@daviseford
daviseford / upload.sh
Last active February 14, 2018 16:39
upload.sh
#!/bin/bash
# This script does some various utility tasks
# Builds the static site using Jekyll
# And syncs the generated site with S3
# You can run this script with three options
# -i | enable Image processing. Creates thumbnails and quickly compresses images.
# -c | enable maximum Compression for images. Creates thumbnails, thoroughly compresses images, and takes a long time doing it
# -n | No-upload mode. Doesn't upload the build to S3.
# -s | enable Setup mode. Downloads the necessary npm files for compression
@daviseford
daviseford / mining_script.bat
Last active January 22, 2018 23:10
eth mining script
@ECHO OFF
REM Configuration
COLOR 0a
REM Kill explorer and restart
taskkill /im explorer.exe /f
start explorer.exe
REM Disable some programs
@daviseford
daviseford / collapsible_section.js
Last active January 21, 2018 01:45 — forked from misskillingsworth/collapsible_section.js
Create a collapsible page section
<script type="text/javascript">
(function () { // Immediately invoked function enclosure
var _store = [
{
section: '#lp-pom-block-160',
content: '#lp-pom-box-322',
button: '#lp-pom-button-245'
},
@daviseford
daviseford / electron_changes.js
Created February 11, 2017 20:51
Importing an image into electron-react-boilerplate
// First, import the image like this
import image_src from './../img/your_image.png';
// Use it inline like so (in React)
class YourImage extends React.Component {
render(){
return (
<img src={image_src} />
)
}
@daviseford
daviseford / flatten_arrays_of_arbitrary_depths.js
Created January 6, 2017 02:10
Flatten arrays of arbitrary depths, bringing all integers to top level
'use strict';
function flatten(array) {
let result = [];
const f = function (x) {
if (Array.isArray(x)) {
x.forEach((x) => { f(x) });
} else if (typeof x === 'number') {
result.push(x)
}
@daviseford
daviseford / parts.txt
Created November 29, 2016 14:11
Hula hoop Parts list
https://www.adafruit.com/products/276 - 5V 2A (2000mA) switching power supply
https://www.adafruit.com/products/368 - Female DC Power adapter - 2.1mm jack to screw terminal block
https://www.adafruit.com/products/1461 - LED strip, but should've used the smaller strip (and I'm sure we would've if we knew it was there 😣 )
https://www.adafruit.com/products/2880 - 2-pin JST SM Plug + Receptacle Cable Set
https://www.adafruit.com/products/1311 - Hook-up Wire Spool Set - 22AWG Solid Core - 6 x 25 ft
https://www.adafruit.com/products/592 - USB cable - A/MicroB - 3ft
An Arduino Uno (R3)
http://hoopsupplies.com/shop/?id=17&collid=57 - Push Buttons - Package of 10; Select Size: Regular
https://www.amazon.com/dp/B000FMZ6D4 - White High Density Polyethylene (HDPE) Tubing, 3/4" ID, 1" OD, 1/4" Wall, 100' Length
Wire shrink
@daviseford
daviseford / led_hula_hoop_code.ino
Created November 26, 2016 17:33
A really awful bit of code that ran our failed led hula hoop product. http://daviseford.com/building-an-led-hula-hoop
#include "LPD8806.h"
#include "SPI.h"
#include <avr/sleep.h>
#include "hearts.h"
//since data is on 11 and clock is on 13, we can use hardware SPI
LPD8806 strip = LPD8806(160); //32 LED's per meter * 5
int demoCaseNumber = 0;
@daviseford
daviseford / openssl_error_fix_django.sh
Created November 16, 2016 16:36
A bash command that fixes 'django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/anaconda/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib'
# Run this in your terminal
# Credit: http://stackoverflow.com/questions/27264574/import-psycopg2-library-not-loaded-libssl-1-0-0-dylib
export DYLD_FALLBACK_LIBRARY_PATH=$HOME/anaconda/lib/:$DYLD_FALLBACK_LIBRARY_PATH
@daviseford
daviseford / title_extended.py
Last active November 16, 2016 01:17
Python: Capitalize First Letter of Each Word in a String (including after punctuation)
import re
import string
def lowercase_match_group(matchobj):
return matchobj.group().lower()
# Make titles human friendly
# http://daviseford.com/python-string-to-title-including-punctuation
@daviseford
daviseford / category_reporting_dashboard.php
Last active August 29, 2015 14:26
multiple wordpress installations, specific post category by date
<?php
/* By Davis Ford, 2015
* http://daviseford.com
* Please feel free to re-use this code with credit.
*/
$servername = "localhost";
$username_Sample = "your_mysql_username";
$password_Sample = "your_mysql_password";