Skip to content

Instantly share code, notes, and snippets.

View klan's full-sized avatar

Klaus Nielsen klan

  • Odense
View GitHub Profile
@klan
klan / waste-of-time.js
Created January 28, 2015 09:06
Toggle fullscreen on button click event for IE11. fsMsElm.msRequestFullscreen is always undefined, every fucking time.
var fsButton = document.getElementsByClassName("fullscreen");
for(var i = 0; i < fsButton.length; i++) {
fsButton[i].addEventListener("click", function() {
var fullscreenButton = document.getElementsByClassName("fullscreen");
if (!document.msFullscreenElement) {
var fsMsElm = document.getElementsByClassName('play-widget-player')[0];
alert(fsMsElm.msRequestFullscreen);
if (fsMsElm.msRequestFullscreen) {
fsMsElm.msRequestFullscreen(); // ie
-- Vejret update category_id in series
UPDATE `series` SET 'category_id' = 33 WHERE 'id' = 715;
-- Vejret update category_id in program
UPDATE `program` SET 'category_id' = 32 WHERE 'series_id' = 715;
@klan
klan / hyperion.config.json
Last active August 29, 2015 14:08
hyperion.config.json for Lightberry (ws2801) curl -L --output /opt/hyperion/config/hyperion.config.json --get https://gist.githubusercontent.com/klan/cde160972e681c1a36ad/raw/16484aceffce6c253776cb458805b53a176c69e1/hyperion.config.json
// Automatically generated configuration file for 'Hyperion daemon'
// Generated by: HyperCon (The Hyperion deamon configuration file builder
{
/// Device configuration contains the following fields:
/// * 'name' : The user friendly name of the device (only used for display purposes)
/// * 'type' : The type of the device or leds (known types for now are 'ws2801', 'ldp8806',
/// 'lpd6803', 'sedu', 'adalight', 'lightpack', 'test' and 'none')
/// * 'output' : The output specification depends on selected device. This can for example be the
/// device specifier, device serial number, or the output file name
Update and install requirements:
› sudo apt-get update
› sudo apt-get dist-upgrade
› sudo apt-get install matchbox chromium x11-xserver-utils ttf-mscorefonts-installer xwit sqlite3 libnss3
Curl to desktop, cat file and copy-paste into existing files:
› curl -L --output /home/pi/Desktop/config.txt --get https://gist.githubusercontent.com/klan/7482956/raw/ebe5b60527aad2bec93e23035cbc07ee5b6a3d9b/config.txt
› curl -L --output /home/pi/Desktop/rc.local --get https://gist.githubusercontent.com/klan/7482956/raw/33786a1c5c9448bf30cd037950169679a718fb79/rc.local
Curl new file to location:
@klan
klan / Setting up subdomain with Drupal installation on Linode
Created October 30, 2013 11:39
How to set up a subdomain on a Linode server with a Drupal installation and a repository
• SSH to your server to start creating a subdomain (https://library.linode.com/hosting-website#sph_configuring-name-based-virtual-hosts)
• Go to ~/public/
› mkdir -p sub.example.com/{public,log,backup}
› cd sub.example.com/public/
› nano index.html | nano index.php
• Write 'Hello world' or whatever, we just need a html|php file to test with
@klan
klan / Google Power Search Class
Created October 22, 2013 11:46
Google Power Search Class
• define […]
- Defines a word, in english, also on the danish site
• #[…]
- Searches the web for hashtags
• +[…]
- Searches Google+
• $[…]
- Given a number, searches for a price
• @[…]
- Given a name, seaches for people (on mostly social networks)
@klan
klan / Installing Drupal with drush
Created October 22, 2013 09:20
Step-by-step Drupal install with drush. Includes installation of: Omega theme (and sub-theme), Adminimal theme, Adminimal admin menu, Module Filter, Views, Context, ctools, Devel, Diff, Features, Entity API, Entity Reference, jQuery Update, Pathauto and Token.
› drush dl drupal --drupal-project-rename="projectname"
• Install site
› cd projectname/sites/all/modules/
› mkdir contrib custom
› drush dl adminimal_theme adminimal_admin_menu module_filter
› drush en -y adminimal_admin_menu module_filter
› drush variable-set admin_theme adminimal
@klan
klan / custom_jquery_update.php
Created July 26, 2013 07:39
Custom D7 module for running jQuery 1.5 backend, and newest version frontend.
<?php
/**
* Implements hook_module_implements_alter().
*/
function custom_jquery_update_module_implements_alter(&$implementations, $hook) {
if ($hook == 'library_alter') {
if(isset($implementations['jquery_update'])) {
// Move jquery update to the end. This will make sure our hook_library_alter
// is always called before the jquery_update.
$jquery_update = $implementations['jquery_update'];
@klan
klan / drupal-bootstrap.php
Created July 21, 2013 16:33
Drupal bootstrap
<?php
// Get path of drupal install and strip path to module
$drupal_path = preg_replace('@\/sites\/[a-zA-Z_/]+@i', '', getcwd());
// Create a constant DRUPAL_ROOT that defines our path to the drupal install
define('DRUPAL_ROOT', $drupal_path);
// require bootstrap
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
@klan
klan / basic-regex
Created June 23, 2013 11:18
Basic regex
Metachar. Name Matches
. dot Any one character
[...] class Any character listed
[^...] negated class Any character NOT listed
-------------------------------------------------------------
^ caret Start of line
$ dollar End of line
\< backslash less-than Start of word
\> backslash greater-than End of word