Skip to content

Instantly share code, notes, and snippets.

View AndreBaumeier's full-sized avatar

Andre Baumeier AndreBaumeier

View GitHub Profile
@AndreBaumeier
AndreBaumeier / find-log4j.sh
Last active December 12, 2021 14:00
find log4j usages within your java applications. Requires installed JRE and jdeps.
#!/bin/bash
find . -type f -name '*jar' | while read line; do
LOG4JUSAGE=''
#echo "Processing file '$line'"
LOG4JUSAGE=$(jdeps "$line"|grep -i log4)
if [ ! -z "$LOG4JUSAGE" ]
then
echo "Processing file '$line'"
echo "found log4 references"
echo "$LOG4JUSAGE"
diff -ur drupal-8.4.5/core/lib/Drupal/Core/DrupalKernel.php drupal-8.4.6/core/lib/Drupal/Core/DrupalKernel.php
--- drupal-8.4.5/core/lib/Drupal/Core/DrupalKernel.php 2018-02-20 20:35:14.000000000 +0100
+++ drupal-8.4.6/core/lib/Drupal/Core/DrupalKernel.php 2018-03-27 10:03:10.000000000 +0200
@@ -20,6 +20,7 @@
use Drupal\Core\Http\TrustedHostsRequestFactory;
use Drupal\Core\Installer\InstallerRedirectTrait;
use Drupal\Core\Language\Language;
+use Drupal\Core\Security\RequestSanitizer;
use Drupal\Core\Site\Settings;
use Drupal\Core\Test\TestDatabase;
@AndreBaumeier
AndreBaumeier / ShortUrlGenerator.php
Created November 4, 2014 14:58
short url generator
<?php
class ShortUrlGenerator {
/**
* From http://rosettacode.org/wiki/Linear_congruential_generator#PHP
*/
public static function bsd_rand($seed) {
return function() use (&$seed) {
return $seed = (1103515245 * $seed + 12345) % (1 << 31);
};
}
<?php
/**
* From http://rosettacode.org/wiki/Linear_congruential_generator#PHP
*/
function bsd_rand($seed) {
return function() use (&$seed) {
return $seed = (1103515245 * $seed + 12345) % (1 << 31);
};
}
<?php
function encode_alphas($n, $alphas) {
$result = '';
for ($i=0;$i<6;$i++) {
$m = $n % count($alphas);
$n = $n / count($alphas);
$result .= $alphas[$m];
}
return $result;
}
@AndreBaumeier
AndreBaumeier / gist:9691758
Created March 21, 2014 17:51
Update an associatvie array attached to an object by one of it's keys.
<?php
define('LANGUAGE_NONE', 'und');
/**
* Update an associatvie array attached to an object by one of it's keys.
*
* @param $object object to work on
* @param string $field attribute used of object
* @param string $key key to be used of value array
* @param array $value
* @param string $lang
@AndreBaumeier
AndreBaumeier / gist:9691257
Created March 21, 2014 17:23
change the value of an associative array attached to an object by any array key
<?php
define('LANGUAGE_NONE', 'und');
function _update_array_value($object, $field, $key, $value, $lang = LANGUAGE_NONE) {
foreach ($object->{$field}[$lang] as &$sub) {
if (isset($sub[$key]) && $sub[$key] == $value[$key]) {
$sub = $value;
}
}
}
@AndreBaumeier
AndreBaumeier / gist:6163419
Last active December 20, 2015 16:39
Drupal: get all enabled dependencies for a module
<?php
function bit_get_enabled_dependencies($module) {
$dependencies=array();
// Get all module data so we can find dependencies and sort.
$module_data = system_rebuild_module_data();
// Get all dependencies for a module
if (isset($module_data[$module])) {
foreach ($module_data[$module]->required_by as $required_module => $required_module_data) {
if (!in_array($required_module, $dependencies)) {
if (module_exists($required_module)) {