Skip to content

Instantly share code, notes, and snippets.

View alana314's full-sized avatar

alana314

  • Ayzenberg
  • Los Angeles
View GitHub Profile
@alana314
alana314 / robotArmServer.ino
Created February 25, 2018 02:18
Arduino script for listening for bridge commands and controlling a robot arm
/*
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:
@alana314
alana314 / armproxy.js
Created February 25, 2018 02:11
Node Proxy to forward commands to Yun
//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;
@alana314
alana314 / robotarmlamda.py
Last active February 25, 2018 02:15
Robot Arm Lamda that hits another node endpoint
# -*- 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,
@alana314
alana314 / getlatestwiredarticle.js
Last active February 24, 2018 07:21
Get latest wired article
//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);
@alana314
alana314 / Google Sheets Formula for Address Formatting
Created January 13, 2018 08:07
Google Sheets/Excel Formula for formatting addresses
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)
@alana314
alana314 / commandlineinteractive.php
Created November 28, 2017 01:24
Use PHP to interact with stdin
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";
//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);}
//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);}
@alana314
alana314 / gist:7a832604714af7043dd619b499185a3d
Created April 10, 2017 23:07
Map a range from one to another in javascript for parallax
//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)
@alana314
alana314 / ngrokService.sh
Last active March 31, 2017 17:36 — forked from mendesbarreto/ngrokService.sh
Script to start Ngrok at raspberry every boot
#! /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)