Skip to content

Instantly share code, notes, and snippets.

View ironcamel's full-sized avatar

Naveed Massjouni ironcamel

  • Blacksburg, VA, USA
View GitHub Profile
@mjangda
mjangda / console-error.js
Created April 29, 2010 19:37
Protects you from console.log() errors for your IE and Firebug-less Firefox users.
// In case we forget to take out console statements. IE becomes very unhappy when we forget. Let's not make IE unhappy
if(typeof(console) === 'undefined') {
var console = {}
console.log = console.error = console.info = console.debug = console.warn = console.trace = console.dir = console.dirxml = console.group = console.groupEnd = console.time = console.timeEnd = console.assert = console.profile = function() {};
}
@melo
melo / .bash_prompt
Created October 12, 2010 23:56
My PS1 bash setup
#!/bin/bash
#
# PS1 magic
#
# Mostly copied from YUVAL KOGMAN version, added my own __git_ps1 stuff
# Original: http://gist.github.com/621452
#
# See video demo of this at http://vimeo.com/15789794
#
# To enable save as .bash_prompt in $HOME and add to .bashrc:
@avar
avar / benchmark-hello.pl
Created October 17, 2010 13:45
Benchmark Hello world programs. From http://news.ycombinator.com/item?id=1800220
#!/usr/bin/env perl
use strict;
use warnings;
use autodie qw(:all);
use Benchmark qw(:all);
use File::Temp qw(tempdir);
use File::Spec::Functions qw(catfile);
my $dir = tempdir(CLEANUP => 0);
my $obj_file = emit_c($dir);
@tildedave
tildedave / ruby-1.8.7-is-poorly-scoped.rb
Created December 2, 2010 14:03
from Andrew Kennedy
# scoping in ruby 1.8.7
x = 0
[1,2,3].each{|x| puts x}
puts x
@ironcamel
ironcamel / index.tt
Created December 20, 2010 09:01
A simple websocket web app using the Dancer web framework http://perldancer.org
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
var socket;
$(function() {
// ws_path should be of the form ws://host/_hippie/ws
var ws_path = "ws:<% request.base.opaque %>_hippie/ws";
@schwern
schwern / mxd_vs_ms_vs_perl.pl
Created January 10, 2011 06:21
Benchmarking MooseX::Declare vs Method::Signatures vs hand written
#!/usr/bin/perl -w
use MooseX::Declare;
class WithDeclare {
has greetings =>
is => 'rw',
isa => 'Str',
default => "Hello"
;
@tildedave
tildedave / automated-war-deploy.pl
Created January 31, 2011 21:41
Watch a WAR file for changes, and then deploy it to the root of a running tomcat instance.
#!/usr/bin/perl
use strict;
use warnings;
use File::Monitor;
use File::Path::Expand;
use File::Copy;
use File::Remove;
use App::Rad;
@lfborjas
lfborjas / gist:817504
Created February 8, 2011 23:12
Filter even numbers in a list; fork it for maximum fun!
#these are meant to be run in a REPL, and the java one in beanshell of something of the sort:
#ruby
[1,2,3,4].select{ |x| x.even? }
#python
[x for x in [1,2,3,4] if not x%2]
#or, more norvingly
filter(lambda x: not x%2, [1,2,3,4])
#clojure
#!perl
use strict;
use Acme::CPANAuthors;
use File::Find;
use Getopt::Long;
use LWP::Simple;
use File::Temp qw(tempdir);
use Acme::CPANAuthors::Japanese;
use CPAN::DistnameInfo;
use Compress::Zlib;
@throughnothing
throughnothing / gist:936021
Created April 22, 2011 04:37
PRU examples -> Perl
# grep --- all lines including foo
ls -al | grep foo
ls -al | pru /foo/
ls -al | perl -ne 'print if /foo/'
perl -E 'say for <*foo*>'
# grep --- all lines including current date
ls -al | grep $(date +"%Y-%m-%d")
ls -al | pru 'include?(Time.now.strftime("%Y-%m-%d"))'
ls -al | perl -MTime::Piece -ne '$d=localtime->strftime("%Y-%m-%d");print if /$d/'