Skip to content

Instantly share code, notes, and snippets.

View dnaber-de's full-sized avatar
🏠
Working from home

David Naber dnaber-de

🏠
Working from home
View GitHub Profile
@dnaber-de
dnaber-de / datetime-iso-to-mysql
Created November 22, 2011 13:15
Translate an ISO-formatet datetime string in a mysql datetime string in UTC and local time
/**
* datetime_iso_to_mysql
*
* if the iso string comes without timezone information
* we gues it's utc and append this to leave no doubt
* remeber to set your systems default timezone with
* date_default_timezone_set()
*
* @param string $iso an ISO Formated datetime string
* @return array $mysql_date keys are local and utc
@dnaber-de
dnaber-de / MooTools-delayed-action.js
Created January 12, 2012 17:51
Delayed action on an event
/**
* personal note
* just in case...
*/
$( 'hover-me' ).addEvent( 'mouseenter', function() {
if ( outTimer )
clearTimeout( outTimer );
inTimer = (
function() {
@dnaber-de
dnaber-de / editor_plugin.js
Created January 22, 2012 18:33
Wordpress TinyMCE Popup-Dialog. German Tutorial on http://dnaber.de/p1477
// js/editor_plugin.js
/**
* an example tinyMCE Plugin
*/
tinymce.create(
'tinymce.plugins.myPlugin',
{
/**
* @param tinymce.Editor editor
* @param string url
@dnaber-de
dnaber-de / default_plugin.php
Created January 23, 2012 12:03
A empty WordPress Plugin with frequently used functionality
<?php
/*
Plugin Name: New_Plugin
Description: Empty Plugin to fill with your code
Version: 0.0
Author: David Naber <kontakt@dnaber.de>
Author URI: http://dnaber.de
*/
# @charset utf-8
@dnaber-de
dnaber-de / cursor.js
Created January 24, 2012 17:08
Relative Cursor position in an Element (using MooTools)
$( 'foo' ).addEvent(
'mousemove',
function( event ) {
var pos = this.getPosition( );
var relPos = {};
relPos.x = event.page.x - pos.x;
relPos.y = event.page.y - pos.y;
console.log( relPos );
}
);
@dnaber-de
dnaber-de / Some Regexp
Created March 19, 2012 11:45
Codesnippets for sharing
~(box(?:-[0-9]+)?\.(?:jpe?g|png))~
@dnaber-de
dnaber-de / page-for-posts-url.php
Created March 21, 2012 12:08
Wordpress function to get the URL of the posts index page if this is not the home URL.
/**
* gets the link to the article index
*
* @global $blog_id
* @return string
*/
function get_page_for_posts_url() {
global $blog_id;
$index_id = 0;
@dnaber-de
dnaber-de / Nth_Child_Class.php
Created May 7, 2012 13:21
A template helper to print HTML-Classes to each element in a loop which matches the CSS nth-child syntax
<?php
declare( encoding='UTF-8' );
/**
* A template helper to print class-names
* to eacht element, matches the equation xn+y
*
* @author David Naber <kontakt@dnaber.de>
*/
class Nth_Child_Class {
@dnaber-de
dnaber-de / technicolor.css
Created June 19, 2012 20:25
A simple Rainbow.js Theme specially for PHP, CSS, and HTML
@charset "UTF-8";
/**
* Technicolor
*
* A theme for Rainbow.js
*
* @author David Naber <kontakt@dnaber.de>
*/
@dnaber-de
dnaber-de / class-Logwriter.php
Created June 22, 2012 12:29
yet another log writer
<?php
/**
* class Logwriter
*
* yet another log writer
*
* @author David Naber <kontakt@dnaber.de>
* @charset utf-8
* @version 0.3
* @licence GPLv3