Skip to content

Instantly share code, notes, and snippets.

View Zegnat's full-sized avatar

Martijn van der Ven Zegnat

View GitHub Profile
@@ -70,16 +70,16 @@
});
// enter key submits form
- $items.on('enterKeyDown', function onEnterKeyDown(e) {
+ $widget.on('enterKeyDown', function onEnterKeyDown(e) {
$form.submit();
});
// spacebar triggers 'check' event
$('.my_answers').each(function(){if(/(\d+), \d+, \1\)/.test(this.getAttribute('onclick')))this.style.backgroundColor='green'});
<?php
/**
* A minimal PhotoBackup API endpoint developed in PHP.
*
* @version 1.0.0
* @author Martijn van der Ven <martijn@zegnat.net>
* @copyright 2015 Martijn van der Ven
* @license http://opensource.org/licenses/MIT The MIT License
*/
@Zegnat
Zegnat / .bash_minidlna
Last active April 24, 2016 19:20
These are the aliases I have configured to control my MiniDLNA set-up.
# Running DLNA server via `minidlnad`
alias dlna_remove_log="if [ -f ~/.config/minidlna/minidlna.log ];then rm ~/.config/minidlna/minidlna.log;fi"
alias dlna_stop="if [ -f ~/.config/minidlna/minidlna.pid ];then cat ~/.config/minidlna/minidlna.pid | xargs kill;fi"
alias dlna_init="minidlnad -f ~/.config/minidlna/minidlna.conf -P ~/.config/minidlna/minidlna.pid"
alias dlna_start="dlna_stop;dlna_remove_log;dlna_init"
alias dlna_rescan="dlna_stop;dlna_remove_log;dlna_init -R"
/**
* Send JSON encoded data to the browser and end all further processing.
* @method endWithJson
* @param array $data A data array.
* @throws InvalidArgumentException
* @return void
*/
private function endWithJson($data)
{
if (!is_array($data)) {
@Zegnat
Zegnat / zegnat.sugar.js
Created January 23, 2014 10:31
Some extensions to Sugar.
Number.extend({
'sign': function() {
// http://stackoverflow.com/a/21294663/3225372
return typeof this === 'number' ? this ? this < 0 ? -1 : 1 : this === this ? this : NaN : NaN;
},
'isPositive': function() {
return this.sign() === 1;
},
'isNegative': function() {
return this.sign() === -1;
@Zegnat
Zegnat / License.txt
Created January 2, 2016 21:50
OmniMix Uno End User License Agreement
LICENSE AGREEMENT
OmniMix Uno End User License Agreement
Copyright (c) 2006 - 2015, Christian Danner - https://www.danner-net.de/om.htm.
All rights reserved.
THIS IS A LEGAL AGREEMENT between "you", the end user of the OmniMix Uno software, and Christian Danner, its author.
/**
* Create an array containing every possible way to write a given string in mixed-case.
*
* @param {String} str - A string to find every case-combination for.
* @return {Array} Every possible case-combination.
*/
function mixedCase(str) {
'use strict';
str = str.toLowerCase();
var length = str.length,
@Zegnat
Zegnat / kick-it.html
Last active December 21, 2015 16:28 — forked from 4rn0/kick-it.html
<a href="http://causeyoucantyouwontandyoudontstop.com/" class="kick-it">Kick it!</a>
@Zegnat
Zegnat / gaunt.js
Last active December 20, 2015 20:39
A Gaunt <http://tinysubversions.com/gaunt/> parser in JavaScript passing JavaScript Lint, JSLint, and JSHint. No regular expression, only one ternary operator, loads of string manipulation.
var gaunt = function (data) {
'use strict';
var input = String(data), map = {9: '0', 32: '1'}, result = '', output = '', i, j;
for (i = 0, j = input.length; i < j; i += 1) {
result += map[input.charCodeAt(i)] || '';
}
for (i = 0, j = result.length; i < j; i += 8) {
output += String.fromCharCode(parseInt(result.substr(i, 8), 2));
}
return output;