Skip to content

Instantly share code, notes, and snippets.

View kraftner's full-sized avatar

Thomas Kräftner kraftner

View GitHub Profile
@priithaamer
priithaamer / gist:1034070
Created June 19, 2011 11:01
Capistrano task to ask confirmation before deploying to production
task :ask_production_confirmation do
set(:confirmed) do
puts <<-WARN
========================================================================
WARNING: You're about to perform actions on production server(s)
Please confirm that all your intentions are kind and friendly
========================================================================
@hakre
hakre / dl-file.php
Created January 2, 2012 21:41
Wordpress login to download uploaded files
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+
@ptz0n
ptz0n / gist:1646171
Created January 20, 2012 08:43
Recursive merge of arrays with integer keys
<?php
/**
* Merge two dimensional arrays my way
*
* Will merge keys even if they are of type int
*
* @param array $array1 Initial array to merge.
* @param array ... Variable list of arrays to recursively merge.
*
@christophermanning
christophermanning / README.md
Last active March 30, 2023 04:24
Voronoi Diagram with Force Directed Nodes and Delaunay Links

Created by Christopher Manning

Summary

Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.

The white lines are the Delaunay triangulation and the purple cells are the Voronoi diagram.

Controls

@Rarst
Rarst / r-debug.php
Last active February 3, 2024 17:30
R Debug (set of dump helpers for debug)
<?php
/*
Plugin Name: R Debug
Description: Set of dump helpers for debug.
Author: Andrey "Rarst" Savchenko
Author URI: https://www.rarst.net/
License: MIT
*/
@thefuxia
thefuxia / basic_meta_box.php
Last active June 7, 2024 04:53
WordPress meta box example
<?php # -*- coding: utf-8 -*-
declare( encoding = 'UTF-8' );
/**
* Plugin Name: Basic Meta Box
* Description: Create a simple meta box. Demo plugin.
* Version: 2012.02.05
* Required: 3.3
* Author: Fuxia Scholz
* Author URI: https://fuxia.me
* License: GPL
@stephanieleary
stephanieleary / wp_private_page_filters.php
Last active March 7, 2018 12:41
Private page filters for WordPress. Related to ticket #8592.
<?php
/*
Plugin Name: Unpublished Hierarchies
Description: A tiny plugin to allow draft, private, scheduled, and password-protected pages to be selected as parents.
Author: Stephanie Leary
Version: 1.0
Author URI: http://stephanieleary.com
License: GPL2
*/
@franz-josef-kaiser
franz-josef-kaiser / wpmail_exceptions.php
Last active May 28, 2024 07:30
WP Mail Error/Exception handling and SMTP settings
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) PHPMailer Exceptions & SMTP
* Description: WordPress by default returns <code>FALSE</code> instead of an <code>Exception</code>. This plugin fixes that.
*/
add_action( 'phpmailer_init', 'WCMphpmailerException' );
function WCMphpmailerException( $phpmailer )
{
@benvandyke
benvandyke / index.html
Created January 16, 2014 17:50
Plotting a trendline with D3.js
<!DOCTYPE html>
<meta charset="utf-8">
<title>Plotting a Trendline with D3.js</title>
<style>
.line {
stroke: blue;
fill:none;
stroke-width: 3;
}
@mannieschumpert
mannieschumpert / gist:8886289
Last active August 2, 2020 13:15
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );