This file contains hidden or 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
#![allow(unused)] | |
use std::{collections::HashMap, sync::{Arc, Mutex}}; | |
use rand::Rng; | |
#[derive(Debug)] | |
struct UserData { | |
name: String, | |
age: u32, |
This file contains hidden or 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
stage('tests') { | |
steps { | |
sh "XDEBUG_MODE=coverage APP_ENV=test php vendor/bin/phpunit --log-junit 'reports/junit.xml' --coverage-html 'reports/coverage' --coverage-clover 'reports/coverage/coverage.xml'|| true" | |
} | |
post { | |
always { | |
junit 'reports/junit.xml' | |
step([ | |
$class: 'CloverPublisher', | |
cloverReportDir: 'reports/coverage', |
This file contains hidden or 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
export function validateUrl(url: string, throws: boolean = false): boolean { | |
try { | |
new URL(url) | |
} catch (err) { | |
if (throws) { | |
throw new Error(`invalid url '${url}': ${err}`) | |
} | |
return false | |
} |
This file contains hidden or 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
<?php | |
function unserializeToClass($object, $class = 'stdClass') | |
{ | |
return unserialize(preg_replace('/^O:\d+:"[^"]++"/', 'O:' . strlen($class) . ':"' . $class . '"', $object)); | |
} |
This file contains hidden or 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
# coding: utf-8 | |
from PyQt5.QtNetwork import QNetworkInterface, QHostAddress | |
def get_ips(): | |
"""Get all ip addresses from computer | |
:rtype: list | |
""" | |
ip_list = [] | |
for interface in QNetworkInterface().allInterfaces(): |
This file contains hidden or 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 sizeof_fmt(num, suffix='o'): | |
"""Readable file size | |
:param num: Bytes value | |
:type num: int | |
:param suffix: Unit suffix (optionnal) default = o | |
:type suffix: str | |
:rtype: str | |
""" | |
for unit in ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z']: |
This file contains hidden or 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://stackoverflow.com/questions/43580/how-to-find-the-mime-type-of-a-file-in-python | |
import magic | |
mime = magic.Magic(mime=True) | |
mime.from_file("testdata/test.pdf") # 'application/pdf' |
This file contains hidden or 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 create_ssl_certificate(distinguished_name, key_file, cert_file, overwrite=False, X509=None): | |
from OpenSSL import crypto | |
if not os.path.exists(cert_file) or not os.path.exists(key_file) or overwrite: | |
k = crypto.PKey() | |
k.generate_key(crypto.TYPE_RSA, 1024) | |
if X509 is None: | |
X509 = crypto.X509() |
This file contains hidden or 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
# coding: utf-8 | |
import os | |
import winreg | |
import sys | |
def read_extension_regkey(extension): | |
path = r"Software\Classes\{}\OpenWithProgIDs".format(extension) | |
print("read_extension_regkey path={}".format(path)) | |
try: |