Skip to content

Instantly share code, notes, and snippets.

@zarino
zarino / set_video_metadata_date_created.sh
Created January 3, 2018 21:13
Automatically alter the “date added” for a video file in the Synology Video Station database, to match the last modification date of the file on disk
#!/bin/sh
set -e
if [ -z "$1" ]; then
cat <<'EOF'
Usage:
./set_video_metadata_date_created.sh '/absolute/path/to/video/file.mp4'
@zarino
zarino / pseudolocalize.js
Last active February 20, 2016 16:15
A simple JavaScript function that doubles every character on a web page – useful when testing layouts for i18n issues
// Paste this function to your browser’s JavaScript console,
// and then run it, passing in a CSS selector, eg:
// > pseudolocalize('body')
var pseudolocalize = function pseudolocalize(arg){
if(typeof arg === 'string'){
var elements = document.querySelectorAll(arg);
for(var i=0, len=elements.length; i<len; i++){
pseudolocalize(elements[i]);
}
@zarino
zarino / gist:e72f0abc64849e8b11d9
Created January 5, 2016 10:51
Carousel proof of concept
<!-- Progressively enhances a load of slides, so they can be flicked through like a carousel -->
<!-- Assumes only one .js-slide per page, and jQuery available -->
<!-- Untested! -->
<style>
.js-slide { display: none }
.js-slide:first-child { display: block }
</style>
<div class="js-slides">
Started GET "/" for 10.10.10.1 at 2015-11-16 13:04:28 +0000
Processing by GeneralController#frontpage as */*
Xapian query (0.00022s) Search: variety:response (status:successful OR status:partially_successful)
InfoRequestEvent Load (0.5ms) SELECT "info_request_events".* FROM "info_request_events" WHERE (info_request_events.id in ('908','906','913'))
InfoRequest Load (0.4ms) SELECT "info_requests".* FROM "info_requests" WHERE "info_requests"."id" IN (105, 106, 108)
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" IN (1, 5)
PublicBody Load (0.4ms) SELECT "public_bodies".* FROM "public_bodies" WHERE "public_bodies"."id" IN (3, 5, 6)
CensorRule Load (0.3ms) SELECT "censor_rules".* FROM "censor_rules" WHERE "censor_rules"."info_request_id" IN (105, 106, 108) ORDER BY created_at desc
Xapian query (0.00016s) Search: variety:sent
InfoRequestEvent Load (0.4ms) SELECT "info_request_events".* FROM "info_request_events" WHERE (info_request_events.id in ('916','904'))
@zarino
zarino / gist:c597d442560a513ea9cf
Last active August 29, 2015 14:06
Convert GNU Mailman output to tab-separated file for MailChimp
#!/usr/bin/env python
# Assumes a file called mailman.txt in the working directory,
# generated by: `list_members -p -f -n enabled -o ~/mailman.txt news`
import csv
import re
with open('exported.tsv', 'wb') as csvfile:
csvwriter = csv.writer(csvfile, delimiter="\t")
~/Work/mysociety/sayit.mysociety.org:zarinozappia ⌘ git ls-files -v
H .gitignore
H .tx/config
H LICENSE.txt
H README.md
H about/__init__.py
H about/models.py
H about/templates/about/charles-taylor/index.html
H about/templates/about/leveson/index.html
H about/templates/about/shakespeare/index.html
~/Work/mySociety/popit:zarinozappia ⌘ make test
compass clean
remove .sass-cache/
remove public/css/docs.css
remove public/css/foundicons/general_foundicons.css
remove public/css/foundicons/general_foundicons_ie7.css
remove public/css/ie.css
remove public/css/popit.css
remove public/css/print.css
rm -rf public/css
~/mysociety/popit:zarinozappia ⌘ npm rebuild
> bcrypt@0.7.5 install /Users/zarinozappia/Work/mySociety/popit/node_modules/bcrypt
> node-gyp rebuild
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
SOLINK_MODULE(target) Release/bcrypt_lib.node
SOLINK_MODULE(target) Release/bcrypt_lib.node: Finished
#! /bin/sh
if test -z "${REAL_OPT_DIR}"; then
# next line to be replaced according to OPTWARE_TARGET
REAL_OPT_DIR=/volume1/@optware
fi
case "$1" in
start)
echo "Starting Optware."
#!/bin/sh
# Optware setup
[ -x /etc/rc.optware ] && /etc/rc.optware start