Skip to content

Instantly share code, notes, and snippets.

View ericvanjohnson's full-sized avatar
🐘
Probably doing PHP Stuff.

Eric Van Johnson ericvanjohnson

🐘
Probably doing PHP Stuff.
View GitHub Profile
@ericvanjohnson
ericvanjohnson / x
Created May 28, 2009 03:47
Ubiquity command the involks the HootSuite Bookmarklet
CmdUtils.makeBookmarkletCommand({
name: 'send-to-hootlet',
icon: "http://static.hootsuite.com/images-3-7-0/favicon.ico",
homepage: "http://www.esolves.com",
author: { name: "Eric Van Johnson", email: "eric@esolves.com"},
license: "GPL",
description: "Sends URL to post via Hootsuite.com",
help: "Type 'send-to-hootlet",
url: "javascript:var%20d=document,w=window,e=w.getSelection,f='http://hootsuite.com/twitter/bookmark-tool-v2?',l=d.location,e=encodeURIComponent,p='address='+e(l.href)+'&title='+escape(d.title),u=f+p;a=function(){if(!w.open(u,'t','scrollbars=1,toolbar=0,location=0,resizable=0,status=0,width=555,height=570'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();void(0);",
}
var http = require('http');
var pg = require('pg');
var connectionString = "pg://chartjes:********@localhost:5432/ibl_stats";
pg.connect(connectionString, function(err, client) {
if (err) {
console.log(err);
} else {
http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/html'});
@ericvanjohnson
ericvanjohnson / gist:2714758
Created May 16, 2012 23:05
.htaccess 301 Redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule (.*) http://newurl.com/$1 [R=301,L]
</IfModule>
@ericvanjohnson
ericvanjohnson / gist:3165983
Created July 23, 2012 20:17
Search for all cron jobs for all users
# List all cron jobs for all users
# Run from command line as root
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
# To know, which user does a crontab belong to insert echo $user
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
# List of useful Vim tricks. Most taken from @vimtips on Twitter
# CTRL-w | and CTRL-W _ maximize your current split vertically and horizontally, respectively. CTRL-W = equalizes 'em CTRL-w s CTRL-w T will open current buffer in new tab (via @vrybas_)
# qa starts a recording in register 'a'. q stops it. @a repeats the recording. 5@a repeats it 5 times.
# Comment out lines containing _pattern_ (if '#' is your comment character/sequence) (via @vrybas_)
:g/_pattern_/s/^/#/g
# re-tab all files in the buffers list.
public function gravatar($email, $size = 70, $default = "monsterid") {
return "http://www.gravatar.com/avatar/" .
md5(strtolower($email)) .
"?s=" . (integer) $size .
"&d=" . urlencode($default) .
"&r=G";
}
@ericvanjohnson
ericvanjohnson / gist:4235452
Created December 7, 2012 18:47
Nice BASH Prompt with Git Awareness
export PS1='\n\[\e[0;36m\]┌─[\[\e[0m\]\[\e[1;33m\]\u\[\e[0m\]\[\e[1;36m\]@\[\e[0m\]\[\e[1;33m\]\h\[\e[0m\]\[\e[0;36m\]]─[\[\e[0m\]\[\e[1;34m\]\w\[\e[0m\]\[\e[0;36m\]]\[\e[0;36m\]─$(__git_ps1 "[\[\e[1;37m\]%s\[\e[0m\]\[\e[0;36m\]]─")[\[\e[0m\]\[\e[0;31m\]\T\[\e[0m\]\[\e[0;36m\]]\[\e[0m\]\n\[\e[0;36m\]└─[\[\e[0m\]\[\e[1;37m\]\$\[\e[0m\]\[\e[0;36m\]]› \[\e[0m\]'
@ericvanjohnson
ericvanjohnson / bashprompt2.sh
Created January 22, 2013 01:14
Bash Prompt without Git Autocomplete
export PS1='\n\[\e[0;36m\]┌─[\[\e[0m\]\[\e[1;33m\]\u\[\e[0m\]\[\e[1;36m\]@\[\e[0m\]\[\e[1;33m\]\h\[\e[0m\]\[\e[0;36m\]]─[\[\e[0m\]\[\e[1;34m\]\w\[\e[0m\]\[\e[0;36m\]]\[\e[0;36m\]─[\[\e[0m\]\[\e[0;31m\]\T\[\e[0m\]\[\e[0;36m\]]\[\e[0m\]\n\[\e[0;36m\]└─[\[\e[0m\]\[\e[1;37m\]\$\[\e[0m\]\[\e[0;36m\]]› \[\e[0m\]'
@ericvanjohnson
ericvanjohnson / gist:4597775
Created January 22, 2013 19:45
Create a tree like structure from the ls command:
ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
@ericvanjohnson
ericvanjohnson / gist:4597822
Created January 22, 2013 19:49
Rsync over SSH (Remote to local)
rsync -ave "ssh" USER@REMOTE_SERVER:/remote/file/path/ /local/file/path/