Skip to content

Instantly share code, notes, and snippets.

@stefanotorresi
stefanotorresi / wp-custom-archives.php
Last active August 29, 2015 13:57
wordpress custom archive hooks
<?php
/**
* archive list join clause
*/
function myArchiveJoin($join)
{
global $wpdb;
$join .= "
@stefanotorresi
stefanotorresi / FormDirectiveAutofillDecorator.js
Last active August 24, 2016 20:50
angular form directive decorator to fix Safari autofill bug
use 'strict';
/**
* workaround for: https://github.com/angular/angular.js/issues/1460
* source: http://victorblog.com/2014/01/12/fixing-autocomplete-autofill-on-angularjs-form-submit/
* decoration tips: http://angular-tips.com/blog/2013/09/experiment-decorating-directives/
* credits: https://github.com/evictor
*
* note: this directive only fixes the behaviour on form submit event,
* it doesn't fix the bidirectional data binding
<?php
namespace Application;
use Zend\Mvc\MvcEvent;
use Zend\Validator\AbstractValidator;
class Module
{
public function onBootstrap(MvcEvent $event)
@stefanotorresi
stefanotorresi / ansible-playbook-helper.sh
Created September 11, 2014 16:27
Script to run an Ansible playbook inside an Ubuntu virtual machine against a local inventory.
#!/usr/bin/env bash
ANSIBLE_PLAYBOOK=$1
ANSIBLE_HOSTS=$2
INVENTORY_FILE="/tmp/ansible_hosts"
function check_arguments() {
if [ -z ${ANSIBLE_PLAYBOOK} ]; then
echo "Usage: ansible-playbook-helper playbook-file [inventory-file|hostname]"
exit 1

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:

@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
@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 / 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 / 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 / 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