Skip to content

Instantly share code, notes, and snippets.

@alexdioso
alexdioso / gist:2439315
Created April 21, 2012 19:56
Display username and hostname in tmux window title
case "$TERM" in
screen)
export PROMPT_COMMAND='echo -ne "\033]2;${USER}@${HOSTNAME}: ${PWD}\007\033k${USER}@${HOSTNAME}\033\\"'
;;
esac
@alexdioso
alexdioso / gist:1494860
Created December 18, 2011 23:53
BrowserID without jQuery
document.getElementById('loginbutton').addEventListener(
"click",
function(event) {
navigator.id.getVerifiedEmail(function(assertion) {
if (assertion !== null) {
alert("logged in");
} else {
alert("not logged in");
}
});
@alexdioso
alexdioso / gist:1494853
Created December 18, 2011 23:48
BrowserID and jQuery
$('#loginbuttn').click(function() {
navigator.id.getVerifiedEmail(
function(assertion) {
if (assertion !== null) {
alert("logged in");
} else {
alert("not logged in")
}
}
)
@alexdioso
alexdioso / Makefile
Created September 19, 2011 22:39
Go Makefile with debug target
include $(GOROOT)/src/Make.inc
TARGDIR=../bin
TARG=myprogram
GOFILES=\
myprogram.go\
CLEANFILES+=$(TARG)-debug
include $(GOROOT)/src/Make.cmd
@alexdioso
alexdioso / perlDisableDbiHandleError.pl
Created September 18, 2011 19:54
Perl disable DBI HandleError
my $previous_handler = $dbh->{'HandleError'};
$dbh->{'HandleError'} = undef;
eval {
$sth_insert->execute;
$dbh->{'HandleError'} = $previous_handler;
1;
} or do {
$dbh->rollback;
# Insert failed, try an update
# No check needed because HandleError was restored
@alexdioso
alexdioso / perlDbiHandleError.pl
Created September 18, 2011 19:51
Perl DBI HandleError
my $dbh = DBI->connect(
'dbi:Pg:dbname=DATABASE_NAME',
q{},
q{},
{
RaiseError => 1,
AutoCommit => 0,
PrintError => 0,
ShowErrorStatement => 1,
HandleError => sub {
@alexdioso
alexdioso / perlEvalDbError.pl
Created September 18, 2011 19:42
Perl eval db error
my $dbh = DBI->connect(
'dbi:Pg:dbname=DATABASE_NAME',
q{},
q{},
{
RaiseError => 1,
AutoCommit => 0,
PrintError => 0,
ShowErrorStatement => 1
}
@alexdioso
alexdioso / DesignAndRunTime.xaml
Created August 22, 2011 23:28
Run-time and design-time selection of a ViewModel using only xaml.
<Window Name="mMainView"
x:Class="MyProject.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:MyProject.ViewModels"
mc:Ignorable="d"
Title="My Project" Height="450" Width="800">
<mc:AlternateContent>