Skip to content

Instantly share code, notes, and snippets.

@mikemadisonweb
mikemadisonweb / OneInstance.php
Last active December 2, 2016 10:32 — forked from m8rge/CronException.php
Yii2 console controller behavior. Prevents double run console command
<?php
namespace console\controllers\behaviors;
use Yii;
use yii\base\ActionEvent;
use yii\base\Behavior;
use yii\base\Exception;
use yii\console\Controller;
@mikemadisonweb
mikemadisonweb / TruncateString.php
Created November 3, 2016 06:51 — forked from m8rge/TruncateString.php
Truncate string on word break
<?php
/**
* @param string $string Subject
* @param int $length Max string length
* @param bool $exactLength Truncate string with exact $length
* @param string $append Ellipsis string
* @return string
*/
class TruncateString
@mikemadisonweb
mikemadisonweb / ConsoleProgress.php
Created November 3, 2016 06:50 — forked from m8rge/ConsoleProgress.php
Simple yii2 console progress helper
<?php
use yii\base\Object;
use yii\helpers\Console;
/**
* Usage:
* $consoleProgress = new ConsoleProgress(['max' => 365]);
* $consoleProgress->start();
* foreach($days in $day) {
@mikemadisonweb
mikemadisonweb / ansible_conditionals_examples.yaml
Created October 19, 2016 15:19 — forked from marcusphi/ansible_conditionals_examples.yaml
Ansible 1.3 Conditional Execution -- Very complete example with comments -- I find the conditional expressions to be ridiculously hard to get right in Ansible. I don't have a good model of what's going on under the surface so I often get it wrong. What makes it even harder is that there has been at least three different variants over the course …
---
# This has been tested with ansible 1.3 with these commands:
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts"
# NB: The type of the variable is crucial!
- name: Ansible Conditionals Examples
hosts: $hosts
vars_files:
@mikemadisonweb
mikemadisonweb / supervisord-example.conf
Created October 18, 2016 11:46 — forked from didip/supervisord-example.conf
Example configuration file for supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon

Configure

xdebug.ini

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
@mikemadisonweb
mikemadisonweb / gulpfile.js
Created August 28, 2016 13:49 — forked from glebcha/gulpfile.js
Gulp task sample (css and js minify+concat, compress images, watching for changes)
// Определяем зависимости в переменных
var gulp = require('gulp'),
cache = require('gulp-cache'),
clean = require('gulp-clean'),
stream = require('event-stream'),
size = require('gulp-size'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
minifyCSS = require('gulp-minify-css'),
@mikemadisonweb
mikemadisonweb / Queue.class.php
Created August 24, 2016 13:24 — forked from zachflower/Queue.class.php
PHP implementation of a queue.
<?php
// http://www.cplusplus.com/reference/queue/queue/
class Queue {
private $_queue = array();
public function size() {
return count($this->_queue);
}
@mikemadisonweb
mikemadisonweb / Stack.class.php
Created August 24, 2016 13:24 — forked from zachflower/Stack.class.php
PHP implementation of a stack.
<?php
// http://www.cplusplus.com/reference/stack/stack/
class Stack {
private $_stack = array();
public function size() {
return count($this->_stack);
}