Skip to content

Instantly share code, notes, and snippets.

View DecisionNerd's full-sized avatar

David Spencer DecisionNerd

View GitHub Profile
@DecisionNerd
DecisionNerd / fibonacci.py
Created May 25, 2012 02:06
A module of functions about non-zero Fibonacci numbers
"""A module of functions about non-zero Fibonacci numbers."""
import sys
def fib(n):
"""Print the non-zero Fibonacci numbers less than n."""
a, b =1,1
while b<n:
print b,
a, b = b, a+b
@DecisionNerd
DecisionNerd / pylibpcap.py
Created July 7, 2012 02:06
copy of pylibpcap: python module for libpcap v0.6.4
#!/usr/bin/env python2
"""copy of pylibpcap, BSD license http://sourceforge.net/projects/pylibpcap/"""
import pcap
import sys
import string
import time
import socket
import struct
<!DOCTYPE html>
<html>
<head>
<title>Leaflet</title>
<link rel="stylesheet" href="http://code.leafletjs.com/leaflet-0.3.1/leaflet.css" />
<script src="http://code.leafletjs.com/leaflet-0.3.1/leaflet.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script src="https://raw.github.com/gist/2197042/2b90c41b39b7d5b3a851d8f256de2ebd3fe1fb74/leaflet-google.js"></script>
</head>
<body>
@DecisionNerd
DecisionNerd / algebraL2P6.py
Last active December 16, 2015 21:29
Python function for solving the polynomial substitution problems in Udacity College Algebra Lesson 2 Problem 6 (SJSU MA008)
def l2p6(x):
ans = (x**3)+(2*(x**2))+(3*x)-2
print ans
@DecisionNerd
DecisionNerd / algebraL2P7.py
Created May 2, 2013 03:33
Python function for solving the polynomial substitution problems in Udacity College Algebra Lesson 2 Problem 7 (SJSU MA008)
def l2p7(x):
ans = (3+x)/(x**2.)
print ans
@DecisionNerd
DecisionNerd / csvLogstash.sh
Last active November 13, 2015 02:37
ingesting csv files into logstash requires removal of the header row in the first line of the file. This script processes csv files in the directory where it is executed. Script runs continuously until stopping with ctrl+Z
#!/bin/bash
# ingesting csv files into logstash requires removal of the header row in the
# first line of the file. This script processes csv files in the directory
# where it is executed. Script runs continuously until stopping with ctrl+Z
#specify directory to send files for ingest (without trailing /)
DEST=/home/user/Test/forIngest
echo "processing csv files in $(pwd) for ingest by logstash..."
@DecisionNerd
DecisionNerd / csv2json.sh
Created November 13, 2015 03:13
CSV to JSON converter using BASH. Original script from http://blog.secaserver.com/2013/12/convert-csv-json-bash/
#!/bin/bash
# CSV to JSON converter using BASH
# original script from http://blog.secaserver.com/2013/12/convert-csv-json-bash/
# thanks SecaGuy!
# Usage ./csv2json.sh input.csv > output.json
input=$1
[ -z $1 ] && echo "No CSV input file specified" && exit 1
[ ! -e $input ] && echo "Unable to locate $1" && exit 1
input {
http_poller {
# List of urls to hit
# URLs can either have a simple format for a get request
# Or use more complex HTTP features
urls => {
BWI => "http://services.faa.gov/airport/status/BWI?format=application/json"
IAD => "http://services.faa.gov/airport/status/IAD?format=application/json"
DCA => "http://services.faa.gov/airport/status/DCA?format=application/json"
}
@DecisionNerd
DecisionNerd / gist:35833e912c9110958fac874d0ef7388e
Last active December 31, 2017 03:16
Raspbian Keyboard reconfiguration Instructions
sudo dpkg-reconfigure keyboard-configuration #to reconfigure your keyboard.
#Choose English (US) for keyboard layout (second page of configuration).
#Then either reboot or
invoke-rc.d keyboard-setup start #to reload the keymap.Code: Select all
#!/bin/bash
# Adds R to apt and install it
#
# Instructions:
# sudo chmod 700 InstallR.sh
# ./FirstTimeInstallR.sh
# Install R
sudo echo "deb http://cran.rstudio.com/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list