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 BeforeSpace /^ */ containedin=ALL | |
syntax match AfterSpace / *$/ containedin=ALL | |
syntax match InsideSpace "\t *\t"hs=s+1,he=e-1 containedin=ALL | |
highlight BeforeSpace ctermbg=DarkBlue | |
highlight AfterSpace ctermbg=DarkBlue | |
highlight InsideSpace ctermbg=DarkBlue |
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
def main_setup (option_parsing, pager=True): | |
def decorator (real_main): | |
def main_wrapper (): | |
options, argv = option_parsing () | |
if pager and options.use_pager: | |
o, pager_is_less = get_pager () | |
else: | |
o, pager_is_less = sys.stdout, False | |
Colors.setup(enabled = not (options.no_colors or (not os.isatty (o.fileno ()) and not options.keep_colors and not pager_is_less))) | |
if options.debug is True: |
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
import sys | |
class handling_of_global_exceptions (object): | |
def __enter__ (self): | |
pass | |
def __exit__ (self, e_type, e_val, e_tb): | |
if isinstance (e_val, KeyboardInterrupt): | |
sys.stderr.write ("\nControl-C. Let's call it quits.\n") | |
elif isinstance (e_val, IOError) and e_val[1] == 'Broken pipe': |
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
# let's have a code that calls glibc's puts twice | |
somewhere in the code: | |
0x00000000004004c4 <+36>: bl 0x400490 <puts@plt> | |
# calling plt stub; return address is in link register (x30) | |
(gdb) p/x $x30 | |
$2 = 0x4004c8 | |
# bl stands for branch and link; like call on intel, but we use link register instead of top of stack for return adress |
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 <stdio.h> | |
#include <stdlib.h> | |
int main (int argc, char *argv[]) | |
{ | |
long from, i, j = 20L; | |
if (argc > 1) | |
from = atol (argv[1]); |
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 <decimal/decimal> | |
using namespace std; | |
using namespace decimal; | |
int main () | |
{ | |
decimal32 a (1.5); | |
decimal64 b (2.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
import re, sys | |
r = re.compile ('\d\d\d\d+') | |
with open ("b.list", "r") as f, open ("b.list.new", "w") as o: | |
n = 1 | |
for l in f: | |
m = r.search (l) | |
if m: | |
o.write ('{0:4}: https://gcc.gnu.org/bugzilla/show_bug.cgi?id={1} # {2}'.format (n, m.group (0), l)) |
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 | |
# pre-commit hook for removing whitespace | |
git diff-index --cached --name-only HEAD | { while read -r f | |
do | |
[[ -d .git ]] || cd $(git rev-parse --show-cdup) | |
sed -i 's/\s*$//' "$f" | |
git add "$f" | |
done; } |
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
# protected -O3 | |
0000000000000710 <bar>: | |
710: 48 8d 3d 0e 00 00 00 lea 0xe(%rip),%rdi # 725 <_fini+0x9> | |
717: e9 b4 fe ff ff jmpq 5d0 <puts@plt> | |
# default -O3 | |
0000000000000730 <bar>: | |
730: e9 cb fe ff ff jmpq 600 <foo@plt> | |
735: 0f 1f 00 nopl (%rax) |
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
echo 1000 > /proc/self/oom_score_adj | |
exec $@ |