Skip to content

Instantly share code, notes, and snippets.

View rwisner's full-sized avatar
👋
Hello World

Rob Wisner rwisner

👋
Hello World
  • Star Publishing
  • Tucson, AZ
View GitHub Profile
@rwisner
rwisner / drawMap.js
Created October 6, 2020 18:19
Draw a map using leafletjs and tiles from mapbox
function drawMap() {
// draw a map using leafletjs and tiles from mapbox
var mymap = L.map('mapid').setView([32.221041, -110.971143], 15);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'ACCESS_TOKEN_HERE'
@rwisner
rwisner / listSheet.js
Last active October 1, 2020 18:13
List Google Sheet rows
function listSheet() {
fetch('https://api.sheetson.com/v2/sheets/SHEET_NAME_HERE', {
withCredentials: true,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY_HERE',
'X-Sheetson-Spreadsheet-Id': 'SHEET_ID_HERE'
}
})
.then(function(resp) { return resp.json() })
@rwisner
rwisner / fetchweather.js
Created September 27, 2020 20:48
Get weather data from openweathermap and display the current temp
// get weather data from openweathermap and display the current temp
function fetchWeather() {
fetch("https://api.openweathermap.org/data/2.5/weather?zip=85705,US&appid=APIKEYHERE&units=imperial")
.then(function(resp) { return resp.json() })
.then(function(data) {
document.getElementById("weather").innerHTML = "It is currently " + data.main.temp + "&deg; in Tucson, AZ";
})
.catch(function() {
document.getElementById("weather").innerHTML = "Error in fetchWeather function";
});
@rwisner
rwisner / displaygreeting.js
Created September 27, 2020 20:45
Display good morning, afternoon or evening based on the time
// display good morning, afternoon or evening based on the time
function displayGreeting() {
var date = new Date();
var hour = date.getHours();
var description = "";
if (hour < 12) {
description = "morning";
} else if (hour < 17) {
description = "afternoon";
} else {
@rwisner
rwisner / displayrssfeed.js
Last active September 27, 2020 20:46
Fetch an RSS feed and display the title and description
// fetch an RSS feed and display the title and description
function displayRSSFeed() {
var origURL = 'https://tucson.com/search/?f=rss&t=article&c=news/local&l=5&s=start_time&sd=desc';
// feednami doesn't like & so replace with %26
var replacedURL = origURL.replace(/&/g, "%26");
feednami.load(replacedURL,function(result) {
if (result.error) {
console.log(result.error);
} else {
var entries = result.feed.entries
In this sentance <strong>these words are bold</strong>
<h1>Heading one</h1>
<h2>Heading two</h2>
<h3>Heading three</h3>
<h4>Heading four</h4>
<h5>Heading five</h5>
<h6>Heading six</h6>
@rwisner
rwisner / restaurant_sort.html
Created April 28, 2019 17:32
Firebase Restaurant List Sort
<script src="https://www.gstatic.com/firebasejs/4.12.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyBDNw-JYXcsGxmoy3VR3nIoCpgBMuFtWqw",
authDomain: "restaurant-f0492.firebaseapp.com",
databaseURL: "https://restaurant-f0492.firebaseio.com",
projectId: "restaurant-f0492",
storageBucket: "restaurant-f0492.appspot.com",
messagingSenderId: "531297456626"
@rwisner
rwisner / Swift3JSONStructs.swift
Created August 22, 2017 16:23 — forked from stinger/Swift3JSONStructs.swift
Swift 3: JSON-serializable structs using protocols
//: # Swift 3: JSON-serializable structs using protocols
//: Most of the implementation is based on the code in [this blog post](http://codelle.com/blog/2016/5/an-easy-way-to-convert-swift-structs-to-json/)
import Foundation
//: ### Defining the protocols
protocol JSONRepresentable {
var JSONRepresentation: Any { get }
}
protocol JSONSerializable: JSONRepresentable {}
#!/bin/bash
# =========================
# Add User OSX Command Line
# =========================
# An easy add user script for Max OSX.
# Although I wrote this for 10.7 Lion Server, these commands have been the same since 10.5 Leopard.
# It's pretty simple as it uses and strings together the (rustic and ancient) commands that OSX
# already uses to add users.