Skip to content

Instantly share code, notes, and snippets.

Dave Hulbert dave1010

Block or report user

Report or block dave1010

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View x
CmdUtils.CreateCommand({
name: "search-php",
homepage: "http://createopen.com/blog/",
author: { name: "David Hulbert", email: "dave1010+ubiquity@gmail.com"},
icon: "http://static.php.net/www.php.net/favicon.ico",
license: "MPL",
takes: {"function": noun_arb_text},
description: "Searches PHP for a function.",
View x
/*
TODO:
match beginnings of function names
say if no functions found
if > 1 function result, have a list of them
option to show more details of function?
get it working with gotapi.com and all languages it supports
*/
CmdUtils.CreateCommand({
name: "search-php",
View jQuery.twtShrt.js
/**
* Make a form field shorten text as you type
* Made for keeping tweets < 140 chrs
* Usage: $('textarea').twtShrt();
* @author dave1010
*/
jQuery.fn.twtShrt = function() {
var o = [
"seriously","have to", "what is", "done", "oh my god", "oh my gosh", "face to face", "for the win", "for the loss", "in real life", "your mileage may vary", "best regards", "joint venture", "let me know", "not safe for work", "are you ok", "tomorrow", "as soon as possible", "be right back", "be back later", "be back soon", "at the moment", "by the way", "in my honest opinion", "tata for now", "as known as", "also known as", "see you later", "see you", "for your information", "in my opinion", "too good to be true", "best friends forever", "best friend forever", "best friends", "best friend", "definitely", "been", "hello", "i am", "night", "when", "some", "to", "speak", "you", "your", "for", "friend", "people", "see", "be", "and", "&", "anyone", "because", "are", "bate", "date", "fate", "great", "hate", "late", "mate",
@dave1010
dave1010 / strip_word_html.php
Created Nov 12, 2010
Strip MS Word HTML. From php.net
View strip_word_html.php
<?php
function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
{
mb_regex_encoding('UTF-8');
//replace MS special characters first
$search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
$replace = array('\'', '\'', '"', '"', '-');
$text = preg_replace($search, $replace, $text);
//make sure _all_ html entities are converted to the plain ascii equivalents - it appears
//in some MS headers, some html entities are encoded and some aren't
@dave1010
dave1010 / github-issue-quick-export.js
Created Nov 16, 2010
Get a quick list of all issues on the current page with their #
View github-issue-quick-export.js
// add as a bookmark with "javascript:" at the beginning of the URL to make into a bookmarklet
(function(){var o = '';$('.issue').each(function() {var n = '#' + $('.number', this).text().replace('.', '') + ' - ',t = $('.issue_title', this).text();o += n+t + '\n';});alert(o);})();
@dave1010
dave1010 / notify-apache-errors.sh
Created Nov 30, 2010
notify-apache-errors.sh
View notify-apache-errors.sh
#!/bin/bash
# use ubuntu's notification system to let us know when there's something new in the apache error log
tail -n0 -f /var/log/apache2/error.log | while read line
do
body=`echo $line | cut -f 9- -d ' '`
notify-send -c im.received -i error "Apache / PHP error" "$body"
done
@dave1010
dave1010 / github-issues-total-hours.js
Created Dec 7, 2010
Name GitHub issues with hours like [2] in the title and this will add them up
We couldn’t find that file to show.
@dave1010
dave1010 / jquery.detach-select-options.js
Created Dec 12, 2010
jQuery plugin to detach (hide) select options and add them again.
View jquery.detach-select-options.js
// this is because of http://stackoverflow.com/questions/4398966/how-can-i-hide-select-options-with-javascript-cross-browser/4423543
(function($){
$.fn.extend({detachOptions: function(o) {
var s = this;
return s.each(function(){
var d = s.data('selectOptions') || [];
s.find(o).each(function() {
d.push($(this).detach());
@dave1010
dave1010 / sort-phpunit-tests-by-time.sh
Created Dec 21, 2010
sort-phpunit-tests-by-time.sh
View sort-phpunit-tests-by-time.sh
grep time tests.xml | grep testcase | awk "{ print \$7 \$2 }"|sed 's/name="/ /g'|sed 's/time="//g'|sed 's/"\/>//g'|sed 's/"//g'|sort
@dave1010
dave1010 / (.sh
Created Mar 7, 2011
9.sh - for Peter's broken keyboard.
View (.sh
#!/bin/bash
echo '('
You can’t perform that action at this time.