Skip to content

Instantly share code, notes, and snippets.

View alana314's full-sized avatar

alana314

  • Ayzenberg
  • Los Angeles
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / autoscrollwebsite.js
Created April 20, 2018 22:55
Auto scroll website
//Paste this in console (in another window) to auto-scroll a website, useful for video capturing.
var i = 0;setInterval(function(){window.scrollTo(0, i);i = i+ 2;}, 5);
@alana314
alana314 / testheadphones.sh
Created March 21, 2019 17:59
Test if headphones are plugged in -- OS X shell script
#!/bin/bash
if system_profiler SPAudioDataType | grep --quiet Headphones; then
echo plugged in
else
echo not plugged in
fi
@alana314
alana314 / youtube-dl-mp4
Created December 5, 2019 04:58
youtube-dl-mp4 for forcing youtube-dl to download mp4
#!/bin/bash
#for OS X or linux
#place this file in /usr/local/bin/youtube-dl-mp4
#and chmod +x /usr/local/bin/youtube-dl-mp4
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' $1
@alana314
alana314 / copySoundcloudPlaylist.js
Created December 10, 2019 23:16
Copy Soundcloud Playlist to JSON
//Copies the Artist, Track and URL of a playlist to the clipboard in JSON format
//Run in console on a soundcloud page with a playlist:
copy([...document.querySelectorAll('.trackItem__content')].map(ele => {return ({'artist' : ele.querySelectorAll('a')[0].innerHTML, 'track' : ele.querySelectorAll('a')[1].innerHTML, 'url' : ele.querySelectorAll('a')[1].href})}))
//or log it:
[...document.querySelectorAll('.trackItem__content')].map(ele => {return ({'artist' : ele.querySelectorAll('a')[0].innerHTML, 'track' : ele.querySelectorAll('a')[1].innerHTML, 'url' : ele.querySelectorAll('a')[1].href})})
//Example output of my 2019 playlist:
/*
[
{
"artist": "JUST A GENT",
@alana314
alana314 / ffmpeg_convert_1920_29_97.sh
Created October 21, 2020 21:14
Convert and Letterbox video to 1920x1080 29.97 fps with ffmpeg
#!/bin/bash
#convert to 1080 at 29.97fps
#useful for screen capture videos with odd aspect ratios and framerates
#modified from https://superuser.com/questions/891145/ffmpeg-upscale-and-letterbox-a-video
ffmpeg -i input.mov -vf "scale=(iw*sar)*min(1920/(iw*sar)\,1080/ih):ih*min(1920/(iw*sar)\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\,1080/ih))/2:(1080-ih*min(1920/iw\,1080/ih))/2, fps=fps=29.97" output.mp4