Skip to content

Instantly share code, notes, and snippets.

@leafnode
leafnode / tar-find.sh
Created August 24, 2018 09:03
Archive files chosen using find #tips #shell
find ./someDir -name "*.php" -o -name "*.html" | tar -cf my_archive -T -
@leafnode
leafnode / remove_old_files.sh
Last active August 24, 2018 09:02
Remove files older than x days #shell #tips
find {{ file_retention.path }} -mindepth 1 -maxdepth 1 -type d -mtime +$file_retention_days -print0 | xargs -0 rm -rf
@leafnode
leafnode / remove_old_ansible_backups.sh
Last active August 24, 2018 09:02
Remove old ansible backups #shell #tips
# Keep 2 newest files
find /some/directory -maxdepth 1 -name "orig_filename.*@*~" -type f -print0 | xargs -0r ls -1t | tail -n+3 | xargs -rd '\n' rm
@leafnode
leafnode / generate.sh
Created May 18, 2018 08:09
Generate Certificate Signing Request for properly signed SSL certificate #ssl
openssl genrsa -out $DOMAIN.key 2048
openssl req -new -sha256 -key $DOMAIN.key -out $DOMAIN.csr
@leafnode
leafnode / pre-commit-debug.sh
Created May 17, 2018 10:30
pre-commit hook to check for debug calls
#!/bin/sh
echo "Checking for debug calls..."
if git-rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@leafnode
leafnode / InMemoryProducts.php
Created May 15, 2018 22:58
Products getByAlternate
<?php
final class Products implements BaseProducts
{
public function getByAlternates(array $alternates): array
{
$alternates = \array_map(function (Product\Alternate $alternate) {
return $alternate;
}, $alternates);
@leafnode
leafnode / pre-commit
Created May 15, 2018 12:24 — forked from ilyakatz/pre-commit
helpful precommit hooks
#!/bin/bash -l
# A git hook script to find and fix trailing whitespace
# in your commits. Bypass it with the --no-verify option
# to git-commit
#
.git/hooks/pre-commit-master-no-no
if [[ $? == 1 ]]
then
@leafnode
leafnode / multihooks.py
Created May 15, 2018 12:15 — forked from carlos-jenkins/multihooks.py
Delegating script for multiple git hooks
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2015-2017 Carlos Jenkins <carlos@jenkins.co.cr>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@leafnode
leafnode / devkitARMUpdate.pl
Created May 13, 2018 20:13 — forked from xvw/devkitARMUpdate.pl
Install or Update the DevKitARM with `perl devkitARMUpdate.pl`
#!/usr/bin/perl
#-----------------------------------------------------------------------------
#
# Copyright (C) 2011
# Michael Theall (mtheall)
# Dave Murphy (WinterMute)
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any
# damages arising from the use of this software.
@leafnode
leafnode / openssl.sh
Last active March 19, 2018 22:33
Generate self-signed SSL certificate for web server #openssl #ssl
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt