Skip to content

Instantly share code, notes, and snippets.

View ironcamel's full-sized avatar

Naveed Massjouni ironcamel

  • Blacksburg, VA, USA
View GitHub Profile
file {
'/srv/exports':
owner => 'root',
group => 'root',
mode => '0755',
ensure => directory;
}
@ironcamel
ironcamel / recursive-closure.pl
Created March 25, 2012 18:43
Recursive closure
my $factorial = sub {
my $val = shift;
return $val * __SUB__->($val - 1) if $val > 1;
return $val;
};
print $factorial->(5);
@ironcamel
ironcamel / p
Created September 25, 2011 02:12 — forked from mfontani/raptor.sh
steroids for your perl one-liners.
#!/usr/bin/env perl
# Based on Randy Stauner's http://blogs.perl.org/users/randy_stauner/2011/06/exploratory-one-liners-with-less-typing.html
# and Marco Fontani's https://gist.github.com/1042504.
# To install all dependencies:
# sudo cpanm File::Slurp JSON::XS Data::Dump YAML::XS utf8::all Class::Autouse
# Installation:
# copy this file to ~/bin/p
# Example usage:
# p 'dd [File::Spec->path]' # dynamically load arbitrary modules
# p -pe 's/foo/bar/' foo.txt # use your favorite options like -lane
@ironcamel
ironcamel / script-runner.vim
Created September 15, 2011 04:47
vim script runner
nmap <F5> :call Run('perl')<CR>
cabbrev pyx call Run('python')
cabbrev perlx call Run('perl')
cabbrev rubyx call Run('ruby')
fu! NewThrowawayBuffer()
new
setlocal noswapfile
setlocal buftype=nowrite
setlocal bufhidden=delete
@ironcamel
ironcamel / JSON-Schema.diff
Created September 10, 2011 23:22
JSON::Schema bugfix patch
235c235
< checkProp($value, $type, $path, undef, $_changing);
---
> $self->checkProp($value, $type, $path, undef, $_changing);
283c283
< checkProp($value, $schema->{'extends'}, $path, $i, $_changing);
---
> $self->checkProp($value, $schema->{'extends'}, $path, $i, $_changing);
304,306c304,307
< if (ref $schema->{'items'} eq 'ARRAY')
/*
Treewidth is a class that reduces a graph by a series of "safe" rules.
It also generates a minimum value for the treewidth of the graph.
The rules that have been implemented so far are:
* Islet Rule
* Twig Rule
* Series Rule
* Triangle Rule
* Simplicial Rule
* Almost Simplicial Rule
@ironcamel
ironcamel / freenode.yml
Created March 29, 2011 22:14
IRC bot that notifies via libnotify popups and festival text-to-speech converter
conn_info:
server: irc.freenode.net
port: 6667
channels:
- '#foo'
- '#bar'
nick: foobot
username: foobot
name: defender of the universe
ignore_list:
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";
use LWP::UserAgent;
my $agent = LWP::UserAgent->new();
$agent->credentials($host, $realm, $user, $pass);
print $agent->get($uri)->content();