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
# 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 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
import pickle | |
class BaseRepository: | |
def put(self, entity): | |
raise NotImplementedError | |
def find_by_id(self, entity_id): | |
raise NotImplementedError |
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
extract values using snmp-walk | |
# filter by dates 07E4 -> 2020 year | |
snmpwalk -v2c -c community gpon.my.net 1.3.6.1.4.1.2011.6.128.1.1.2 | grep "07 E4" | |
# mibs from https://code.getnoc.com/noc/noc/-/blob/master/cmibs/huawei_xpon_mib.py | |
"HUAWEI-XPON-MIB::hwGponDeviceOltLastUpTime": "1.3.6.1.4.1.2011.6.128.1.1.2.21.1.17", | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.21.1.17.4194304000 = Hex-STRING: 07 E4 06 09 0A 2E 07 00 2B 02 00 | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.21.1.17.4194304768 = Hex-STRING: 07 E4 02 13 0A 0E 00 00 2B 01 00 | |
"HUAWEI-XPON-MIB::hwGponDeviceOltLastDownTime": "1.3.6.1.4.1.2011.6.128.1.1.2.21.1.18", | |
SNMPv2-SMI::enterprises.2011.6.128.1.1.2.21.1.18.4194304000 = Hex-STRING: 07 E4 06 09 0A 2D 38 00 2B 02 00 |
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
# Script for IDA | |
# find for MIPS global pointer and try to create a function | |
# | |
# conversion hex to opcode at https://www.eg.bucknell.edu/~csci320/mips_web/ | |
# 0x3c1c8064 | |
# LUI $gp 0x8064 | |
# | |
# 0x279c1c70 | |
# ADDIU $gp $gp 0x1C70 |
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 | |
current_tag=production_$(date +'%Y%m%d') | |
git tag $current_tag | |
previous_tag=$(git tag -l 'prod*' --sort=-committerdate | grep -v $current_tag | head -n1) | |
commit_description=$(git log $previous_tag..$current_tag --pretty=format:" * %s") | |
if ! [ -f CHANGELOG.md ]; then touch CHANGELOG.md; fi; | |
NewerOlder