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 lxml import etree | |
from lxml.builder import ElementMaker | |
class NewRpcMessageEncoder(object): | |
def _envelope(self, request_id, hold_requests): | |
SOAP_ENV = "http://schemas.xmlsoap.org/soap/envelope/" | |
SOAP_ENC = "http://schemas.xmlsoap.org/soap/encoding/" | |
XSD = "http://www.w3.org/2001/XMLSchema" | |
XSI = "http://www.w3.org/2001/XMLSchema-instance" |
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
/** | |
* /vendor/laravel/framework/src/Illuminate/Support/helpers.php | |
*/ | |
if (! function_exists('dd')) { | |
/** | |
* Dump the passed variables and end the script. | |
* | |
* @param mixed | |
* @return void |
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
Resetting board in 0 seconds...HELO | |
CPUI | |
L1CI | |
DRAM | |
---- | |
PHYS | |
PHYE | |
DDR1 | |
333H | |
SIZ3 |
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 | |
from pydriller import Repository | |
def extract_version(content): | |
regex = r"<artifactId>myapp<\/artifactId>.*\n^\-.*<version>(.*)<\/version>.*\n^\+.*<version>(.*)<\/version>" | |
matches = re.findall(regex, content, re.MULTILINE) | |
if matches: | |
return matches[0][0], matches[0][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
import glob | |
import shutil | |
files = glob.glob("/home/jorge/Music/**", recursive=True) | |
for current in files: | |
try: | |
new = current.encode('utf8', 'ignore') | |
shutil.move(current, new) | |
except Exception as exc: | |
print(str(exc)) |
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
# Asterisk/Util.py | |
class EventCollection(Logging.InstanceLogger): | |
''' | |
Utility class to allow grouping and automatic registration of event. | |
''' | |
def __init__(self, initial=None): | |
''' | |
If <initial> is not None, register functions from the list <initial> | |
waiting for events with the same name as the 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
#---- current behaviour | |
# class UsernameTooShortError(Exception): | |
# MSG = 'Username too short' | |
# pass | |
# def add_user(username=None): | |
# if len(username) < 4: | |
# raise UsernameTooShortError() |
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 struct | |
import datetime | |
ts = 1620386580.0 | |
dt = datetime.datetime.fromtimestamp(ts) | |
packed = struct.pack(">hbbbbbb", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond) | |
print ("packed", packed, ts ) | |
tp = dt.timetuple() # expand values in a tuple | |
import time |
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
# reduce the time whe your write a mamba spec file | |
# easy use: :UltiSnipsEdit | |
# | |
global !p | |
def sanitize_spec_fn(fn): | |
return fn.replace("spec.py", "").replace("_", " ") | |
endglobal | |
snippet mamba "mamba spec skel" | |
from mamba import description, context, it |
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 pickle | |
class BaseRepository: | |
def put(self, entity): | |
raise NotImplementedError | |
def find_by_id(self, entity_id): | |
raise NotImplementedError |
NewerOlder