Skip to content

Instantly share code, notes, and snippets.

View arnold-almeida's full-sized avatar
💀
Based

Arnold A arnold-almeida

💀
Based
View GitHub Profile
/**
* @param $file Path to source file
* @param $dest Path to save the image
* @param $type Method of resizing ('resize', 'resizemin', 'resizecrop', 'crop')
* @param $size Dimensions, array of width and height or maxScale
* @param $output Type of file to save it as ('jpg', 'png', 'gif')
* @param $quality 0 < x < 100
*/
function image ($file, $dest, $type, $size, $output = NULL, $quality = NULL, &$error = '') {
function request($data , $retry = 1)
{
//Configure::write('debug' , 2);
$start_time_unix = time();
$max_time_unix = time() + $this->request_timeout;
$success = false;
// Are there any servers left to try ???
if(false != $this->select_server())
@arnold-almeida
arnold-almeida / Files changed since last tag
Created October 14, 2009 04:43
GIT: Files changed since last tag
#!/bin/bash
unset GIT_DIR
cd /path/to/project
# Get our info....
LATEST_TAG=$(git describe --tags --abbrev=0)
CURRENT_REVISION=$(git describe)
NUMBER_FILES_CHANGED=$(git diff --name-only HEAD $LATEST_TAG | wc -l)
#FILES_CHANGED=$(git diff --name-only HEAD $LATEST_TAG)
@arnold-almeida
arnold-almeida / symlinks->hardlinks
Created October 10, 2010 12:08
Convert symlinks to hard links in a dir
@arnold-almeida
arnold-almeida / dir_mon
Created November 14, 2010 02:31
Monitor files in a directory, do stuff when contents change.
#!/bin/sh
# Via http://www.unix.com/shell-programming-scripting/100979-folder-watch.html
DIR=foo
STATIC=contents
ls -al $DIR > contents.tmp
diff -q contents.tmp $STATIC
if [ ! $? -eq 0 ]
@arnold-almeida
arnold-almeida / Check large objects in GIT repo
Created November 24, 2010 04:38
GIT : Check large objects in repo
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
@arnold-almeida
arnold-almeida / FeatureContext.php
Last active December 17, 2015 22:29
Boilerplate for Behat with Mink on Php 5.4+ with contexts and subcontexts
<?php
/**
* Reading :
*
* - http://www.craftitonline.com/2011/08/behat-symfony-2-secret-how-to-subcontext-minkcontext/
* - http://www.craftitonline.com/2011/07/behat-mink-new-use-of-aliased-subcontexts-complex-step-chaining/
* - http://davidwinter.me/articles/2012/01/14/testing-javascript-websites-with-behat/
* - http://davidwinter.me/articles/2012/01/13/using-behat-with-mink/
*/
use Behat\Behat\Context\ClosuredContextInterface,
@arnold-almeida
arnold-almeida / SimpleWorkflow.md
Last active December 19, 2015 23:28
Sync only new/changed files from a current dir over ssh to a remote folder.
  • New deployment

rsync -azv --stats --progress . -e ssh user@host:/path/to/vhost/ --exclude=".git" --exclude-from=".gitignore"

  • Notice bad code, locally revert changes, or fix and commit.

git reset --hard HEAD@SHA1

  • Sync working copy again
@arnold-almeida
arnold-almeida / MigrateShell.php
Created July 31, 2013 06:14
Shortcut shell to the CakeDC Migrations plugin
<?php
/**
* Shortcut shell to the CakeDC Migrations plugin
* Plugin :
* git submodule add https://github.com/CakeDC/migrations.git app/Plugin/Migrations
* Install this file:
* app/Console/Command
* Usage:
* cake migrate [subcommand] [-h] [-v] [-q]
*
@arnold-almeida
arnold-almeida / FixtureShell.php
Created July 31, 2013 06:25
Shortcut shell for quick fixtures
<?php
/**
* Shortcut shell for easy fixtures
*
* Plugin/s :
* git submodule add [email protected]:FloatingPoints/Resources.git app/Plugin/Resources
* Install this file:
* app/Console/Command
* Usage:
* cake fixture [subcommand] [-h] [-v] [-q]