Skip to content

Instantly share code, notes, and snippets.

View eteubert's full-sized avatar

Eric Teubert eteubert

View GitHub Profile
@eteubert
eteubert / limit.js
Created December 2, 2011 10:39
WordPress: Comment Length Limiter
jQuery(function($) {
// configure
var comment_input = $( '#commentform textarea' );
var submit_button = $( '#commentform .form-submit' );
var comment_limit_chars = 1000;
// stop editing here
// display how many characters are left
$( '<div class="comment_limit_info"><span>' + comment_limit_chars + '</span> characters left</div>' ).insertAfter( comment_input );
@eteubert
eteubert / gist:1426544
Created December 3, 2011 08:26
Blue Yeti
- my machine: MacBook Pro with Mac OS X Lion (currently 10.7.2)
- When I connect the Yeti to any of the USB ports of my MacBook Pro, the Mute light shines red but that's all
- not recognized in the "Sound" panel: http://cl.ly/1Y1O2B2j0H0f1C2K1o0z
- does not appear in the "Audio Devices" panel either: http://cl.ly/3y3F0T2U4046202Z0q03
- tried all USB slots
- directly plugged in, no USB hub
- tried rebooting
- tried different USB cable
- no other devices connected to the MBP
- tried with 3 different Lion Macs: the aforementioned MBP, a MacBook and a MacBook air - same symptoms everywhere
@eteubert
eteubert / example.php
Created December 4, 2011 09:11
WordPress: Rethinking Hook Declaration
<?php
/**
* My Plugin
*
* @uses add_filter() for 'the_content': make love not content
* @uses add_filter() for 'get_the_excerpt': clearly announce all excerpts
*/
class my_plugin
{
function __construct() {
@eteubert
eteubert / class.php
Created December 13, 2011 15:04
WordPress: Namespacing WordPress Plugins
<?php
class TheTroublesomeButCoolWidget {
public function __construct() {
$this->register_scripts();
$this->register_shortcode();
$this->register_setup_hooks();
}
private function register_scripts() { /* ... */ }
private function register_shortcode() { /* ... */ }
private function register_setup_hooks() { /* ... */ }
@eteubert
eteubert / activate.php
Created December 20, 2011 10:45
WordPress: Find Users by Last Login Activity
<?php
register_activation_hook( __FILE__, 'add_last_activity_for_all_users' );
function add_last_activity_for_all_users() {
global $wpdb;
$sql = $wpdb->prepare( "
SELECT
u.ID
FROM
$wpdb->users AS u
@eteubert
eteubert / exhibit1.php
Created January 22, 2012 13:14
PHP Weirdness: Calling Non-Static Methods Statically
<?php
class A {
public function foo() {
echo "Hello World";
}
}
A::foo(); // => Hello World
@eteubert
eteubert / after.html
Created February 9, 2012 20:10
Multi Feed Reader Example
</tbody>
</table>
@eteubert
eteubert / public_api.php
Created February 25, 2012 16:22
dtpr: dtpr_get_user_capability_names
<?php
/**
* Get capability names array of user.
*
* Example output:
*
* Array
* (
* [1] => Array
* (
@eteubert
eteubert / archivist.html
Created February 25, 2012 16:27
archivist template
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@eteubert
eteubert / public_api.php
Created February 27, 2012 15:07
dtpr_get_all_user_capabilities
<?php
/**
* Return array containing all capabilities that user has access to.
* If he is an admin, the list will contain all available capability IDs.
*
* @param $user_id integer
* @return array
*/
function dtpr_get_all_user_capabilities( $user_id ) {
global $wpdb;