Skip to content

Instantly share code, notes, and snippets.

Martijn van der Ven Zegnat

Block or report user

Report or block Zegnat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Zegnat
Zegnat / License.txt
Created Jan 2, 2016
OmniMix Uno End User License Agreement
View License.txt
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.
View mixedCase.js
/**
* 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,
View kick-it.html
<a href="http://causeyoucantyouwontandyoudontstop.com/" class="kick-it">Kick it!</a>
@Zegnat
Zegnat / gaunt.js
Last active Dec 20, 2015
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.
View gaunt.js
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;
@Zegnat
Zegnat / slow_compare.php
Created Jul 5, 2013
For secure and slow string comparisons. This helps against timing attacks on secret strings.
View slow_compare.php
<?php
function slow_compare($str1, $str2, $length = null) {
$out = ($str1_len = strlen($str1 .= chr(0))) - ($str2_len = strlen($str2 .= chr(0)));
if (!is_int($length)) $length = $str1_len;
for ($i = 0; $i < $length; $i++)
$out |= ord($str1[$i % $str1_len]) ^ ord($str2[$i % $str2_len]);
return 0 === $out;
}
@Zegnat
Zegnat / Bcrypt.php
Last active Dec 19, 2015 — forked from marcoarment/Bcrypt.php
Simple PHP 5.3+ Bcrypt class
View Bcrypt.php
<?php
/*
Originally by Marco Arment <me@marco.org>.
Edited by Martijn van der Ven <martijn@zegnat.net>.
This code is released in the public domain.
THERE IS ABSOLUTELY NO WARRANTY.
This class is aimed at PHP versions over 5.3 and below 5.5.
View fote.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Zegnat
Zegnat / gmailprintcleaner.txt
Created Apr 28, 2013
Adblock Plus filter for removing cruft from Gmail prints.
View gmailprintcleaner.txt
[Adblock Plus 1.3]
! Checksum: h6BrZGmz6mljqqZ43XaHrw
! [Gmail print cleaner]
! Gmail logo (left) and receipient email adress (right):
mail.google.com##body[onload="Print()"] .bodycontainer>table
! Horizontal line below logo/email adress:
mail.google.com##body[onload="Print()"] .bodycontainer>hr
! Title and message count:
mail.google.com##body[onload="Print()"] .maincontent>table:first-child
@Zegnat
Zegnat / crapchacracker.js
Created Apr 23, 2013
Every CAPTCHA needs to be cracked. Even CRAPCHA.
View crapchacracker.js
document.querySelector('.crapcha input').value=Array.prototype.map.call(document.querySelectorAll('.crapcha .code span'),function(a){return a.textContent.length?a.textContent:String.fromCharCode(parseInt('F'+a.className.substr(5),16))}).join('')
@Zegnat
Zegnat / gist:5378588
Last active Dec 16, 2015
Getting the closest midnight relative to a certain DateTime.
View gist:5378588
<?php
function closestMidnight($date) {
if (!is_a($date, 'DateTime')) {
try { $date = new DateTime($date); }
catch (Exception $e) {
if (is_numeric($date)) { $date = (new DateTime())->setTimestamp(intval($date)); }
else { return false; }
}
}
$comp = clone $date;
You can’t perform that action at this time.