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 / hands-off-from-content.php
Created August 25, 2012 11:43
WP Plugin: Don't replace 'Wordpress' with 'WordPress'. Keep ' and " as they are.
<?php
/**
* Plugin Name: dna Hands off from content
* Description: Don't replace 'Wordpress' with 'WordPress'. Keep ' and " as they are.
* Plugin URI: https://gist.github.com/3464269
* Version: 2012.08.25
* Author: David Naber
* Author URI: http://dnaber.de/
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
@dnaber-de
dnaber-de / screenshot-1.png
Created August 24, 2012 17:29
WP Multisite Plugin: non-super-admins can edit users in blog context (if they have the capabilities 'edit_users' and 'promote_users').
screenshot-1.png
@dnaber-de
dnaber-de / result-page.html
Created July 10, 2012 09:37
Google custom search code
<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.de/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'de'});
google.setOnLoadCallback(function() {
var customSearchOptions = {}; var customSearchControl = new google.search.CustomSearchControl(
'*****************', customSearchOptions);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
function parseParamsFromUrl() {
@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
@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 / 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 / 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 / Some Regexp
Created March 19, 2012 11:45
Codesnippets for sharing
~(box(?:-[0-9]+)?\.(?:jpe?g|png))~
@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 / 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