Skip to content

Instantly share code, notes, and snippets.

View Mihailoff's full-sized avatar
🎯
Focusing

George Mihailov Mihailoff

🎯
Focusing
View GitHub Profile
@Mihailoff
Mihailoff / redis-server-for-init.d-startup
Created March 13, 2012 17:14 — forked from lsbardel/redis-server-for-init.d-startup
Init.d Redis script for Ubuntu
#! /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
@Mihailoff
Mihailoff / AnObj.php
Created September 11, 2012 18:17
PHP Anonymous Object
<?php
/**
* PHP Anonymous Object
*/
class AnObj
{
protected $methods = array();
public function __construct(array $options)
@Mihailoff
Mihailoff / drush_reload_modules
Created February 22, 2013 12:23
Quickly disable & re-enable all non-core modules in Drupal 7
# 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 / symfony2-simple-in-place-validation-example.php
Last active December 15, 2015 04:59
Simple in-place validation in Symfony2
<?php
$data = array(
'agency' => array(
'name' => 'a',
'moderator' => 'b'
)
);
$rules = new Symfony\Component\Validator\Constraints\Collection(array(
drush user-create adminuser --mail="[email protected]" --password="1234"; drush user-add-role "administrator" adminuser
@Mihailoff
Mihailoff / drupal-cron-debug.sh
Created September 10, 2013 13:02
Drush command to help debug cron timeout errors
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"); }'
@Mihailoff
Mihailoff / watchdog.php
Created January 23, 2014 13:24
Include trace in Drupal watchdog messages
<?php
$e = new Exception();
watchdog(
'my_module',
"Message %foo !trace",
array(
'%foo' => 'Basic message',
'!trace' => nl2br("\n" . $e->getTraceAsString()),
),
@Mihailoff
Mihailoff / prepare-commit-msg
Created July 2, 2014 18:13
Auto prepend branch name to commit message if name not start with "MOODLE_"
# .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 / automated-ebs-snapshots
Last active August 29, 2015 14:18
init.d script for automated-ebs-snapshots tool
#!/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 / bitbucket-pipelines.yml
Created May 26, 2021 02:11
Bitbucket pipelines - docker login with AWS credentials
image: node:14
pipelines:
branches:
default:
- step:
name: build
script:
- apt-get update
- apt-get install -y python3-pip