Skip to content

Instantly share code, notes, and snippets.

View pstuifzand's full-sized avatar

Peter Stuifzand pstuifzand

View GitHub Profile
@pstuifzand
pstuifzand / NBT.bfft
Created December 14, 2014 11:48
Minecraft NBT bfft (bininspector)
include 'utf8.bfft'
struct tag_byte {
unsigned 8 big byte;
summary 'Byte(', byte, ')';
}
struct tag_short {
unsigned 16 big short;
summary 'Short(', short, ')';
@pstuifzand
pstuifzand / main.go
Created March 9, 2015 06:50
Git pull tool
package main
import (
"bufio"
"io"
"log"
"net"
"os/exec"
"strings"
)
@pstuifzand
pstuifzand / fetch.php
Created April 7, 2015 06:02
Magento database collection speed tests
<?php
include_once('app/Mage.php');
Mage::app('default');
function makeWalker($collection, $modelName) {
///echo $collection->getSelect(). "\n";
return array($collection->getSelect()->query(), $modelName);
}
@pstuifzand
pstuifzand / menu2.html
Last active August 29, 2015 14:18
Menu without delay
<!doctype html>
<html>
<head>
<style>
* {
padding:0;
margin:0;
box-sizing:border-box;
}
body {
@pstuifzand
pstuifzand / twitter.pl
Created July 31, 2009 13:40
Command line Twitter
# Simple commandline twitter script.
# Reads a line from STDIN and updates twitter.
# This doesn't work anymore, because of OAuth.
# Net::Twitter does support OAuth so it could be rewitten to make it work
# Created by Peter Stuifzand <peter.stuifzand@gmail.com>
use strict;
use warnings;
use Net::Twitter;
@pstuifzand
pstuifzand / just-one-space.vim
Created August 5, 2009 09:29
Just one space function for vim
" Replace many spaces with one in Vim
" With help from Al: http://stackoverflow.com/questions/1228100/substituting-zero-width-match-in-vim-script
function JustOneSpace()
" Get the current contents of the current line
let current_line = getline(".")
" Get the current cursor position
let cursor_position = getpos(".")
@pstuifzand
pstuifzand / gist:916575
Created April 12, 2011 22:22
I got this on the same request
127.0.0.1:5000
Start Time: Wed Apr 13 2011 00:20:59 GMT+0200 (CEST)
t=1302646859860 [st=0] +SOCKET_ALIVE [dt=4]
--> source_dependency = {"id":210,"type":4}
t=1302646859860 [st=0] +TCP_CONNECT [dt=0]
--> address_list = ["127.0.0.1:5000"]
t=1302646859860 [st=0] TCP_CONNECT_ATTEMPT [dt=0]
--> address = "127.0.0.1:5000"
@pstuifzand
pstuifzand / logfile.pl
Created April 13, 2011 14:32
Shows the HTTP status of the last few requests in the logfile
#!/usr/bin/perl -w
# Name: logtail.pl
# Description Shows the HTTP status of the last few requests in the logfile
# Usage: tail -f apachelogfile.log | perl logtail.pl
# Date: Wed Apr 13 16:31:35 CEST 2011
# Author: Peter Stuifzand
# License: GPL3+
use strict;
use Parse::AccessLogEntry;
@pstuifzand
pstuifzand / scribe_parser.pl
Created March 15, 2012 00:39
(Partial) Parser for Scribe built with Marpa::XS
#!/usr/bin/perl -w
use 5.10.1;
use strict;
use File::Slurp 'read_file';
use Marpa::XS;
my %tokens = (
AT => qr/^\@/,
LP => qr/^\(/,
@pstuifzand
pstuifzand / tree_structure_test.pl
Created March 30, 2012 18:10
Using Marpa with a tree structure
use Marpa::XS;
use Data::Dumper;
my $grammar = Marpa::XS::Grammar->new(
{ start => 'Expression',
actions => 'My_Actions',
rules => [
# This rebuilds the tree
{ lhs => 'Expression', rhs => [qw/Term/], action => 'Return_0' },