Skip to content

Instantly share code, notes, and snippets.

View dave1010's full-sized avatar

Dave Hulbert dave1010

View GitHub Profile
@dave1010
dave1010 / x
Created January 31, 2009 08:52
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.",
@dave1010
dave1010 / x
Created January 31, 2009 10:46
/*
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",
@dave1010
dave1010 / jQuery.twtShrt.js
Created October 1, 2010 18:07
jQuery.fn.twtShrt
/**
* 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 November 12, 2010 13:14
Strip MS Word HTML. From php.net
<?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 November 16, 2010 09:26
Get a quick list of all issues on the current page with their #
// 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 November 30, 2010 17:31
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 December 7, 2010 12:19
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 December 12, 2010 19:33
jQuery plugin to detach (hide) select options and add them again.
// 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 December 21, 2010 10:31
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 March 7, 2011 13:22
9.sh - for Peter's broken keyboard.
#!/bin/bash
echo '('