Skip to content

Instantly share code, notes, and snippets.

View Zegnat's full-sized avatar

Martijn van der Ven Zegnat

View GitHub Profile
@Zegnat
Zegnat / redirect.js
Created May 1, 2012 14:26
Redirect Tumblr page to day page. [JS]
(function(a){
if (!0{block:DayPage}1{/block:DayPage} && a) {
window.location.replace('/day/'+a+'/');
}
})([''{block:Posts}{block:Date}{block:NewDayDate},'{Year}/{MonthNumberWithZero}/{DayOfMonthWithZero}'{/block:NewDayDate}{/block:Date}{/block:Posts}][1]);
@Zegnat
Zegnat / H9RBS.decoded.js
Created May 9, 2012 19:07
HTML9 Responsive Boilerstrap JS (v0.0001)
var 흤 = [
"<pre style=\"font-family: monspace; font-size: 30px; width: 900px; margin:auto;\"><br>",
"write",
"………………………………………………………………………………………………<br>",
"………………….._,,-~’’’¯¯¯’’~-,,…………………………………………………………<br>",
"………………..,-‘’ ; ; ;_,,---,,_ ; ;’’-,…………………………….._,,,---,,_………………<br>",
"……………….,’ ; ; ;,-‘ , , , , , ‘-, ; ;’-,,,,---~~’’’’’’~--,,,_…..,,-~’’ ; ; ; ;__;’-,……………<br>",
"……………….| ; ; ;,’ , , , _,,-~’’ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ¯’’~’-,,_ ,,-~’’ , , ‘, ;’, …………<br>",
"……………….’, ; ; ‘-, ,-~’’ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;’’-, , , , , ,’ ; |…………<br>",
"…………………’, ; ;,’’ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;’-, , ,-‘ ;,-‘…………<br>",
<?php //shared functions
/* ====================================================================================================================== */
/* NoNonsense Forum v22 © Copyright (CC-BY) Kroc Camen 2012
licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
//formulate a URL (used to automatically fallback to non-pretty URLs when htaccess is not available),
//the domain is not included because it is not used universally throughout (absolute-base / relative links)
function url ($action='index', $path='', $file='', $page=0, $id='') {
@Zegnat
Zegnat / gist:4088332
Created November 16, 2012 15:43
Gravatar support for the default NoNonsenseForum theme.
/* Put this in theme.php, inside the `theme_custom` function. */
foreach ($template->query('.nnf_reply-author, #nnf_post-author') as $node) {
$name = strtolower(trim($node->nodeValue));
$imgsrc = md5('');
if (function_exists('filter_var')) {
if (filter_var($name, FILTER_VALIDATE_EMAIL)) {
$imgsrc = md5($name);
}
} else { $imgsrc = md5($name); }
@Zegnat
Zegnat / fix-blog-a-penguin-classic.user.js
Created December 8, 2012 19:48
Fix ‘Blog A Penguin Classic’.
// ==UserScript==
// @name Fix ‘Blog A Penguin Classic’.
// @author Martijn van der Ven <martijn@zegnat.net>
// @id fix-blog-a-penguin-classic
// @namespace http://zegnat.net
// @version 0.5
// @match http://*.blogapenguinclassic.co.uk/*
// ==/UserScript==
(function(a,i,b){
@Zegnat
Zegnat / theme.php
Last active December 10, 2015 03:18
Temporary fix for https://github.com/Kroc/NoNonsenseForum/issues/163 through the templating engine.
<?php //theme-specific template functions
/* ====================================================================================================================== */
/* NoNonsense Forum v23 © Copyright (CC-BY) Kroc Camen 2012
licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
//this function is called just before a templated page is outputted so that you have an opportunity to do any extra
//templating of your own. the `$template` object passed in is a DOMTemplate class, see '/lib/domtemplate/' for code
//or <camendesign.com/dom_templating> for documentation on how to template with it
<?php
// This assumes $text is the input we are parsing.
// I am using normal `echo`s here to output text, you will use whatever function you need.
if (preg_match('/^\/ba?ck(?:\s+(.*?))?\s*$/', $text, $result)) {
// $text matched!
if (isset($result[1]) && strlen($result[1]) > 0) {
// $text included an optional back message to display.
echo '<p><strong>Back:</strong> ' . $result[1] .'</p>';
} else {
@Zegnat
Zegnat / gist:5378588
Last active December 16, 2015 04:39
Getting the closest midnight relative to a certain DateTime.
<?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;
@Zegnat
Zegnat / crapchacracker.js
Created April 23, 2013 15:42
Every CAPTCHA needs to be cracked. Even CRAPCHA.
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 / gmailprintcleaner.txt
Created April 28, 2013 10:47
Adblock Plus filter for removing cruft from Gmail prints.
[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