Skip to content

Instantly share code, notes, and snippets.

@cvn
cvn / .profile
Last active August 29, 2015 13:56
Git Prompt
# original git prompt from ray
# http://raysohn.com/posts/simple-git-prompt.html
# Fix wrapping behavior (escape non-printing characters)
# http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/nonprintingchars.html
# Output escaped non-printing characters from a function
# http://stackoverflow.com/a/13997892/490592
# Maintain new tab behavior in Terminal.app
# http://superuser.com/a/623305/75328
simple_git_prompt () {
function colorFromString(str, length) {
if (!str){
str = 'null';
}
if (length){
jobColorSource = hex_md5(str.substring(0,length));
}else{
jobColorSource = hex_md5(str.substring(0,4));
}
jobColor = new Array(jobColorSource.substr(0,2), jobColorSource.substr(2,2), jobColorSource.substr(4,2));
@cvn
cvn / phpinfo-cli
Created June 14, 2014 15:52
Output from phpinfo() in command line php
PHP Version => 5.4.24
System => Darwin ground.local 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64
Build Date => Jan 19 2014 21:18:21
Configure Command => '/private/var/tmp/apache_mod_php/apache_mod_php-87.2~1/php/configure' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--sysconfdir=/private/etc' '--with-apxs2=/usr/sbin/apxs' '--enable-cli' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/Library/Server/Web/Config/php' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--disable-cgi' '--with-curl=/usr' '--enable-dba' '--enable-ndbm=/usr' '--enable-exif' '--enable-fpm' '--enable-ftp' '--with-gd' '--with-freetype-dir=/BinaryCache/apache_mod_php/apache_mod_php-87.2~1/Root/usr/local' '--with-jpeg-dir=/BinaryCache/apache_mod_php/apache_mod_php-87.2~1/Root/usr/local' '--with-png-dir=/Bin
@cvn
cvn / phpinfo-alfred
Created June 14, 2014 16:42 — forked from cvn/phpinfo-cli
Output from phpinfo() in Alfred
PHP Version => 5.4.24
System => Darwin ground.local 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64
Build Date => Jan 19 2014 21:18:21
Configure Command => '/private/var/tmp/apache_mod_php/apache_mod_php-87.2~1/php/configure' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--sysconfdir=/private/etc' '--with-apxs2=/usr/sbin/apxs' '--enable-cli' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/Library/Server/Web/Config/php' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--disable-cgi' '--with-curl=/usr' '--enable-dba' '--enable-ndbm=/usr' '--enable-exif' '--enable-fpm' '--enable-ftp' '--with-gd' '--with-freetype-dir=/BinaryCache/apache_mod_php/apache_mod_php-87.2~1/Root/usr/local' '--with-jpeg-dir=/BinaryCache/apache_mod_php/apache_mod_php-87.2~1/Root/usr/local' '--with-png-dir=/Bin
@cvn
cvn / class.format.php
Created May 2, 2011 02:14
Vanilla forums (v2) youtube / vimeo mods
<? // Replace LinksCallback() in class.format.php with the below, starting at line 551
protected static function LinksCallback($Matches) {
$Pr = $Matches[1];
$Url = $Matches[2];
if (preg_match('/(www\.)?youtube.com\/watch\?v=([^&]+)/', $Url, $Matches) && C('Garden.Format.YouTube')) {
$ID = $Matches[2];
$Width = 640;
$Height = 390;
$Result = <<<EOT
<div class="Video"><iframe title="YouTube video player" width="$Width" height="$Height" src="http://www.youtube.com/embed/$ID" frameborder="0" allowfullscreen></iframe></div>
@cvn
cvn / linkify.js
Created September 7, 2011 01:37
linkify twitter feed
function linkify(tweet_text,entities){
// function borrowed from http://140dev.com/free-twitter-api-source-code-library/twitter-display/linkify-php/
// entities is an object delivered by the Twitter API for each tweet with
// the user @mentions, hastags, and URLs broken out along with their positions
// Constants
var user_mention_url = 'http://twitter.com/',
user_mention_title = '';
hashtag_url = 'http://twitter.com/search?q=',
hashtag_title = '';
@cvn
cvn / gist:2981807
Created June 24, 2012 05:38
Apache icons workaround for Webfaction (httpd.conf)
<IfModule mod_autoindex.c>
Alias /webfaction-apache-icons /var/www/icons
AddIconByEncoding (CMP,/webfaction-apache-icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/webfaction-apache-icons/text.gif) text/*
AddIconByType (IMG,/webfaction-apache-icons/image2.gif) image/*
AddIconByType (SND,/webfaction-apache-icons/sound2.gif) audio/*
AddIconByType (VID,/webfaction-apache-icons/movie.gif) video/*
43 requests ❘ 71.68KB transferred ❘ 8.09s (onload: 3.44s, DOMContentLoaded: 3.18s)
tiff.png
/static/img/icons/system/128
app.png
/static/img/icons/system/128
jar.png
/static/img/icons/system/128
:8000/api/industry/uploadgroup/
HeadersContent
NameError at /new-account
global name 'forms' is not defined
Request Method: POST
Request URL: http://localhost:8000/new-account
Django Version: 1.4.1
Exception Type: NameError
Exception Value:
global name 'forms' is not defined
Exception Location: /Users/chad/Sites/post/Post/source/postghost/apps/webplayer/views.py in clean_email, line 223
Python Executable: /Users/chad/Sites/post/ENV/bin/python
@cvn
cvn / functions.php
Last active December 18, 2015 05:39
Wordpress Subheading plugin tab order fix
/**
* Inject javascript to fix tab order for Subheading plugin input field
*/
function add_jquery_data() {
// only load on new post / edit post page
global $parent_file;
if ( is_admin() && $parent_file == 'edit.php'): ?>
<script type="text/javascript">
jQuery(document).on('ready', function(){
var titleInput = jQuery('input#title')