Skip to content

Instantly share code, notes, and snippets.


Gary Haran garyharan

View GitHub Profile
garyharan / rails
Created Jul 29, 2014
View rails
# This file was generated by RubyGems.
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
require 'rubygems'
garyharan / gist:e680b5a22d9b4d76f0f2
Created Feb 17, 2015
When Postgresql complains user does not exist
View gist:e680b5a22d9b4d76f0f2
This can happen when active directory or someone else installed postgresql without proper right like a sudo brew install postgres instead of a brew install postgres.
To fix you can entirely destroy the db and recreate it with your user:
rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8
View .gitconfig
[filter "hawser"]
clean = git hawser clean %f
smudge = git hawser smudge %f
required = true
ui = auto
name = Gary Haran
email =
[mergetool "Kaleidoscope"]
View gist:123032
$(document).ready(function () {
$("a.remove").click(function() {
$.post(this.href, {_method: "delete"});
return false;
View Sample time stamp plugin
$('p[time]').live('mouseover', function() {
var insertion = $(this);
var insertionTime = insertion.attr('time');
var timeSpan = insertion.find('span.time');
if (timeSpan.length) {;
} else {
var date = new Date();
date.setTime(insertionTime * 1000);
View github-talker-plugin.js
plugin.onMessageInsertion = function(event){
// regex is probably wrong
var github_status_expression = /https*:\/\/\/(.*)\/(.*)/i;
var last_anchor = Talker.getLastInsertion().find('a');
var last_href = last_anchor.attr('href') || '';
if (github_status_expression.test(last_href)){
var author = last_href.match(github_status_expression)[1];
View plugin.privateChat.js
// jQuery.nano template engine
(function(c){c.nano=function(d,e){return d.replace(/\{([\w\.]*)}/g,function(a,f){a=f.split(".");var b=e[a.shift()];c.each(a,function(){b=b[this]});return b})}})(jQuery);
var vendorStyles = function(str){
var s = str.split('-');
if (s.length == 4 && s[0] == 'border'){
var value = s[3].split(':')[1];
View Vimeo Plugin
plugin.onMessageReceived = function(event){
var vimeo_expression = /^(?:http\S+vimeo\.com\/)(\d+)/;
var vimeo_match = event.content.match(vimeo_expression);
if (vimeo_match){
Talker.insertMessage(event, '<object width="400" height="220">'
+ '<param name="allowfullscreen" value="true" />'
+ '<param name="allowscriptaccess" value="always" />'
+ '<param name="movie" value="' + vimeo_match[1]
+ '&amp;;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />'
View gist:303306
2 == "2"
2 === "2"
typeof 2
View gist:327038
140 char limit sucks
Node.js matters because:
- JS programmers now have access to their language on the server (ignoring Netscape server for a minute).
- concurrent programming is the hot topic "du jour" and languages that embrace events like JS make for a good mix with this topic "du jour"
- Node.js is faster than Ruby yet still very expressive
- JS has a good chance to become the lingua franca for programmers much like PHP is for the web today.
You can’t perform that action at this time.