Skip to content

Instantly share code, notes, and snippets.

// Crop Images (cut from bottom)
convert -resize 1440x810^ -gravity North -extent 1440x810 orig/*.jpg -set filename:base "%[basename]" "testi-16x9-%[filename:base].jpg"
javascript:(function(){ var text = ""; var activeEl = document.activeElement; var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null; if ( (activeElTagName == "textarea") || (activeElTagName == "input" && /^(?:text|search|password|tel|url)$/i.test(activeEl.type)) && (typeof activeEl.selectionStart == "number") ) { text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd); } else if (window.getSelection) { text = window.getSelection().toString(); } var timestamp = parseInt(text) * 1000; var d = new Date(); d.setTime(timestamp); alert(d.toString()); }());
for f in *.jpg; do convert "$f" -resize 1600 small/"$f"; done;
<?php
/**
* Very simple password protectetion for very simple php web pages
*/
$accessWord = 'nameOfMyGirlfriendOrDaughterWhereEsAreReplacedByThrees';
if (!isset($_COOKIE['accessWord']) || $_COOKIE['accessWord'] !== md5($accessWord)) {
if (isset($_POST['accessWord']) && trim($_POST['accessWord']) === $accessWord) {
@bespr
bespr / wp-function-returnMenuLabel
Last active December 17, 2015 12:39
Wordpress function to return the menu label of a page
<?php
/**
* @return array - info about the page, which is only available in the menu
*/
function getCurrentMenuValues() {
global $post;
$reArray = array();
@bespr
bespr / html mini template
Last active September 29, 2018 14:25
html mini template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html { font-family: sans-serif; box-sizing: border-box; }
*, *:after, *:before { box-sizing: inherit; }
* { margin: 0; padding: 0; }
@bespr
bespr / moment.fromNowShort.js
Created April 8, 2013 15:54
Extend moment.js to return very short words for time differences. Same as moment().fromNow, but much shorter.
/**
* A little moment js "plugin" to allow very short relative times
* NOT: "26 minutes ago"
* BUT: "26m"
*
* Usage:
* var m = moment('2013-04-08 17:50:00', 'YYYY-MM-DD HH:mm:ss');
* console.log(m.fromNow()); // -> "3 minutes ago"
* console.log(m.fromNowShort()); // -> "3m"
*