Skip to content

Instantly share code, notes, and snippets.

View exodist's full-sized avatar

Chad Granum exodist

View GitHub Profile
python -m SimpleHTTPServer $PORT
for i in `seq 1 254`; do echo -n "."; ping -c 1 -w 1 192.168.0.$i > /dev/null; if [ $? -eq 0 ]; then echo -n " $i "; fi; done
#!/usr/bin/perl;
use strict;
use warnings;
use Test::More;
my $time = 60;
if ( @ARGV ) {
writer();
int main (int argc, char* argv[]) {
int i;
int pi;
const char* perl_cmd = "%s";
char* perl_args[argc+1];
char* dash_m = (char *)malloc(sizeof(char) * (strlen(argv[0]) + 20));
char* dash_e;
strcat(dash_m, "-Mperl5i::cmd=");
strcat(dash_m, argv[0]);
The following will try to find the line number using the following logic:
Asserts calls are not method calls
Asserts are the last call from the class using the known assert (ok)
A stack of line numbers starting from the last known assert class can be listed in cases of ambiguity, This narrows the list down to a couple choices for the user. For instance, "Test failure at line number 10, 20, or 30.
This gives the user useful information, does not require anyone to do anything special when writing assertions that call is, ok, etc. In some cases it might not be the exact line number, but will probably never give more than 2 or 3 choices.
#!/usr/bin/perl
package Test::LineNumber;
struct Pattern;
struct Node;
struct Controls;
struct Meta;
struct MetaMap;
struct PatternMap;
#include "Pattern.h"
#include "PatternNode.h"
#include <stdlib.h>
struct Pattern {
PatternNode *start;
char *pattern_string;
short match_case;
};
exodist@dev1 $ ls -l /usr/include/glib-2.0/glib.h && gcc -I/usr/include/glib-2.0/ -O2 -c Pattern.c [~/projects/Oyster/GrammarEngine/src]
-rw-r--r-- 1 root root 2769 May 22 15:49 /usr/include/glib-2.0/glib.h
In file included from /usr/include/glib-2.0/glib/galloca.h:34,
from /usr/include/glib-2.0/glib.h:32,
from Pattern.c:5:
/usr/include/glib-2.0/glib/gtypes.h:34:24: error: glibconfig.h: No such file or directory
/usr/include/glib-2.0/glib/gtypes.h:410:2: error: #error unknown ENDIAN type
In file included from /usr/include/glib-2.0/glib.h:33,
from Pattern.c:5:
/usr/include/glib-2.0/glib/garray.h:50: error: expected specifier-qualifier-list before 'guint8'
exodist@dev1 $ time perl ./builddb.pl [~/projects/Oyster/GrammarEngine/ucd]
perl ./builddb.pl 0.39s user 0.01s system 88% cpu 0.451 total
exodist@dev1 $ time gcc -o x unidb.c [~/projects/Oyster/GrammarEngine/ucd]
gcc -o x unidb.c 1.25s user 0.09s system 93% cpu 1.440 total
exodist@dev1 $ time ./x > /dev/null [~/projects/Oyster/GrammarEngine/ucd]
./x > /dev/null 0.00s user 0.00s system 41% cpu 0.005 total
exodist@dev1 $ time ./x [~/projects/Oyster/GrammarEngine/ucd]
... SNIP ...
./x 0.00s user 0.00s system 73% cpu 0.004 total
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
sub blah { 'blah' }
bless( \&blah, 'AAAA' );
print Dumper( \&blah );
# output
# $VAR1 = bless( sub { "DUMMY" }, 'AAAA' );