Skip to content

Instantly share code, notes, and snippets.

View adamabernathy's full-sized avatar
👋

Adam C. Abernathy adamabernathy

👋
View GitHub Profile
@adamabernathy
adamabernathy / randomKey.js
Last active January 10, 2018 10:22
Generates a random key name such as "yfva-pyxd-qxfv-ftjr"
/**
* Generates a random key name such as "yfva-pyxd-qxfv-ftjr"
* @param {number} quartets
* @returns {string}
*
* (C) 2018 Adam C. Abernathy, [email protected]. Licence MIT
* https://gist.github.com/adamabernathy/4047f2e79b05af2d5f8b23e0748ac1a2
*/
const randomKey = (quartets = 4) => {
const f = () => Math.floor(Math.random() * 26) + 97; // Lowercase charcodes: 97->122
@adamabernathy
adamabernathy / parseQueryStatement.js
Last active January 10, 2018 17:15
Parse string with "parameter:value" style search syntax to object.
/**
* Parse string with `parameter:value` style search syntax to object.
*
* Examples:
* state:ut --> {state: ['ut']}
* state:ut,az,id --> {state: ['ut', 'az', 'id]}
* complete --> {complete: 1} // defaults to value of 1
* {air_temp > 10} --> {filter_on: '(air_temp > 10)'} // explicit statement
*
* @param {string} blob, query
@adamabernathy
adamabernathy / array.js
Created December 26, 2017 15:20
Array tricks
// Create array of n length
const range = n => Array.from({ length: n }, (v, i) => i);
@adamabernathy
adamabernathy / grades.html
Last active December 22, 2017 15:07
Nathan's grade calculator
<html>
<head>
<style>
ul {
list-style: none;
}
label {
margin-right: 1em;
<html>
<head>
<style>
h1 {
text-align: center;
}
.container {
padding: 0 5em 5em 5em;
@adamabernathy
adamabernathy / mesonet_example.py
Created August 19, 2017 17:22
Python example using urllib, urllib2 and json to interface with the SL Mesonet API
from urllib import urlencode
from urllib2 import Request, urlopen, URLError, HTTPError
import json
def fetch_data(service, parameters={}, debug=False):
'''Calls the Mesonet API service and returns data as a dictionary'''
baseurl = 'https://api.mesowest.net/v2/'
_parameters = urlencode(parameters)
payload = None # Set default to None, so you can catch errors later
@adamabernathy
adamabernathy / weather-ticker.html
Last active June 27, 2017 16:34
Scrolling Weather Ticker
<html>
<head>
<title>Scrolling Weather Ticker</title>
<style>
@-webkit-keyframes ticker {
0% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
visibility: visible;
@adamabernathy
adamabernathy / latest.html
Last active June 14, 2017 22:07
Simple example using Mesonet Latest
<html>
<body>
<h2>Simple Latest Example</h2>
<p>See the console for the full data response.</p>
<hr/>
<div id="result"></div>
</body>
<script>
@adamabernathy
adamabernathy / index.html
Last active February 13, 2017 16:12
Image viewer for brian
<!DOCTYPE html>
<!--
Photo Viewer
View all images in a directory by clicking buttons.
This allows you to stay on the same page rather than clicking the back button every time you want to see a different image.
Image name can not have any spaces!!
Created by Brian Blaylock
Date: November 30, 2015
Updated with bootstrap style: February 10, 2017
http://home.chpc.utah.edu/~u0553130/Brian_Blaylock/home.html
@adamabernathy
adamabernathy / simple_test.py
Created February 6, 2017 16:14
Simple assertion test
# encoding: utf-8
"""
TESTING SCRIPT for Time Rate of Change - QC Flag Test
"""
def assert_(statement, result, caption='*'):
"""
Simple assertion test
"""