Skip to content

Instantly share code, notes, and snippets.

View aero's full-sized avatar

aero aero

  • Seoul, Republic of Korea
View GitHub Profile
@wilsonpage
wilsonpage / reqUrl.js
Created November 25, 2011 14:38
A function I made that wraps the node http.request function to make it a little more friendly. In my case I am using it for API route testing.
// module dependencies
var http = require('http'),
url = require('url');
/**
* UrlReq - Wraps the http.request function making it nice for unit testing APIs.
*
* @param {string} reqUrl The required url in any form
* @param {object} options An options object (this is optional)
@melo
melo / gist:1937200
Created February 29, 2012 02:54
Compiling perl 5.14.2 with perlbrew on CentOS 6 64bit with mod_perl support
# the fpic is needed for mod_perl
# so is usesshrplib
# use 64bitall just makes sense as uselargefiles
# the ldflags mimic the settings of the system perl
perlbrew install -j 8 5.14.2 \
-Dcccdlflags=-fPIC \
-Duseshrplib \
-Duse64bitall \
@olegwtf
olegwtf / json_ordered.pl
Created March 26, 2012 04:39
Save JSON object keys ordering as is
use strict;
use Tie::IxHash;
use JSON::PP;
# magic start
my $obj_parser_sub = \&JSON::PP::object;
*JSON::PP::object = sub {
tie my %obj, 'Tie::IxHash';
$obj_parser_sub->(\%obj);
@rodchyn
rodchyn / opkg-clean
Created August 8, 2012 11:24
opkg clean script
#!/bin/sh
opkg update
PACKAGES=`opkg --force-space --noaction install $1 | grep http | cut -f 2 -d ' ' | sed 's/.$//'`
for i in $PACKAGES
do
LIST=`wget -qO- $i | tar -Oxz ./data.tar.gz | tar -tz | sort -r | sed 's/^./\/overlay/'`
for f in $LIST
do
if [ -f $f ]
then
@joemiller
joemiller / netpps.sh
Last active January 12, 2024 15:39
shell: quick linux scripts for showing network bandwidth or packets-per-second
#!/bin/bash
if [ -z "$1" ]; then
echo
echo usage: $0 network-interface
echo
echo e.g. $0 eth0
echo
echo shows packets-per-second
@waylan
waylan / foo.sh
Created November 15, 2012 18:39
Simple bash subcommands. Each subcommand is implemented as a function. For example, `sub_funcname` is called for `funcname` subcommand.
#!/bin/sh
ProgName=$(basename $0)
sub_help(){
echo "Usage: $ProgName <subcommand> [options]\n"
echo "Subcommands:"
echo " bar Do bar"
echo " baz Run baz"
echo ""
use Plack::App::CGIBin;
use Plack::App::PHPCGI;
use Plack::Builder;
use File::Zglob;
my $cgibin = Plack::App::CGIBin->new(
root => "/usr/local/nagios/sbin",
exec_cb => sub { my $file = shift; $file =~ m!\.cgi$! and -x $file },
)->to_app;
my $static = Plack::App::File->new(root => "/usr/local/nagios/share")->to_app;
@tsee
tsee / terrain.h
Created April 25, 2013 17:53
terrain.h - a naive C implementation
#define NW 0
#define NE 1
#define SW 2
#define SE 3
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <EXTERN.h>
@krimdomu
krimdomu / gist:6080102
Created July 25, 2013 14:15
rex and expect
# Rexfile
use Expect;
set connection => "OpenSSH";
my $expect_timeout = 5;
my $git_password = 'f00b4r';
my $sudo_password = 'test';
@dwarring
dwarring / gist:6127599
Last active December 20, 2015 11:59
perl6 brainf*ck program
use v6;
grammar Brainfuck::Grammar {
rule TOP {^ [<cmd> || .+? ]* $}
proto token cmd { <...> }
token cmd:sym<ptr-inc> {\>}
token cmd:sym<ptr-dec> {\<}
token cmd:sym<inc> {\+}
token cmd:sym<dec> {\-}
token cmd:sym<input> {\,}