Skip to content

Instantly share code, notes, and snippets.

@spig
spig / validate_barcode.js
Last active November 11, 2023 21:56
Validate a barcode UPC-E, UPC-A, EAN, EAN-14, SSCC
// checksum calculation for GTIN-8, GTIN-12, GTIN-13, GTIN-14, and SSCC
// based on http://www.gs1.org/barcodes/support/check_digit_calculator
function isValidBarcode(barcode) {
// check length
if (barcode.length < 8 || barcode.length > 18 ||
(barcode.length != 8 && barcode.length != 12 &&
barcode.length != 13 && barcode.length != 14 &&
barcode.length != 18)) {
return false;
}
@spig
spig / getBrowserLanguage.js
Created April 20, 2011 16:49
get browser language - not especially useful but a fall back if necessary, better to use accept-language from browser request header
function getBrowserLanguages() {
var languages = [ 'en' ];
if (navigator) {
var language;
if (navigator.language) { language = navigator.language; }
else if (navigator.browserLanguage) { language = navigator.browserLanguage; }
else if (navigator.userLanguage) { language = navigator.userLanguage; }
else if (navigator.systemLanguage) { language = navigator.systemLanguage; }
else { language = 'en'; }
@spig
spig / gist:1019494
Created June 10, 2011 18:53
Get namespace of node
xquery version '1.0-ml';
<b xmlns="http://www.w3.org/1999/xhtml">
{
let $element := element test { }
return
for $prefix in fn:in-scope-prefixes($element) return fn:concat("prefix: ", fn:namespace-uri-for-prefix($prefix, $element), ",")
}
</b>
@spig
spig / turnoffretweets
Created March 9, 2013 04:41
Turn off all retweets on twitter. Run this in javascript console.
$(".retweet-off-text").each(function() { $(this).click(); });
@spig
spig / http-get-lines-from-file.sh
Created April 23, 2014 22:55
http get lines from a file and output as filename
while read line ; do
echo $line ; http --ignore-stdin GET https://host$line > `basename $line`
done < images.txt
@spig
spig / gist:d66a3aa81f7c96d4a035976936e6f679
Created October 12, 2016 21:17
Remove all songs from wish list on freegalmusic.com
$("div.wishlistsong").each(function(index, wsl) { $.post("/homes/removeWishlistSong/", { ajax: 1, delete: wsl.id.replace('wishlistsong-', '') })});
// ==UserScript==
// @name Hide Rated R Movies on Feature Films page
// @namespace http://stevespiga.rel.li/
// @version 0.1
// @description try to take over the world!
// @author Steve Spigarelli
// @match https://www.slcolibrary.org/mm/mmmo/newFeatureFilms.htm
// @grant none
// ==/UserScript==
// ==UserScript==
// @name Remove Kids Accounts from Total Balance
// @namespace http://stevespiga.rel.li/
// @version 0.2
// @description remove kid account balances from total balances - money and savings
// @author Steve Spigarelli
// @match https://secure.capitalone360.com/myaccount/banking/account_summary.vm
// @grant none
// ==/UserScript==
ffmpeg -i 1112_20161129185900.ts -ss 00:03:00.000 -t 00:00:30.000 -c:v libvpx -b:v 1M -c:a libvorbis 1112_20161129185900.webm
for i in *.ts; do filename=$(basename $i); base=${filename%.*}; ffmpeg -i $filename -c:v libx264 -c:a libfaac -vf scale=-1:720 -q:a 100 -ac 2 $base.mp4; done