Skip to content

Instantly share code, notes, and snippets.

View netsensei's full-sized avatar
👾
retro-wave driven development

Matthias Vandermaesen netsensei

👾
retro-wave driven development
View GitHub Profile
@netsensei
netsensei / adlib-csv.xsl
Created August 27, 2015 20:57
Adlib XML to CSV XSLT.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:variable name="delimiter" select="';'" />
<!-- define an array containing the fields we are interested in -->
<xsl:variable name="fieldArray">
<field>Production</field>
<field>object_number</field>
@netsensei
netsensei / Moment.js with isBeforeOrSame and isAfterOrSame
Last active August 29, 2015 14:00
Extends moment.js with isBeforeOrSame or isAfterOrSame methods.
(function (root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['moment'], factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require('moment'));
@netsensei
netsensei / cafl.drush.inc
Last active August 29, 2015 14:01
Command All Field Labels. A Drush command that allows you to hide/show field instance labels in bulk from the command line.
<?php
/**
* @file
* Command All Field Labels
*
* Field labels can be pesky to maintain. Take control back over your field
* instance labels. Set field instance labels in bulk with this drush command.
*
* Show a single field instance label for a specific view mode
@netsensei
netsensei / index.js
Created June 23, 2014 20:43
requirebin sketch
var term = require('hypernal')()
var tablify = require('tablify').tablify
var request = require('browser-request')
var url = require('url')
var moment = require('moment')
term.appendTo(document.body)
// style fake terminal
var termEl = term.term.element
@netsensei
netsensei / List drupal modules as CSV with artoo.js
Created July 11, 2014 13:26
Need to draw a list of active Drupal modules on your site? Why not automate the process by just scraping from the admin/modules page? This artoo.js (http://medialab.github.io/artoo/) script does just that.
artoo.scrape('form#system-modules table tr:has(td input[type=checkbox]:checked)', {
title: {sel: 'td:nth-child(2) label'},
version: {sel: 'td:nth-child(3)'},
description: {sel: 'td:nth-child(4)'}
}, artoo.saveCsv);
@netsensei
netsensei / retroarch.cfg
Created July 14, 2014 21:03
RetroPie USB NES (Gamepad) controllers configuration. Original: http://thebestunlock.com/retroarch.cfg/ Found via http://lifehacker.com/how-to-turn-your-raspberry-pi-into-a-retro-game-console-498561192. Keeping this here as a backup!
## Skeleton config file for RetroArch
# Save all save files (*.srm) to this directory. This includes related files like .bsv, .rtc, .psrm, etc ...
# This will be overridden by explicit command line options.
# savefile_directory =
# Save all save states (*.state) to this directory.
# This will be overridden by explicit command line options.
# savestate_directory =
@netsensei
netsensei / gist:d333c87b8e44e2591be8
Last active August 29, 2015 14:05
Drupal: Automagically set breadcrumbs for Taxonomy Menu without Menu Position rules.
<?php
/**
* Implements hook_node_view().
*
* Using Taxonomy Menu and you want your breadcrumbs / active trail to follow suit?
* This snippet will handle that so that your breadcrumbs can / might look like this:
*
* home >> term A >> subterm B >> node title
*
* How to use:
@netsensei
netsensei / gist:1d8cc0f2eccc97dfcdf2
Created March 11, 2015 15:51
Spider a set of URIs,fetch data from each DOM document and return as a CSV document keyed by URI using artoo.js (medialab.github.io/artoo/quick_start/)
var urls = ['url', 'url2'];
artoo.ajaxSpider(
function(i) {
return urls[i];
},
{
process: function(data, i) {
var inv = $(data).find('.classname').text();
var url = urls[i];
return [url, inv];
@netsensei
netsensei / size_mysql_cli.sql
Created December 13, 2011 09:51
MySQL Get table sizes if you don't have PHPMyAdmin
SELECT table_schema "<tablename>", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", sum( data_free )/ 1024 / 1024 "Free Space in MB" FROM information_schema.TABLES GROUP BY table_schema ;
SELECT table_name, sum( data_length + index_length ) / 1024 / 1024 FROM tables WHERE table_schema = "<tablename>";
@netsensei
netsensei / solr_objects.php
Created January 19, 2012 11:04
Get a Solr Query and Response object in D7
$env_id = 'solr';
$query = apachesolr_current_query($env_id);
if ($query) {
$response = apachesolr_static_response_cache($query->getSearcher());
}
$query_params = $query->getParams();