Skip to content

Instantly share code, notes, and snippets.

View yckart's full-sized avatar

Yannick Albert yckart

View GitHub Profile
@yckart
yckart / LICENSE.txt
Last active March 8, 2018 11:45 — forked from 140bytes/LICENSE.txt
getSet
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 Yannick Albert <http://yckart.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@yckart
yckart / LICENSE.txt
Last active March 8, 2018 11:38 — forked from 140bytes/LICENSE.txt
undo/redo manager
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@yckart
yckart / README.md
Last active October 30, 2016 19:04
rawgit.com / rawgithub.com - Bookmarklet

A simple bookmarklet which makes our painful life a bit easier.

javascript:(function(b,a,c,d,e){if(/\.\w+$/.test(a))b.location=c+a.replace("/blob/","/");else if(e=prompt("Insert a filename:","index.html"))b.location=c+a.replace("/tree/","/")+(~a.indexOf(d)?"/":d)+e})(window,location.pathname,"http://rawgit.com","/master/");

The usage is quite simple:

Go to any repo where you like to preview a file, and execute the booklet. If the current url is a file, it should open the file directly, otherwise it will prompt for a filename (per default it is index.html).

@yckart
yckart / README.md
Last active October 26, 2016 14:06
Interesting concept to wrap strings around each array-item.

This is something I fiddled with during development. A really helpful thing if we need to wrap strings around array items.

var values = [1, 3, 3, 7];
var open = '<span>';
var close = '</span>';
var html = open + values.join(close + open) + close;

console.log(html); // => "<span>1</span><span>3</span><span>3</span><span>7</span>"
@yckart
yckart / ModuleBoilerplate.module
Last active August 8, 2016 21:05
ModuleBoilerplate.module for ProcessWire
<?php
/**
* A simple module-boilerplate
*
* @see https://gist.github.com/yckart/7040320
* @see http://wiki.processwire.com/index.php/Module_Creation
*/
class ModuleBoilerplate extends WireData implements Module, ConfigurableModule {
@yckart
yckart / jquery.act.js
Created December 2, 2012 23:58
jQuery function to allow multiple events via `on`-event on one element with different functions and target selectors
;(function($) {
$.fn.act = function() {
var args = arguments;
return this.each(function() {
for (var i = args.length; i--;) {
$(this).on(args[i][0], args[i][1], args[i][2]);
}
});
};
})(jQuery);
@yckart
yckart / Log.module
Last active January 31, 2016 06:38
Log.module - A lightweight logging wrapper around ProcessWire's session message/error
<?php
class Log extends WireData implements Module {
/**
* getModuleInfo is a module required by all modules to tell ProcessWire about them
*
* @return array
@yckart
yckart / debounce.js
Last active January 13, 2016 19:22
throttle/debounce javascript
// call after last delay
function debounce(callback, delay) {
var timeout;
return function () {
var self = this, args = arguments;
if (timeout) clearTimeout(timeout);
timeout = setTimeout(function () {
callback.apply(self, args);
}, delay || 100);
};
<?
wire()->addHookProperty('Page::readingTime', null, 'readingTime');
function readingTime($event) {
$page = $event->object;
$words = str_word_count(strip_tags($page->body));
$m = floor($words / 200);
$s = floor($words % 200 / (200 / 60));
$minutes = $m == 1 ? __('Minute') : __('Minutes');
$seconds = $s == 1 ? __('Second') : __('Seconds');
$event->return = "$m {$minutes}, $s {$seconds}";
@yckart
yckart / functions.php
Last active December 26, 2015 02:49
ProcessWire page slug
<? $input->slug = $input->urlSegments ? end($input->urlSegments) : $page->name; ?>