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 requests | |
from bs4 import BeautifulSoup | |
if __name__ == '__main__': | |
req = requests.get("https://www.coursera.org/learn/dsp4?specialization=digital-signal-processing") | |
bs = BeautifulSoup(req.text) | |
tags = bs.find_all(lambda tag: tag.name == 'h3' or (tag.has_attr('data-test-id') and tag['data-test-id'] == 'item-view')) | |
for t in tags: | |
try: |
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 python3 | |
# -*- coding: ISO8859-15 -*- | |
# This might need some adjustments: | |
# Save file with the correct encoding and | |
# make sure that the chars to be replaced | |
# are encoded correctly in this file. | |
import os | |
import sys |
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
// run it like this: | |
// stap -v -x <PID> system_tap_example.stp | |
global count; | |
probe begin { | |
count = 0; | |
printf("Staring system tap session for pid=%i\n", target()); | |
} |
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/python | |
import subprocess | |
import re | |
import gdb | |
# This is just an example and might not work poperly! | |
class BreakpointAtMain(gdb.Breakpoint): | |
def __init__(self): |
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
# This is just a small example. There are better tools to use when dealing with ELF files. | |
from hachoir.core.endian import LITTLE_ENDIAN | |
from hachoir.field import Parser, Bytes, UInt8, Enum, PaddingBytes, FieldSet, UInt16, UInt32 | |
from hachoir.stream import FileInputStream | |
class Ident(FieldSet): | |
endian = LITTLE_ENDIAN | |
EI_NIDENT = 16 |
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
from bs4 import BeautifulSoup | |
with open(r'MyBool Packt.htm') as in_file: | |
soup = BeautifulSoup(in_file, 'html.parser') | |
toc = soup.find_all('ol', id="accordion-toc") | |
entry = soup.find_all('a', class_='toc-index') | |
for e in entry: | |
print(e.text.strip()) |
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 fileinput | |
import os | |
import sys | |
# WARNING: This is Work-In-Progress!!! | |
def convert(inp): | |
code_snippet = False | |
for line in inp: | |
if code_snippet and line == "\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
#!/usr/bin/env python3 | |
"""Create labels with week numbers and dates""" | |
import os.path | |
from datetime import timedelta, date | |
import locale | |
locale.setlocale(locale.LC_ALL, 'DE_CH') |
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 <sstream> | |
// poor man's unit testing framework | |
#define ASSERT_EQUALS(a, b) do { \ | |
std::cerr << std::boolalpha; \ | |
std::stringstream as, bs; \ | |
as << a; bs << b; \ | |
if (as.str() != bs.str()) { \ | |
std::cerr << as.str() << "\nis not equal to\n" << bs.str() << "\nin line " << __LINE__ << std::endl; \ |
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
option(ENABLE_CPPCHECK "Enable cppcheck" OFF) | |
if(ENABLE_CPPCHECK) | |
find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck) | |
list(APPEND CMAKE_CXX_CPPCHECK | |
"--language=c++" | |
"--enable=warning,missingInclude" | |
"--inconclusive" | |
"--force" | |
"--inline-suppr") |
NewerOlder