Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

George Mihailov Mihailoff

🎯
Focusing
View GitHub Profile
@Mihailoff
Mihailoff / automated-ebs-snapshots
Last active Aug 29, 2015
init.d script for automated-ebs-snapshots tool
View automated-ebs-snapshots
#!/bin/sh
### BEGIN INIT INFO
# Provides: automated-ebs-snapshots
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: automated-ebs-snapshots
### END INIT INFO
@Mihailoff
Mihailoff / prepare-commit-msg
Created Jul 2, 2014
Auto prepend branch name to commit message if name not start with "MOODLE_"
View prepare-commit-msg
# .git/hooks/prepare-commit-msg
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if [[ ! $BRANCH_NAME =~ ^MOODLE_ ]] ; then echo "$BRANCH_NAME " | cat - "$1" > "$1.tmp" && mv "$1.tmp" "$1"; fi
@Mihailoff
Mihailoff / watchdog.php
Created Jan 23, 2014
Include trace in Drupal watchdog messages
View watchdog.php
<?php
$e = new Exception();
watchdog(
'my_module',
"Message %foo !trace",
array(
'%foo' => 'Basic message',
'!trace' => nl2br("\n" . $e->getTraceAsString()),
),
@Mihailoff
Mihailoff / drupal-cron-debug.sh
Created Sep 10, 2013
Drush command to help debug cron timeout errors
View drupal-cron-debug.sh
drush php-eval 'global $timers; $hook = 'cron'; $return = array(); foreach (module_implements($hook) as $module) { $function = $module . '_' . $hook; print($function ." - "); timer_start($function); $result = call_user_func_array($function, array()); if (isset($result) && is_array($result)) { $return = array_merge_recursive($return, $result); } else if (isset($result)) { $return[] = $result; } timer_stop($function); print($timers[$function]['time'] ."\r\n"); }'
View drush_admin_create
drush user-create adminuser --mail="gm@inlead.dk" --password="1234"; drush user-add-role "administrator" adminuser
@Mihailoff
Mihailoff / symfony2-simple-in-place-validation-example.php
Last active Dec 15, 2015
Simple in-place validation in Symfony2
View symfony2-simple-in-place-validation-example.php
<?php
$data = array(
'agency' => array(
'name' => 'a',
'moderator' => 'b'
)
);
$rules = new Symfony\Component\Validator\Constraints\Collection(array(
@Mihailoff
Mihailoff / drush_reload_modules
Created Feb 22, 2013
Quickly disable & re-enable all non-core modules in Drupal 7
View drush_reload_modules
# see http://drupal.org/node/593406
drush pml --no-core --type=module --status=enabled --pipe | xargs drush -y dis
drush pml --no-core --type=module --status=disabled --pipe | xargs drush -y en
@Mihailoff
Mihailoff / AnObj.php
Created Sep 11, 2012
PHP Anonymous Object
View AnObj.php
<?php
/**
* PHP Anonymous Object
*/
class AnObj
{
protected $methods = array();
public function __construct(array $options)
View redis-server-for-init.d-startup
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
You can’t perform that action at this time.