This file contains hidden or 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
/* | |
Arduino Yún Bridge example | |
This example for the YunShield/Yún shows how | |
to use the Bridge library to access the digital and | |
analog pins on the board through REST calls. | |
It demonstrates how you can create your own API when | |
using REST style calls through the browser. | |
Possible commands created in this shetch: |
This file contains hidden or 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
//replace {myport} with any port number and {mytoken} with any URL-friendly string. | |
var request = require('request'); | |
const express = require('express') | |
const app = express() | |
app.get('/', (req, res) => { | |
if(req.query.token != '{mytoken}') | |
{ | |
res.send('Invalid Token'); | |
return; |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
# | |
# Licensed under the Amazon Software License (the "License"). You may not use this file except in | |
# compliance with the License. A copy of the License is located at | |
# | |
# http://aws.amazon.com/asl/ | |
# | |
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, |
This file contains hidden or 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
//Run in console on a page with jQuery. (Most web pages) | |
jQuery.getJSON('https://www.wired.com/wp-json/wp/v2/posts/', function(response){console.log(response[0].title, response[0].content);}) | |
//Here's a version that doesn't need jQuery: | |
xhr = new XMLHttpRequest; | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == 4 && xhr.status == 200) { | |
response = JSON.parse(xhr.responseText); | |
console.log(response[0].title, response[0].content); |
This file contains hidden or 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
For cells: | |
C3: First Name 1 | |
D3: Last Name 1 | |
E3: First Name 2 | |
F3: Last Name 2 | |
H3: Mailing Address 1 | |
I3: Mailing Address 2 (Optional) | |
J3: City | |
K3: State | |
(L3: Country unused) |
This file contains hidden or 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
while(true): | |
echo "Are you sure you want to do this? Type 'yes' to continue: "; | |
$handle = fopen ("php://stdin","r"); | |
$line = fgets($handle); | |
if(trim($line) == 'yes'){ | |
break; | |
} | |
endwhile; | |
fclose($handle); | |
echo "\n"; |
This file contains hidden or 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
//Calculates current em size in pixels, tests current Foundation 5 media query size and logs it in the console | |
//Create a new bookmark and paste this as the URL: | |
javascript: var width = document.body.clientWidth;var em = parseFloat(getComputedStyle(document.body).getPropertyValue('font-size'));if (width < 40 * em) { console.log('small', width);} else if (width < 64 * em) { console.log('medium', width);} else if (width < 90 * em) { console.log('large', width);} else if (width < 120 * em) { console.log('xlarge', width);} else { console.log('xxlarge', width);} |
This file contains hidden or 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
//based on Bootstrap 3 standard media queries | |
//make a new bookmark and add this: | |
javascript: var width = document.body.clientWidth;if (width < 480) { console.log('screen-xs', width);} else if (width < 768) { console.log('screen-sm', width);} else if (width < 992) { console.log('screen-md', width);} else if (width < 1200) { console.log('screen-lg', width);} else { console.log('screen-xl', width);} |
This file contains hidden or 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
//map a range from one to another, protecting limits | |
Number.prototype.map = function(in_min, in_max, out_min, out_max) { | |
var output = (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; | |
if (out_max > out_min && output < out_min) | |
output = out_min; | |
if (out_max > out_min && output > out_max) | |
output = out_max; | |
if (out_max < out_min && output < out_max) | |
output = out_max; | |
if (out_max < out_min && output > out_min) |
This file contains hidden or 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/sh | |
# /etc/init.d/ngrok | |
case "$1" in | |
start) | |
echo "Ngrok service is starting" | |
screen -d -m /usr/local/bin/ngrok start -all -config /home/pi/.ngrok2/ngrok.yml | |
echo "Ngrok service was started" | |
;; | |
stop) |