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> | |
class A | |
{ | |
public: | |
A () { std::cout << "a"; } | |
~A () { std::cout << "A"; } | |
}; | |
int i = 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
# https://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html | |
# https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Breakpoint-Commands.html | |
def my_breakpoint_handler (event): | |
if (isinstance(event, gdb.BreakpointEvent) and (event.breakpoint.location == "g")): | |
print event.breakpoint.hit_count | |
gdb.events.stop.connect(my_breakpoint_handler) | |
gdb.execute("start") | |
gdb.execute("break g") |
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
# capabilities | |
rpm2cpio ../iputils-20121221-5.fc20.x86_64.rpm | cpio -ivd | |
rpm -qp --filecaps ../iputils-20121221-5.fc20.x86_64.rpm | grep '=' | awk '{ print "[ -L " $1 " ] || " "setcap " $3 " " "." $1; }' | bash | |
# permissions | |
rpm2cpio ../sudo-1.8.8-1.fc20.x86_64.rpm | cpio -ivd | |
rpm -qp --qf '[\[ -L %{FILENAMES:shescape} \] || chmod %7{FILEMODES:octal} %{FILENAMES:shescape}\n]' ../sudo-1.8.8-1.fc20.x86_64.rpm | sed -e "s|chmod ...|chmod |" -e "s|'/|'./|g" | bash |
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
################################################## | |
# profiler: | |
# https://docs.python.org/2/library/profile.html | |
# python -mcProfile -o profiler.out ./something.py | |
### profile.py ### | |
import pstats | |
p = pstats.Stats('profiler.out') | |
p.sort_stats('cumtime').print_stats(20) |
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 a(x=False, y=[]): | |
... if not x: | |
... y.append (5) | |
... else: | |
... print y | |
... | |
>>> a() | |
>>> a() | |
>>> a() | |
>>> a() |
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
git diff --name-status HEAD~30..HEAD |
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
$ cat problem_05.py | |
n = 2520 | |
while True: | |
for i in xrange (20, 0, -1): | |
if n % i != 0: | |
break | |
else: | |
print (n) | |
break |
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> | |
static int | |
factorial_helper (int n, int a) | |
{ | |
start: | |
a *= n; | |
if (n-- > 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
class Nonsense(object): | |
def __init__(self, n): | |
self.a = ['x'] * n | |
@property | |
def length(self): | |
return len(self.a) | |
@length.setter | |
def length(self, n): |
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
class MyList(list): | |
# alternative constructor | |
@classmethod | |
def multiple_of(cls, n, c): | |
return cls(c * n) | |
# some random method bundled in the class | |
@staticmethod | |
def print_with_numbers(a): | |
for n, e in enumerate(a): |