Skip to content

Instantly share code, notes, and snippets.

View alana314's full-sized avatar

alana314

  • Ayzenberg
  • Los Angeles
View GitHub Profile
@alana314
alana314 / launchd_wrapper.sh
Last active August 29, 2015 13:57 — forked from mystix/launchd_wrapper.sh
Identical to mystix's Tomcat launchd scripts except it uses /Library/Tomcat as catalina home.
#!/bin/bash
# NOTE: this is an OSX launchd wrapper shell script for Tomcat (to be placed in $CATALINA_HOME/bin)
CATALINA_HOME=/Library/Tomcat
function shutdown() {
date
echo "Shutting down Tomcat"
$CATALINA_HOME/bin/catalina.sh stop
//Now with less jquery
//1) go to your my-list page, and scroll to the bottom to make sure it's all loaded:
//http://www.netflix.com/browse/my-list
//2) Next, paste this in your developer tools console and hit enter:
[...document.querySelectorAll('.slider [aria-label]')].map(ele => ele.getAttribute('aria-label'))
//or use this to copy the list to your clipboard:
copy([...document.querySelectorAll('.slider [aria-label]')].map(ele => ele.getAttribute('aria-label')))
@alana314
alana314 / gist:f81e083fcfa532d6842014b0d70501c4
Created August 25, 2016 23:45
jQuery tweet button function using the window URL and content from twitter's meta tag
$('a.sharebutton.twitter').click(function(e){
window.open("https://twitter.com/intent/tweet?text=" + encodeURIComponent($('meta[name="twitter:description"]').attr('content').substring(0, 116)) + "&url=" + encodeURIComponent(window.location.href),"tweet", "width=500,height=300");
});
@alana314
alana314 / findexternallinks.js
Created September 16, 2016 22:56
Use node.js and jquery (cheerio) to recursively search files for external links
@alana314
alana314 / gist:3cf266365271b7ef4435a63d18e857ed
Created December 15, 2016 22:00
wt - change iterm window title
#!/bin/zsh
#usage: wt [title name]
#deselect all the options for window and tab titles in the iterm->preferences->appearance section. And in the .zshrc uncomment/add export DISABLE_AUTO_TITLE="true"
#via http://superuser.com/questions/292652/change-iterm2-window-and-tab-titles-in-zsh
echo -ne "\e]1;$1\a"
@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)
@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)
//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);}
//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);}
@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";