Skip to content

Instantly share code, notes, and snippets.

View adamrunner's full-sized avatar

Adam Runner adamrunner

View GitHub Profile
@adamrunner
adamrunner / vim_cheatsheet.md
Created September 19, 2016 23:13 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@adamrunner
adamrunner / https_server_nginx.conf
Last active November 18, 2023 18:27
Server Directive for Nginx, redirect from HTTP to HTTPS.
#NOTE: Redirect to HTTPS
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
@adamrunner
adamrunner / www.conf
Created March 31, 2016 23:23
PHP5-FPM www pool configuration
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
@adamrunner
adamrunner / gen_cert.sh
Created March 31, 2016 18:26
bash script to generate a self signed certificate for development use
#!/bin/bash
# Bash shell script for generating self-signed certs. Run this in a folder, as it
# generates a few files. Large portions of this script were taken from the
# following artcile:
#
# http://usrportage.de/archives/919-Batch-generating-SSL-certificates.html
#
# Additional alterations by: Brad Landers
# Date: 2012-01-27
@adamrunner
adamrunner / nginx_vim.sh
Last active March 30, 2016 05:29
add the nginx syntax plugin to vim
#!/bin/sh
mkdir -p ~/.vim/syntax
echo "au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif" > ~/.vim/filetype.vim
wget -O ~/.vim/syntax/nginx.vim http://www.vim.org/scripts/download_script.php?src_id=19394
@adamrunner
adamrunner / temp_uploader.rb
Last active March 27, 2016 22:37
A very simple data polling ruby script. It's intended to be ran on a Cron schedule where it will then poll the data from my ESP8266, and also the Forecast.IO API. It will then upload the data to data.sparkfun.com and also my very own ElasticSearch cluster.
require 'time'
require 'forecast_io'
require 'curb'
phant_public_key = '---'
phant_private_key = '---'
location = ['45.2912', '-122.4037']
#NOTE: This script is intended to be ran on a Cron schedule.
ForecastIO.configure do |configuration|
configuration.api_key = '---'
@adamrunner
adamrunner / esp8266-temperature-server.ino
Last active March 27, 2016 21:45
A simple ESP8266 web server that acts as a microservice, reports the temperature at http://ip-address/ or http://ip-address/temp
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <OneWire.h>
const char* ssid = "wifi";
const char* password = "password";
const long pollTempInterval = 10000;
String displayedTempF = "n/a";
unsigned long previousMillisTemp;
@adamrunner
adamrunner / esp8266-ds18s20.ino
Created February 28, 2016 08:25
Read a DS18x20 temperature sensor and upload the data to data.sparkfun.com
#include <OneWire.h>
#include "ESP8266WiFi.h"
#include <Phant.h>
//NOTE: Do your configuration here:
const char* ssid = "Your-wifi-ssid";
const char* password = "your-wifi-password";
//NOTE: interval is in milliseconds
const long sendInterval = 600000;
const char PhantHost[] = "data.sparkfun.com";
const char PublicKey[] = "public-key-from-sparkfun";
@adamrunner
adamrunner / ds1820.lua
Created February 23, 2016 17:27
Send tempature (in degrees C) from a DS1820 temp chip to thingspeak.com, runs in NodeMCU on a ESP8266
-- Measure temperature and post data to thingspeak.com
-- 2014 OK1CDJ
--- Tem sensor DS18B20 is conntected to GPIO0
--- 2015.01.21 sza2 temperature value concatenation bug correction
http = require('http')
pin = 4
ow.setup(pin)
counter=0
lasttemp=-999
#NOTE: gem install blinkstick first
require "blinkstick"
def cycle_colors(blinkstick)
percentages = [0,0,0]
cycle = 1
while true do
sleep(0.01)
if percentages.first <= 100 && cycle.odd?
percentages = percentages.map {|a| a+1}