Skip to content

Instantly share code, notes, and snippets.

set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "kraihlight"
@MoritzStefaner
MoritzStefaner / .block
Last active October 15, 2024 16:35
Force-based label placement
license: apache-2.0
@jamiehodge
jamiehodge / gist:1327195
Created October 31, 2011 09:38
Warden and Sinatra example
require 'sinatra/base'
require 'rack/flash'
require 'warden'
require 'slim'
require 'sequel'
require 'sqlite3'
DB = Sequel.sqlite
DB.create_table :users do
primary_key :id
@kraih
kraih / irc.pl
Created September 27, 2011 15:22
#!/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');
package Mojo::IOWatcher::AnyEvent;
use Mojo::Base 'Mojo::IOWatcher';
use AE;
use Scalar::Util 'weaken';
$ENV{MOJO_IOWATCHER} ||= 'Mojo::IOWatcher::AnyEvent';
my $SINGLETON;
@tlrobinson
tlrobinson / almost-node-inception
Created May 20, 2011 06:51
jslinux on node.js
tlrobinson@tlr-mac-pro ~/Projects/jslinux (1) $ node linux.js
loaded vmlinux26.bin (1753221 bytes to location 0x100000)
loaded root.bin (3461120 bytes to location 0x400000)
loaded linuxstart.bin (14858 bytes to location 0x10000)
Starting Linux
Linux version 2.6.20 (jdub@fehung) (gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) ) #2 Tue May 17 21:52:21 EST 2011
BIOS-provided physical RAM map:
sanitize start
sanitize bail 0
BIOS-88: 0000000000000000 - 000000000009f000 (usable)
#!/usr/bin/env perl
use strict;
use warnings;
# Use bundled libraries
use FindBin;
use lib "$FindBin::Bin/../lib";
# Mamma Mia! The cruel meatball of war has rolled onto our laps and ruined
@kraih
kraih / proxy.pl
Last active September 5, 2015 09:34
use Mojolicious::Lite;
my $feed = 'http://blog.kraih.com/rss.xml';
get '/blog/atom/perl/atom.xml' => sub {
my $self = shift;
$self->ua->max_redirects(5)->get($feed => sub {
$self->render(text => shift->res->body, format => 'rss');
});
};
use Mojolicious::Lite;
get '/title' => sub {
my $self = shift;
my $url = $self->param('url');
$self->render(text =>
$self->client->get($url)->success->dom->at('title')->text);
};
app->start;
use Mojolicious::Lite;
websocket '/echo' => sub {
my $self = shift;
$self->on(message => sub {
my ($self, $message) = @_;
$self->send("echo: $message");
});
};