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
FROM php:8.1-cli | |
USER root | |
[...] | |
# Add dev user | |
ARG user_id | |
ARG group_id | |
RUN groupadd -g ${group_id} dev | |
RUN useradd dev -u ${user_id} -g dev --shell /bin/bash --create-home |
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
.PHONY: * | |
DOCKER= | |
ifeq ("$(wildcard /.dockerenv)","") | |
DOCKER=docker exec -ti my-app | |
endif | |
build: | |
${DOCKER} composer install | |
${DOCKER} yarn |
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
<Macro Directory $dir> | |
<Directory "/home/dev/www/$dir"> | |
# Projects location | |
Require all granted | |
Options Includes Indexes FollowSymLinks | |
AllowOverride All | |
</Directory> | |
</Macro> | |
<VirtualHost 127.0.0.1> |
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' |
NewerOlder