Skip to content

Instantly share code, notes, and snippets.

@xantus
xantus / 0_reuse_code.js
Created October 22, 2013 15:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@xantus
xantus / irc.pl
Created September 27, 2011 19:31 — forked from kraih/irc.pl
#!/usr/bin/env perl
use Mojolicious::Lite;
use EV;
use AnyEvent::IRC::Client;
# Join #mojo on irc.perl.org
my $irc = AnyEvent::IRC::Client->new;
$irc->connect('irc.perl.org', 6667, {nick => "mojobot$$"});
$irc->send_srv(JOIN => '#mojo');
#!/usr/bin/perl
# Copyright 2010 (c) David Davis - http://xant.us/
# BSD License
# built using webtreemap
# http://github.com/martine/webtreemap
# *DOWNLOAD MOJO FIRST*
# git clone http://github.com/kraih/mojo.git
<script>
// create a QR code to this page's href using google's chart api
// positioned in the right corner. click to enlarge. click again to hide
// http://googlecode.blogspot.com/2008/07/qr-codes-now-available-on-google-chart.html
document.write([
'<img src="http://chart.apis.google.com/chart?chs=150x150&cht=qr&choe=UTF-8&chld=L|1&chl=',
encodeURIComponent(window.location.href),
'" width="35" height="35" alt="QR Code" title="Click Me!" ',
'style="position:absolute;top:10px;right:10px;" ',
'onclick="if(this.width==35){this.width=this.height=150;}else{this.style.display=\'none\';}"/>'
@xantus
xantus / JSON.pm
Created August 2, 2010 19:39
MojoX::JSON
package MojoX::JSON;
use Mojo::JSON;
our $SINGLETON;
BEGIN {
# install JSON::XS if you can!
eval 'use JSON();';
eval ( $@ ? 'sub HAS_JSON(){ 0 }' : 'sub HAS_JSON(){ 1 }' );
@xantus
xantus / gist:496694
Created July 28, 2010 23:18
patch - base64 encoded data sections
diff --git a/lib/Mojo/Command.pm b/lib/Mojo/Command.pm
index 1a92e50..8cfa2dd 100644
--- a/lib/Mojo/Command.pm
+++ b/lib/Mojo/Command.pm
@@ -118,6 +118,9 @@ sub get_all_data {
my $all = {};
while (@data) {
my ($name, $content) = splice @data, 0, 2;
+ if ( $name =~ s/;base64$// ) {
+ $content = b($content)->b64_decode->to_string;
@xantus
xantus / ignite-lite.pl
Created July 28, 2010 20:48
ignite-lite example
#!/usr/bin/perl
use File::Basename 'dirname';
use File::Spec;
my $bin;
BEGIN {
$bin = join( '/', File::Spec->splitdir(dirname(__FILE__)) );
}
var MAX = 10000000, i;
var arr = [];
console.time("assignment");
for (i = 0; i < MAX; i++) {
arr[arr.length] = i;
}
console.timeEnd("assignment");
@xantus
xantus / growl-libnotify-wrapper.pl
Created February 8, 2010 20:59
A simple wrapper for libnotify that takes growlnotify params
#!/usr/bin/env perl
use strict;
use warnings;
# TBD: locate these using env?
# mac
my $growl = '/usr/bin/growlnotify';