Skip to content

Instantly share code, notes, and snippets.

View darkmavis1980's full-sized avatar
🎯
Focusing

Alessio Michelini darkmavis1980

🎯
Focusing
View GitHub Profile
@darkmavis1980
darkmavis1980 / listdir.py
Created September 20, 2018 15:13
Simple python test script to retrieve the files of the current directory
import os
files = os.listdir(os.curdir)
for file in files:
print(f'- {file}')
@darkmavis1980
darkmavis1980 / certbot
Last active September 25, 2021 11:14
Renew Certbot certificate
# renew with dry run
certbot renew --dry-run
# get challenge
certbot -d domain.com --manual --preferred-challenges dns certonly
# install certificate
certbot --nginx -d domain.com
@darkmavis1980
darkmavis1980 / regex.js
Last active January 14, 2019 15:35
List of Regular Expressions
// email validation
^([a-zA-Z0-9.+_-]+)@([a-z0-9.-]+)\.([a-zA-Z]{2,6}$)
// phone numbers
([0-9+\s]+)$
// price, eg: 30, 12.45
^([0-9]+)(\.[0-9]+)?$
@darkmavis1980
darkmavis1980 / docker_root
Created March 20, 2019 13:56
Access as root to a container
docker exec -it -u root jenkins /bin/bash
@darkmavis1980
darkmavis1980 / filter.js
Created July 19, 2019 10:47
mongo_aggregate_and_filter
/**
* This will filter down to the matches with a specific player, with the matches being played after a specific date,
* and it will show only the aggregate matches after that date ignoring the previous ones
*/
var dateFilter = new ISODate("2019-06-01T20:15:31Z");
db.getCollection('competitions').aggregate([
{
$match: {
players: ObjectId("5c71c4c1185c610046f17911"),
@darkmavis1980
darkmavis1980 / recent.js
Created July 21, 2019 00:48
Mongodb: Show most recent events by a sub document
db.getCollection('competitions').aggregate([
{
$unwind: '$matches'
},
{
$sort: { 'matches.date': -1 }
},
{
$limit: 3
}
@darkmavis1980
darkmavis1980 / delete-git-branches
Created July 27, 2019 13:40
Delete all git branches matching regex
git branch | grep "<pattern>" | xargs git branch -D
@darkmavis1980
darkmavis1980 / http.py
Created October 10, 2019 09:21
Run simple http server with python3
python -m http.server 8000
@darkmavis1980
darkmavis1980 / react-chartjs-2-mock
Created October 30, 2019 21:13
jest-react-chartjs-2
jest.mock('react-chartjs-2', () => ({
Pie: () => null,
}));
@darkmavis1980
darkmavis1980 / class.js
Created November 12, 2019 11:41
Function constructor vs class
// These are equals
class Test {
constructor(name) {
this.name = name;
}
getName() {
return this.name;
}