Skip to content

Instantly share code, notes, and snippets.

View LarsEliasNielsen's full-sized avatar

Lars Nielsen LarsEliasNielsen

  • Autorola
  • Odense
  • 18:05 (UTC +02:00)
View GitHub Profile
<?php
$node = node_load($row->nid);
$image = field_get_items('node', $node, 'field_banner_image');
// Setting variables for js object
$site_url = $GLOBALS['base_url'].$GLOBALS['base_path'];
$image_filename = $image[0]['uri'];
// Creating array for object
@LarsEliasNielsen
LarsEliasNielsen / responsiveBanner.js
Last active December 17, 2015 19:48
Responsive images using Drupal 7 image styles.
jQuery(document).ready(function ($) {
/**
* @param string site_url
* URL to Drupal site. Set in preprocess.
* @param string image_filename
* Image name. Set in preprocess.
*/
function responsiveBanner(site_url, image_filename) {
// Trim image url
var formatted_image_filename = image_filename.replace(/public\:\/\//, '');
@LarsEliasNielsen
LarsEliasNielsen / countdown-plugin.jquery.js
Last active December 25, 2015 20:59
jQuery Countdown plugin
;(function( $ ){
$.extend($.fn, {
t2countdown: function(targetDate) {
// Initial variables
var target_date = new Date(targetDate).getTime();
var days, hours, minutes, seconds;
var countdown = this;
// DOM shortcut
@LarsEliasNielsen
LarsEliasNielsen / format-numbers.js
Created October 23, 2013 10:38
Format number with commas.
function formatNumber(unformattedNumber) {
return unformattedNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
@LarsEliasNielsen
LarsEliasNielsen / markup.tpl.php
Last active December 26, 2015 07:59
Ctools Content Type for Panels (pane). Adding stylesheets and scripts in pane. Variables can be set in pane, and extended to scripts. Markup is stored in a standard template file, with parsed variables.
<?php
/**
* @file
* Markup template.
* This is placed in: my_module/plugins/panes/resources/
*/
?>
<div>
<div class="my_output"></div>
#!/bin/bash
#
# The reason of creating this script is that Endpoint Security VPN installs it's own application firewall kext cpfw.kext
# which prevents for example PPTP connections from this computer, which is not appropriate if you need subj connection just
# from time to time
# Usage: checkpoint.sh load|unload
# You will need sudo power, of course
#
COMMAND=$1
@LarsEliasNielsen
LarsEliasNielsen / eject_timemachine.as
Created January 23, 2014 15:20
AppleScript to stop current backup, eject Timemachine disk. My Timemachine disk has another partition, so this is ejected also. Notofications is displayed when disks are ready to be disconnected.
-- Stops current backup do shell script "/Applications/'Time Machine.app'/Contents/MacOS/'Time Machine' 3" -- Set disk names set wd to "WD" set timemachine to "TIMEMACHINE" -- Eject WD tell application "Finder" if disk wd exists then eject disk wd display notification "WD disk has successfully been ejected" with title "WD ejected" else display notification "WD disk was not mounted" with title "WD not mounted" end if end tell -- Eject TIMEMACHINE tell application "Finder" if disk timemachine exists then eject disk timemachine display notification "TIMEMACHINE disk has successfully been ejected" with title "TIMEMACHINE ejected" else display notification "TIMEMACHINE disk was not mounted" with title "TIMEMACHINE not mounted" end if end tell
@LarsEliasNielsen
LarsEliasNielsen / espn_news.info
Created March 3, 2014 11:31
Drupal 7 Module Development: Basic .info file
name = ESPN News
description = Provides a block with recent ESPN sport news.
core = 7.x
package = Custom
@LarsEliasNielsen
LarsEliasNielsen / espn_news.module
Last active August 29, 2015 13:56
Drupal 7 Module Development: Module Block
<?php
/**
* Implements hook_block_info().
*
* Declares a block to provide to Drupal. This can also specify block
* configuration settings, like here where the cache is determined be the
* user role.
*
* @url: https://api.drupal.org/api/drupal/modules!block!block.api.php/function/hook_block_info/7
@LarsEliasNielsen
LarsEliasNielsen / espn_news.module
Last active August 29, 2015 13:56
Drupal 7 Module Development: Help
<?php
/**
* Implements hook_help().
*
* You can add documentation and help here (in admin/help#espn_news). This
* documentation can help the users use and extend you module.
*
* @url: https://api.drupal.org/api/drupal/modules!help!help.api.php/function/hook_help/7
*/