Skip to content

Instantly share code, notes, and snippets.

Avatar

Rodolfo Buaiz brasofilo

View GitHub Profile
@nemoo
nemoo / Gitwebmarkdown
Created Oct 25, 2014
Tampermonkey script for chrome to display README.md files rendered as html from markdown in gitweb
View Gitwebmarkdown
// ==UserScript==
// @name Gitwebmarkdown
// @version 0.1
// @description renders readme files in markdown
// @include http://yourserverhere.com/git/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js
// ==/UserScript==
var converter = new Showdown.converter();
View app.js
angular.module('myApp', ['ngRoute'])
.provider('Weather', function() {
var apiKey = "";
this.getUrl = function(type, ext) {
return "http://api.wunderground.com/api/" +
this.apiKey + "/" + type + "/q/" +
ext + '.json';
};
@thefuxia
thefuxia / t5-silent-flush.php
Last active Aug 11, 2016
T5 Silent Flush - Flushes rewrite rules whenever a custom post type or taxonomy is registered and not already part of these rules. This is a soft flush, the .htaccess will not be rewritten.
View t5-silent-flush.php
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Silent Flush
* Description: Flushes rewrite rules whenever a custom post type or taxonomy is registered and not already part of these rules. This is a soft flush, the .htaccess will not be rewritten.
* Version: 2013.05.04
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
@thefuxia
thefuxia / t5-spam-block.php
Last active Dec 15, 2015
T5 Spam Block Stop comments based on a block list before they can enter the database.
View t5-spam-block.php
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Spam Block
* Description: Block spam before it reaches the database.
* Plugin URI: https://github.com/toscho/T5-Spam-Block
* Version: 2013.03.31
* Author: Thomas Scholz
* Author URI: http://toscho.de
* Licence: MIT
* License URI: http://opensource.org/licenses/MIT
@thefuxia
thefuxia / functions.php
Created Mar 18, 2013
Count posts in post-format "status".
View functions.php
add_action( 'wp_footer', 'count_statuses' );
function count_statuses()
{
$status = 'status';
$num = get_term_post_count_by_type( "post-format-$status", 'post_format' );
print "<pre>{$status}es: $num</pre>";
}
/**
* Count all post in a term.
@franz-josef-kaiser
franz-josef-kaiser / debug_register_pt_args.class.php
Last active Dec 14, 2015
Shows the arguments of a newly registered post type right after it was registered. Helps inspecting which defaults have been added by core and if one of the developers arguments got overwritten. Simply add `&debug_pt_args=true` to your URL and set `WP_DEBUG` to `TRUE`.
View debug_register_pt_args.class.php
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) Debug Register Post Type Args
* Description: Shows the arguments of a newly registered post type right after it was
* registered. Helps inspecting which defaults have been added by core and if
* one of the developers arguments got overwritten. Simply add
* <code>&debug_pt_args=true</code> to your URL and set
* <code>WP_DEBUG</code> to <code>TRUE</code> in your <code>wp-config.php</code>.
* Plugin URl: http://wordpress.stackexchange.com/questions/89066
@franz-josef-kaiser
franz-josef-kaiser / wpse67107_restrict_upload.php
Created Feb 26, 2013
Restrict the maximum file size as well as the maximum allowed resolution for images uploaded to WordPress.
View wpse67107_restrict_upload.php
<?php
/**
* Plugin Name: (#67107) »kaiser« Restrict file upload via image dimensions
*/
function wpse67107_restrict_upload( $file )
{
$file_data = getimagesize( $file );
// Abort when we can't get any info:
if ( ! $file_data )
@mbijon
mbijon / posts_search_demo.php
Created Feb 18, 2013
WordPress posts_search filter example, for Tom Barrett on WP-Hackers list 2013-02-18
View posts_search_demo.php
function tcb_filter_search( $term ) {
if ( is_search() )
$search = "(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
return $search;
}
add_filter( 'posts_search', 'tcb_filter_search', null, 2 );
@franz-josef-kaiser
franz-josef-kaiser / sys_bot.php
Last active Aug 4, 2020
Creates and maintains the SysBot User (which has the role of "editor"). Purpose of this bot user: You're importing data into a WordPress CustomPostType (for e.g.: via a HTTP request). During import/fetch you need a user who is the author of those CPTs posts. You could go with a fake ID, but this will successfully prevent you to use taxonomies, a…
View sys_bot.php
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: SysBot
* Description: Creates and maintains the SysBot User (which has the role of "editor")
* Author: Franz Josef Kaiser
*/
# PUBLIC API #
function get_bot()
@franz-josef-kaiser
franz-josef-kaiser / curl_dump.php
Last active Jul 8, 2019
Debug and dump a WordPress cURL Request and it's response during a WP HTTP API call.
View curl_dump.php
<?php
/**
* Plugin Name: Dump WP HTTP API cURL Request & Response
* Author: Franz Josef Kaiser
*/
add_action( 'plugins_loaded', array( 'WPSE81791_cURL', 'init' ) );
class WPSE81791_cURL
{
protected static $instance;
You can’t perform that action at this time.