Skip to content

Instantly share code, notes, and snippets.

View dillonhafer's full-sized avatar
🍄
Nintendo Power

Dillon Hafer dillonhafer

🍄
Nintendo Power
View GitHub Profile
@dillonhafer
dillonhafer / fb.css
Created June 28, 2015 21:32
My facebook style overrides
/* Main Header */
._4f7n {
background-image: none;
border-bottom: none;
background-color: rgba(0, 0, 0, 0.7);
}
._4f7n:after {background-image:none;}
/* Chat Button */
.fbNubButton img {display:none;}
@dillonhafer
dillonhafer / nginx
Created June 29, 2015 02:09
Nginx init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@dillonhafer
dillonhafer / dates.sql
Created July 14, 2015 23:25
Count posts by date
with posts as (
select date((created_at at time zone 'UTC' at time zone 'America/New_York')::timestamptz) as post_date
from posts
)
select dates_table.date, count(posts.post_date) from (
select (generate_series(now()::date - '29 day'::interval, now()::date, '1 day'::interval))::date as date
) as dates_table
left outer join posts
on posts.post_date=dates_table.date
group by dates_table.date
#!/bin/bash
base_dir=/Users/dillon
# Folders with sync scripts
home_sync=$base_dir/Documents/Home
dirs=($home_sync)
for dir in "${dirs[@]}"; do

Talks can be either:

  1. Case study
  2. Proof of Concept
  3. Tutorial
  4. Benchmark
  5. Presentation of a new feature
@dillonhafer
dillonhafer / sun_data.rb
Created September 18, 2016 20:34
Generate Sunrise/Sunset Times, including leap day
require 'net/http'
require 'uri'
require 'nokogiri'
require 'csv'
require 'date'
def get_data(month:,day:,year: 2016)
print "\e[32m.\e[m"
uri = URI.parse("http://aa.usno.navy.mil/rstt/onedaytable?ID=AA&year=#{year}&month=#{month}&day=#{day}&state=DC&place=Portage%2C+IN")
response = Net::HTTP.get_response(uri)
@dillonhafer
dillonhafer / sun_data.csv
Created September 18, 2016 20:36
CVS of 2016 sundata
date sunrise sunset
Jan-01 7:15 a.m. 4:29 p.m.
Jan-02 7:16 a.m. 4:30 p.m.
Jan-03 7:16 a.m. 4:31 p.m.
Jan-04 7:16 a.m. 4:32 p.m.
Jan-05 7:16 a.m. 4:33 p.m.
Jan-06 7:16 a.m. 4:34 p.m.
Jan-07 7:15 a.m. 4:35 p.m.
Jan-08 7:15 a.m. 4:36 p.m.
Jan-09 7:15 a.m. 4:37 p.m.
@dillonhafer
dillonhafer / sunlights.go
Created September 18, 2016 21:10
Check for sunrise/sunset every minute
package main
import (
"bufio"
"encoding/csv"
"os"
"strings"
"time"
)
@dillonhafer
dillonhafer / slack_geo.rb
Created September 29, 2016 02:27
Slack bot to get featured geography fact
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
require 'json'
require 'net/http'
def geo_fact
page = Nokogiri::HTML(open("https://en.wikipedia.org/wiki/Portal:Geography"))
column = page.css('.portal-column-left')
if column.css('#Featured_article').text == "Featured article"
@dillonhafer
dillonhafer / router-tls.sh
Last active October 2, 2016 03:10
UBTN Let's Encrypt
#!/bin/bash
set -e
echo 'Creating and transferring certificates...'
certbot certonly -a webroot --webroot-path=/Users/dillon/dev/scripts/tls -d router.dillonhafer.com -d local.router.dillonhafer.com --logs-dir=/Users/dillon/dev/scripts --config-dir=/Users/dillon/dev/scripts --work-dir=/Users/dillon/dev/scripts
cd /Users/dillon/dev/scripts/live/router.dillonhafer.com
cat privkey.pem fullchain.pem >> server.pem
scp server.pem chain.pem local.router.dillonhafer.com: > /dev/null 2>&1
ssh local.router.dillonhafer.com 'sudo cp server.pem chain.pem /etc/lighttpd/' > /dev/null 2>&1
ssh local.router.dillonhafer.com 'sudo chown root:www-data /etc/lighttpd/server.pem /etc/lighttpd/chain.pem' > /dev/null 2>&1
echo 'Done.'