Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
composer install --no-dev
for DEP in $(composer show -N); do
echo
echo "*** downgrading ${DEP} ***"
echo
composer update $DEP --prefer-lowest --prefer-stable
composer test
TEST_FAILED=$?
if [[ $TEST_FAILED -gt 0 ]]; then
@stefanotorresi
stefanotorresi / .gitignore
Last active November 5, 2021 07:43
Playing with Python asyncio and websockets
env
@stefanotorresi
stefanotorresi / disk-space-check.sh
Last active May 25, 2016 13:36
check disk space left and send email warning
#!/bin/bash
ADMIN="[email protected]"
# set alert-level %
ALERT=85
MAILER=/usr/bin/mail
df -Ph | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $6 }' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
@stefanotorresi
stefanotorresi / ansible-playbook.yml
Created April 7, 2016 11:46
Wordpress theme deployment and development with Ansible, Composer and wp-cli
---
- hosts: wordpress-server
vars:
root_directory: /var/www/html
theme_name: your-theme-name
theme_repo: https://yourtheme.git.url.git
locale: it_IT
url: http://absolute-url.tld
title: Worpdress
admin_user: admin
@stefanotorresi
stefanotorresi / letsencrypt-renew.sh
Last active March 4, 2016 20:38
Let's Encrypt renewal cron job
#!/usr/bin/env bash
if ! /opt/letsencrypt/letsencrypt-auto renew > /var/log/letsencrypt/renew.log 2>&1 ; then
echo "Automated renewal failed:"
cat /var/log/letsencrypt/renew.log
exit 1
fi
if [[ "$(tail -1 /var/log/letsencrypt/renew.log)" != 'No renewals were attempted.' ]]; then
service apache2 restart 1> /dev/null
@stefanotorresi
stefanotorresi / karma.conf.js
Last active February 25, 2016 23:19
An example of an Angular $http interceptor to store and reuse headers between requests
// Karma configuration
// Generated on Thu Feb 25 2016 23:29:01 GMT+0100 (CET)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
@stefanotorresi
stefanotorresi / AbstractFunctionalTestCase.php
Last active August 29, 2015 14:23
Functional test on a ZF2 application
<?php
use Zend\Test\PHPUnit\Controller\AbstractControllerTestCase as TestCase;
abstract class AbstractFunctionalTestCase extends TestCase
{
public function setUp()
{
// assumes cwd is project root
$config = include 'config/application.config.php';
@stefanotorresi
stefanotorresi / gh-token-retriever.py
Last active August 29, 2015 14:15
Github token retriever script in python
#!/usr/bin/env python
import requests
import getpass
import json
class GithubTokenRetriever:
url = 'https://api.github.com/authorizations'
def __init__(self, username = '', password = '', note = '', otp = ''):
self.user = {
@stefanotorresi
stefanotorresi / apigility-repos
Last active August 29, 2015 14:15
list of apigility related repos to add to Zend\Bot
zfcampus/apigility.org
zfcampus/zf-api-problem
zfcampus/zf-apigility
zfcampus/zf-apigility-admin
zfcampus/zf-apigility-admin-ui
zfcampus/zf-apigility-doctrine
zfcampus/zf-apigility-documentation
zfcampus/zf-apigility-documentation-swagger
zfcampus/zf-apigility-skeleton
zfcampus/zf-content-negotiation

Keybase proof

I hereby claim:

  • I am stefanotorresi on github.
  • I am stefanotorresi (https://keybase.io/stefanotorresi) on keybase.
  • I have a public key whose fingerprint is 0ACF AFD4 CE27 D291 D89F FAF9 BB59 EBFB 607D 4E05

To claim this, I am signing this object: