Skip to content

Instantly share code, notes, and snippets.

@ThomasHambach
ThomasHambach / ssoPublicSessions.php
Created March 14, 2013 04:41
Example implementation of authenticating users to Invision Powerboard using ssoPublicSessions. Will create a new user if this user is not found. This file is located in admin/sources/classes/session and should be overwritten by you.
<?php
/**
* Class ssoPublicSessions
*/
class ssoPublicSessions extends publicSessions
{
protected $ci_user = null;
public function __construct()
@ThomasHambach
ThomasHambach / app.js
Created March 15, 2013 10:45
Node.JS and MongoDB implementation of interview question at http://stackoverflow.com/questions/15400700/recent-interview-q-manipulate-objects-on-page-for-multiple-users Node.JS running on 8080 and Apache on 80 to serve the HTML file (which could also be done by node).
var express = require('express')
, http = require('http')
, mongojs = require('mongojs')
, db = mongojs('traffic')
, users = db.collection('users');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 8080);
app.use(express.logger('dev'));
@ThomasHambach
ThomasHambach / gist:5193734
Created March 19, 2013 04:33
Get first classname using jQuery.
<a id="myelement" href="http://google.com" class="class1 class2 class3">Go to google</a>
<script>
$('a#myelement').attr('class').split(' ')[0];
</script>
@ThomasHambach
ThomasHambach / bundle.php
Created May 4, 2013 22:10
Laravel 3 Adwords PHP Api bundle 1. Create a new directory called "adwords" in your /bundles directory 2. Add in the files below 3. Download the Adwords PHP Api library from https://code.google.com/p/google-api-adwords-php/ 4. Create a new directory in /bundles/adwords called "libraries", in this libraries folder, create another folder called "a…
<?php
return array('adwords');
@ThomasHambach
ThomasHambach / my_module.module
Created September 7, 2013 06:50
Drupal 7, define header/footer/... for your view programatically.
<?php
/**
* Implements hook_views_data().
*/
function MYMODULE_views_data() {
$data = array();
$data[' MYMODULE__global']['table']['group'] = t('My Module');
$data[' MYMODULE__global']['table']['join'] = array(
@ThomasHambach
ThomasHambach / image_field_caption_devel_generate.patch
Last active December 23, 2015 07:59
When trying to create images with the devel generate module and having the module Image Field Caption enabled, you will get an error. This patch should resolve the issue.
Index: image_field_caption.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- image_field_caption.module (date 1379394208000)
+++ image_field_caption.module (revision )
@@ -213,6 +213,10 @@
$items = (array) $entity->{$field_name}[$langcode];
$delta_count = 0;
@ThomasHambach
ThomasHambach / gist:7114893
Created October 23, 2013 08:44
Delete ghost or dead fields in your Drupal 7 website. Sometimes you will end up with dead fields in your database after altering a feature that contained content types. This gist will get all the linked fields from your entities, all the fields defined in the database, find out the difference between them, and remove them.
// Get all fields linked to entities.
$active = [];
$entities = field_info_instances('node');
foreach ($entities as $entity) {
foreach ($entity as $field_name => $field_info) {
$active[] = $field_name;
}
}
$active = array_unique($active);
@ThomasHambach
ThomasHambach / my_search_module.php
Last active January 4, 2016 00:09
Drupal 7, search in current language.
<?php
/**
* Implements of hook_query_node_access_alter().
*/
function my_search_module_query_node_access_alter(QueryAlterableInterface $query) {
$db_and = db_and();
$language = i18n_language_interface();
$db_and->condition($node . '.language', $language->language, '=');
$query->condition($db_and);
@ThomasHambach
ThomasHambach / marker.js
Created January 26, 2014 08:08
Drupal 7 GMAP multi language bubble fix
// Search for this line (on line 92 for me)
if (obj.vars.rmtcallback) {
uri = Drupal.settings.basePath + obj.vars.rmtcallback + '/' + marker.rmt;
}
// And change it to
if (obj.vars.rmtcallback) {
uri = Drupal.settings.basePath + Drupal.settings.pathPrefix + obj.vars.rmtcallback + '/' + marker.rmt;
}
@ThomasHambach
ThomasHambach / gist:8644106
Created January 27, 2014 06:43
Setting up Jetty 9 on Ubuntu 12.04
# Start by following this tutorial
# http://pietervogelaar.nl/ubuntu-12-04-install-jetty-9/
# Try checking your Jetty, getting the error JETTY_HOME not found?
root@ubuntu:/opt# service jetty check
** ERROR: JETTY_HOME not set, you need to set it or install in a standard location
# Solution
nano /etc/default/jetty
# Add following line