Skip to content

Instantly share code, notes, and snippets.

@cdmo
Last active December 15, 2015 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdmo/5233538 to your computer and use it in GitHub Desktop.
Save cdmo/5233538 to your computer and use it in GitHub Desktop.
random stuff that I tend to forget, but need desperately

##Drupal

cache busting in Drupal

drupal_flush_all_caches()
drupal_clear_css_cache()
drupal_clear_js_cache()

getting the full URI of an image

$uri = $value->image['uri'];
$wrapper = file_stream_wrapper_get_instance_by_uri($uri);
$path = $wrapper->getExternalUrl();

##drush

finding that enabled module

drush pml --pipe --status=enabled | grep "name of module"

counting enabled modules

drush pml --type=module --status=enabled | wc -l

##shell

empty a file

echo > /path/to/file.ext

finding a file

ls -aR | grep -B 25 "^needle.php"

##MySQL

Quickly create a database and user for testing

mysql -u root -p
create database name;
grant all on name.* to name@localhost;
set password for name@localhost=password('name');

##PHP

Handy function for dumping variables

function log_to_file($text) {
  $f = fopen('/tmp/mylog.log', 'a');
  fwrite($f, date('Ymd H:i:s - ') . print_r($text, true) . "\n");
  fclose($f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment