Skip to content

Instantly share code, notes, and snippets.

@xenoterracide
xenoterracide / empty.sql
Created January 19, 2010 17:02
Find empty strings or strings containing only whitespace, for postgresql
CREATE OR REPLACE FUNCTION empty(TEXT)
RETURNS bool AS
$$ SELECT $1 ~ '^[[:space:]]*$'; $$
LANGUAGE sql
IMMUTABLE;
COMMENT ON FUNCTION empty(TEXT)
IS 'Find empty strings or strings containing only whitespace';
@xenoterracide
xenoterracide / example-empty-check.sql
Created January 19, 2010 17:47
example create table that uses a CHECK for empty() values
CREATE TABLE example (
field TEXT
NOT NULL
CHECK ( NOT empty( field ))
);
#!/bin/bash
# see my whole file @ http://github.com/xenoterracide/dot_etc/blob/master/bashrc
# set a good defaults if we aren't using konsole
export PS1='\[\033[01;32m\]\h\[\033[01;34m\] \W $ \[\033[00m\]'
umask 0077
# set up env based on KONSOLE_PROFILE and KONSOLE_SESSION
# Test to see if the KONSOLE_PROFILE is empty
@xenoterracide
xenoterracide / game.pl
Created April 18, 2010 20:25
Guess a Number game
#!/usr/bin/env perl
# guess a number game
use feature 'say';
use strict;
use warnings;
say "welcome";
say "Guess the number: ";
my $guess = readline(*STDIN);
@xenoterracide
xenoterracide / game.pl
Created April 18, 2010 22:34
Guess a number game
#!/usr/bin/env perl
# guess a number game
use feature 'say';
use strict;
use warnings;
say "welcome";
say "Guess the number: ";
my $guess = readline(*STDIN);
@xenoterracide
xenoterracide / game.pl
Created April 18, 2010 23:26
Guess a number game
#!/usr/bin/env perl
# guess a number game
use feature 'say';
use strict;
use warnings;
say "welcome";
my $guess = 0;
until ( $guess == 5 ) {
@xenoterracide
xenoterracide / game.pl
Created April 18, 2010 23:47
Guess a number game
#!/usr/bin/env perl
# guess a number game
use feature 'say';
use strict;
use warnings;
say "welcome";
my $winning_num = 5;
@xenoterracide
xenoterracide / game.pl
Created April 19, 2010 00:40
Guess a number game
#!/usr/bin/env perl
# guess a number game
use feature 'say';
use strict;
use warnings;
say "welcome";
# generate the winning number between 1 and 10
my $winning_num = int( rand(10) );
@xenoterracide
xenoterracide / game.pl
Created April 19, 2010 01:24
Guess a number game
#!/usr/bin/env perl
# guess a number game
use feature 'say';
use strict;
use warnings;
say "welcome";
# generate the winning number between 1 and 10
# see perlfaq4 for algorithm details
@xenoterracide
xenoterracide / game.pl
Created April 19, 2010 01:53
guess a number game
#!/usr/bin/env perl
# guess a number game
use feature 'say';
use feature 'switch';
use strict;
use warnings;
say "welcome";
# generate the winning number between 1 and 10