This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use warnings; | |
use strict; | |
sub main { | |
#sub say { print "@args\n" }; | |
my $dir = "/tmp/$ENV{USER}/runc"; | |
my $file = "oneliner.c"; | |
my $out = $file; | |
$out =~ s/..$//; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse, os, sys, re, inspect, fileinput | |
from textwrap import dedent | |
# [NOTE001] -- Hack to get multiple argparse.formatter_class See stackoverflow.com #18462610 for more details | |
__author__ = "Stephen Meckley" | |
__created__ = "05/11/2014" | |
def main(argv=None): | |
"""main function for module""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run with: | |
// ~/bin/runc -f ~/examples/c/define_vs_bitfield.c | |
// Good resource that talks about the tradeoffs between bitfields and macros: | |
// http://docs.embarcadero.com/prodt3ts/rad_studio/delphiAnt2pp2009/HelpUpdate2/EN/html/devwin32/bitfields_xml.html | |
#include <stdio.h> | |
#ifndef UINT8 | |
#define UINT8 uint8 | |
typedef unsigned char uint8_t; | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
enum { | |
plain = 0, | |
bold = 1, | |
italic = 2 | |
}; | |
void PrintString(const char* message, int size, int style) | |
{ | |
printf("%s[%s] %s: %d %d\n" ,__FILE__,__FUNCTION__, message, size, style); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
backgroundColor = (0,)*3 | |
pixelSize = 9 | |
image = Image.open('input.png') | |
image = image.resize((image.size[0]/pixelSize, image.size[1]/pixelSize), Image.NEAREST) | |
image = image.resize((image.size[0]*pixelSize, image.size[1]*pixelSize), Image.NEAREST) | |
pixel = image.load() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find -type f -newermt 20111222 \! -newermt 20111225 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = ['crossABC', ['A', 'B', 'C'], ['r n w ', 'r n r ', 'r n n ', 'n w w ', 'n w r ', 'n w n', 'n r w ', 'n r r ', 'n r n ', 'n n w ', 'n n r ', 'n n n ']] | |
rm_space = lambda x: re.sub('\s+', ' ', x) | |
def do_leaf_nodes(it, str_func): | |
""" Apply function to all string based leaf nodes of an arbitrary structure """ | |
if isinstance(it, list): | |
for i, item in enumerate(it): | |
it[i] = do_leaf_nodes(item, str_func) | |
return it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
# Ex: python parse_strct_txt_file.py grpinfo.txt | |
# Tried to use "textFSM" but it was too restricting and writting the FSM was not that hard. | |
import sys, re, inspect, pprint | |
from collections import defaultdict | |
pp = pprint.PrettyPrinter(indent=4) | |
def parse_cov_strct_txt_file( cov_strct_txt_file ): | |
C = '' # The current register we are working on | |
s = 'Samples_crossed' # The current state of the parser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mergedicts(d1, d2): | |
"""Recursively merge an arbitrary number of dictionaries | |
For common keys d2 will overwrite d1 values. | |
import pprint | |
d1 = 1: {'a': 'A'}, | |
2: {'b': 'B'}, | |
3: {'c': {'c': 'C'}}, | |
4: ['i', 'j']} | |
d2 = {2: {'b': 'BB', | |
'd': {'d': 'D'}}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_leaf_nodes(it, str_func): | |
""" Apply function to all string based leaf nodes of an arbitrary structure. Ex: | |
do_leaf_nodes( self.test_opts, self.check_for_required_args ) | |
""" | |
if isinstance(it, list): | |
for i, item in enumerate(it): | |
it[i] = do_leaf_nodes(item, str_func) | |
return it | |
elif isinstance(it, dict): | |
for key in it: |