This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 © <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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 + "° in Tucson, AZ"; | |
}) | |
.catch(function() { | |
document.getElementById("weather").innerHTML = "Error in fetchWeather function"; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In this sentance <strong>these words are bold</strong> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Heading one</h1> | |
<h2>Heading two</h2> | |
<h3>Heading three</h3> | |
<h4>Heading four</h4> | |
<h5>Heading five</h5> | |
<h6>Heading six</h6> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: # 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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |