Skip to content

Instantly share code, notes, and snippets.

View sobi3ch's full-sized avatar
🎯
Focusing

Piotr Sobieszczański sobi3ch

🎯
Focusing
View GitHub Profile
@VeggieMeat
VeggieMeat / Determine if D7 Rules action is active
Created November 19, 2013 09:44
Determine if a particular action in Drupal 7 Rules 2 is part of any active rule.
$action_name = 'r2d2';
$rules = rules_config_load_multiple(FALSE);
foreach ($rules as $rule) {
if (get_class($rule) == 'RulesReactionRule') {
foreach ($rule->actions() as $action) {
if (get_class($action) == 'RulesAction') {
if (($action->getElementName() == $action_name) && ($rule->active == 1)) {
return 'that was the droid you were looking for';
}
@ashrithr
ashrithr / rsc
Last active December 11, 2015 22:49
manage create/manage rackspace virtual machines using command line api (nova client)
#!/usr/bin/env bash
####################
#
# Wrapper script to manage virtual machines in rackspace using nova-client & rackspace api v2
# Author: Ashrith
#
####################
##NOVA AUTH VARIABLES
export OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/
@carlwiedemann
carlwiedemann / gist:4035400
Created November 7, 2012 23:40
Drush login, Drush logout
# Drush login function dli
# ------------------------
#
# Open the given site in the browser, login as root, and go to destination
# argument. Requires the -l option, or drush site-set @alias, or $options['l']
# in sites/default/bashrc.php
#
# Usage
# -----
#
@bartoszmajsak
bartoszmajsak / prepare-commit-msg.sh
Last active March 20, 2024 08:12
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@founddrama
founddrama / VersionComparator.groovy
Last active April 20, 2023 12:55
a version comparator (e.g., "1.0.2" < "1.0.10")
def versions = []
def f = new File('mock-version-tags.txt')
f.eachLine { versions << it }
def versionComparator = { a, b ->
def VALID_TOKENS = /._/
a = a.tokenize(VALID_TOKENS)
b = b.tokenize(VALID_TOKENS)
for (i in 0..<Math.max(a.size(), b.size())) {