Skip to content

Instantly share code, notes, and snippets.

View derhasi's full-sized avatar
💚
Life is green!

Johannes Haseitl derhasi

💚
Life is green!
  • Nuremberg, Germany
  • 05:09 (UTC +01:00)
View GitHub Profile
@derhasi
derhasi / gist:4249376
Created December 10, 2012 08:43
Ways of recognizing the node add form.
<?php
/**
* Implements hook_form_node_form_alter().
*/
function mycustom_form_node_form_alter(&$form, &$form_state, $form_id) {
// Ways of recognizing the node_add form.
// By using the hook_form_node_form_alter() we do not have to check explicitely
// in the form_id, as we already now, that we are on the node form by using the
// specific hook_form_FORM_ID_alter().
@derhasi
derhasi / foreman.js
Last active December 19, 2015 19:48
This is an example I came up with when testing https://npmjs.org/package/webworker-threads
/**
* @file
* Example for a multithreaded worker with webworker-threads.
*
* @see https://npmjs.org/package/webworker-threads
*/
var Worker = require('webworker-threads').Worker;
/**
@derhasi
derhasi / mymodule.module
Created August 29, 2013 12:44
Override defaults provided by ctools plugins
<?php
/**
* Implements hook_ctools_plugin_api_alter().
*/
function mymodule_ctools_plugin_api_alter() {
// That is not nice, but we do not have a chance to get the api specific
// module list otherwise.
// @see https://drupal.org/node/2075885
@derhasi
derhasi / mymodule.module
Created August 29, 2013 12:59
Remove custom modules and features form the project info for update.
<?php
/**
* Implements hook_update_projects_alter().
*/
function mymodule_update_projects_alter(&$projects) {
// We use this hook to remove our features and custom modules from the update
// info retrieval procedure.
foreach ($projects as $key => $project) {
list($prefix) = explode('_', $key);
@derhasi
derhasi / db.sh
Created September 18, 2013 07:42
Bash script for importing a with a given prefix: execute `bash db.sh 2` to import to `my_db_prefix2`. The "say" command is only valid for Mac OS X by default.
echo "DB;$1";
PREFIX="my_db_prefix";
DB="$PREFIX$1"
DBFILE="current.sql"
DBUSER="root"
DBPASSWORD="password"
echo "DB: $DB from $DBFILE"
@derhasi
derhasi / staging.sh
Last active December 14, 2022 08:39
Bash script for deploying the exact state of a given branch to a remote branch. This is done by using "diff commits". Usage: * 1: change STAGING_REMOTE and STAGING_REMOTE_BRANCH to your needs * 2: execute "bash staging.sh mybranchname" to commit that branch to the "staging remote branch"
#!/bin/bash
################################################################################
# This script is for adjusting the staging branch to a specific branch content.
# The resulting branch will likely not share the history with the given branch,
# but will ensure all files are present in the same state as in the original
# branch.
#
# This approach is needed to ensure we can use the a git based hosting with a
# fixed branch, to rollout and test multiple different branches. In that case
@derhasi
derhasi / update.sh
Created October 28, 2013 13:04
A simple update script skeleton to be used for updating a drupal installation with the latest configuration changes.
# Navigate to our docroot so we can execute the drupal drush commands
cd ../docroot
# Make sure files and classes are correctly registered, even if we moved them
# in another directory.
drush registry-rebuild
# Enable maintenance mode.
drush vset maintenance_mode 1
@derhasi
derhasi / gist:7888991
Last active March 10, 2022 14:58
Git filter-branch recipes

Git filter branch recipes

Remove "Issue #12345: "-Prefix from commit messages

git filter-branch --msg-filter 'sed -e "s/Issue #[0-9]*: //"'

Remove all files except those of a given name

@derhasi
derhasi / drupal_hackedgit.md
Last active December 25, 2021 16:57
Script to get a diff of a Drupal dev project from git and write the diff to the projects folder: `bash check_hacked.sh $PROJECTNAME`.

Check hacked status from git

This small script provides some code to check a project of your installation (located in .../www) against the associated git commit on drupal.org.

Notice: currently the root path and temp directory are hardcoded.

Examples

Check status of views module.

@derhasi
derhasi / SassMeister-input-HTML.html
Created February 10, 2014 17:31
Generated by SassMeister.com.
<div class="wrapper">
<div class="content">
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
</p>
</div>
<div class="bottomic">Downloads & publications</div>
</div>
<div class="wrapper">