Skip to content

Instantly share code, notes, and snippets.

@j0hj0h
j0hj0h / date2filename.sh
Created November 7, 2019 15:40
Write file modification time to filename
for file in *.csv; do
new_name=$(date -r $file "+%Y%m%d-%H%M%S").csv
echo "renaming $file to $new_name"
mv $file $new_name
done
@j0hj0h
j0hj0h / showMore.html
Last active November 21, 2018 22:27
Minimal showMore JS-Module
<div data-show-more>
<div data-show-more-content>
...
</div>
<button type="button" data-show-more-toggle>
<span class="more">Show more</span>
<span class="less">Show less</span>
</button>
</div>
@j0hj0h
j0hj0h / functions.sanitize_upload_filenames.php
Last active April 27, 2017 17:46
Wordpress: sanatize upload filenames
<?php
/*
Sanitizes filenames of uploaded files to only english alpha-numeric characters plus dash.
*/
add_filter('sanitize_file_name', function($filename) {
// replace for accents catalan spanish and more
$a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', '
@j0hj0h
j0hj0h / functions.responsive_embeds.php
Last active August 5, 2016 14:03
Wordpress: responsive embeds
<?php
/*
Wraps the video embed code so that it takes the full width of the parent element
and resizes keeping it's aspect ratio.
Just tested for Vimeo and YouTube iframes so far ...
*/
add_filter('embed_oembed_html', function($html) {
@j0hj0h
j0hj0h / index.html
Last active August 4, 2016 17:58
Placeholder Template (index.html)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body style="padding-top: 150px; text-align: center;">
<img src="logo.png"/>
<h1 style="font-family: Arial; margin-top: 50px;">Under construction</h1>