Skip to content

Instantly share code, notes, and snippets.

View benvanstaveren's full-sized avatar

Ben van Staveren benvanstaveren

View GitHub Profile
[
{
"title" : "Technical Engineer: U.S.S.R.",
"id" : 127,
"ident" : "mechanicEngineer0"
},
{
"title" : "maxPiercingSeries",
"id" : 32,
"ident" : "maxPiercingSeries"
#!/usr/bin/perl
use strict;
use warnings;
use Mojo::IOLoop;
my ($ip, $port, $status);
Mojo::IOLoop->client({ port => $port, address => $ip } => sub {
my ($loop, $error, $stream) = (@_);
# somewhere the app has a 'mango' attribute that was set up like this:
# $app->attr(mango => sub { Mango->new('localhost') });
sub some_action {
my $self = shift;
$self->render_later;
$self->mango->db('mydb')->collection('baz')->find_one({ _id => $self->req->param('id') } => sub {
my ($coll, $err, $doc) = (@_);
if($err) {
$self->render(json => { error => $err });
# the 0x67 message def
$srv_msg->[0x67] = def_msg(0x67, 'Set Slot', [
pair(window_id => MC_byte),
pair(slot => MC_short),
slotupdate('slot_data'),
]);
# MC_byte and MC_short reader implementations
sub read_byte { return unpack('c', shift->read(1)) }
@benvanstaveren
benvanstaveren / gist:4197629
Created December 3, 2012 20:08
perl implementation of mc3p's Stream class (well, most of it)
package Halcyon::Buffer;
use Mojo::Base '-base';
# a reimplementation of mc3p's Stream class, of sorts
has 'raw' => '';
has 'i' => 0;
has 'tot_bytes' => 0;
has 'wasted_bytes' => 0;
sub append {
0xde 0x72 0xbe 0xa0 0xde 0x04 0xbe 0xb1 0xde 0xfe 0xbe 0xef 0xde 0xad 0xbe 0xef
DE 72 BE A0 DE 04 BE B1 DE FE BE EF DE AD BE EF
my $bc = 0;
my $previous_block;
while(my $bread = $data->read(my $block, 8)) {
if($bread < 8) {
my $missing = 8 - $bread;
$block .= chr(0) x $missing;
}
if($bc > 0) {
my $decrypted_block = $self->blowfish->decrypt($block);
my $bc = 0;
my $previous_block;
while(my $bread = $data->read(my $block, 8)) {
if($bread < 8) {
my $missing = 8 - $bread;
$block .= chr(0) x $missing;
}
if($bc > 0) {
my $decrypted_block = $self->blowfish->decrypt($block);
previous_block = null;
while replay_data_available:
block = get_8_bytes_from_replay_data
decrypted_block = decrypt_the_block(block)
if this_block is not the_first_block:
decrypted_block = decrypted_block xor previous_block
previous_block = decrypted_block
Version......: 0.7.4 #220
-- chat message dump -----------------
Source......: tomas907
Target......: #chat:channels/battle/team
Body........: docela fer
Source......: tomas907
Target......: #chat:channels/battle/team
Body........: ja hral za a-20 proti IX