This file contains 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/bash | |
# | |
# Creates a multi-partition QEMU disk image from our buildroot outputs and embeds grub2 | |
# | |
# TODO: Better error handling | |
# TODO: Better args (grub.cfg path is assumed) | |
# | |
DEBUG=1 | |
IMAGE_NAME="dhc.img" |
This file contains 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 <iostream> | |
#include <queue> | |
#include <boost/variant.hpp> | |
struct message_tag { | |
bool handled = false; | |
message_tag() = default; | |
message_tag(std::nullptr_t) { } | |
}; |
This file contains 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 python2 | |
from Tkinter import * | |
# Input value | |
input_value = 0 | |
# Output value | |
output_value = 0 | |
# Output Location | |
output_field = None |
This file contains 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
# using lambdas | |
# | |
c_to_f = lambda c: (c * (9.0/5.0)) + 32 | |
f_to_c = lambda f: (f - 32) * (5.0/9.0) | |
print "Equality check: ", c_to_f(-40) == f_to_c(-40) | |
# using function | |
# |
This file contains 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
// List comprehension in C++11 in form of SQL-like syntax | |
// Example code from http://vitiy.info/cpp11-writing-list-comprehension-in-form-of-sql/ | |
// Written by Victor Laskin (victor.laskin@gmail.com) | |
#include <iostream> | |
#include <functional> | |
#include <vector> | |
#include <future> | |
#include <algorithm> | |
using namespace std; |
This file contains 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/bash | |
_FAIL="[-]" | |
_SUCCESS="[+]" | |
_NOTE="[*]" | |
function _progress() | |
{ | |
local PID=$1 | |
local msg="$2" |
This file contains 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
syntax match luaMinus /-\@<!--\@!/ | |
syntax match simpleOperator "[.!~:*&%<>^|=,+]" | |
syntax match simpleOperator "/[^/*=]"me=e-1 | |
syntax match simpleOperator "/$" | |
syntax match simpleOperator "&&\|||" | |
syntax match simpleOperator "[][]" | |
syntax match parenDelimiter "[();\\]" | |
syntax match luaCustomParen "(" contains=parenDelimiter | |
syntax match luaCustomFunc "\w\+\s*(" contains=luaCustomParen |
This file contains 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
median = lambda data: data[len(data)/2] | |
mean = lambda data: float(sum(data)/len(data)) | |
hi_low = lambda data: (data[0], data[len(data)-1]) | |
variance = lambda data, avg: sum([x**2 for x in [i-avg for i in data]])/float(len(data)) | |
std_dev = lambda data: math.sqrt(variance(data, mean(data))) |
This file contains 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
# Anthony Clark | |
# | |
# Simple TFTP Server in Twisted | |
# TODO timeouts/error handling | |
# | |
# | |
# Most TFTP server do not have a | |
# way to change file root per client. | |
# This one does however using the client | |
# map below |
This file contains 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/bash | |
# Dialog progress for targz | |
# Taken from `man pv` | |
[ $# -lt 2 ] && echo "Supply output filename.tgz and list of files" && exit 1 | |
out=$1 | |
shift; files=$@ | |
(tar cf - $files \ | pv -n -s $(du -sbc $files | grep 'total' | awk '{print $1}') \ | |
| gzip -9 > $out) 2>&1 | dialog --gauge 'Progress' 7 70 |