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 / 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();
@netsensei
netsensei / seasoning.php
Created September 20, 2012 11:52
Deduces the season based on a given date
<?php
function get_season($hemisphere = 'northern', $date = '') {
$now = (!empty($date)) ? strtotime($date) : strtotime(date('Y/m/d'));
$season_dates = array(
'northern' => array(
'/03/21' => 'spring',
'/06/21' => 'summer',
'/09/21' => 'autumn',
'/12/21' => 'winter',
@netsensei
netsensei / drupal-ajax.php
Created November 7, 2012 11:14
Minimal Drupal Bootstrap for AJAX requests
<?php
/**
* @file
*
* Minimal AJAX page. Call like this:
* $.ajax({
* type: 'GET',
* url: '/drupal-ajax.php?param1=...
* data: {},
@netsensei
netsensei / uninstall_table.patch
Created July 6, 2013 15:23
Uninstalls wp_mollom and upgrades the schema definition.
From 707f11370d155a20d83ce90dd89568b1b2e195b1 Mon Sep 17 00:00:00 2001
From: Matthias Vandermaesen <matthias@colada.be>
Date: Sat, 6 Jul 2013 16:47:14 +0200
Subject: [PATCH] Added: uninstall tables defined in MollomSchema::getSchema()
---
includes/Schema.php | 25 ++++++++++++++++++++++---
uninstall.php | 4 +++-
2 files changed, 25 insertions(+), 4 deletions(-)
@netsensei
netsensei / Gruntfile.js
Created December 15, 2013 14:34
Grunt + Jekyll + Compass. Acts as a double pipeline: one line acts on HTML file changes, rebuilding the entire project, the second pipeline just acts on SCSS changes: watch, compile & copy to the jekyll compiled css folder. Includes livereload support via nodejs! Based on https://github.com/thanpolas/thanpolas.github.com/blob/master/Gruntfile.js
module.exports = function (grunt) {
"use strict";
// Config...
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
css : {
src: 'css/**',
@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 / Ionic gulp
Last active January 29, 2017 07:48
Extends Ionics' default Gulp.js with a scripts & bower-files task. Moves app/ source outside the www folder.
var gulp = require('gulp');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var gulpBowerFiles = require('gulp-bower-files');
var paths = {
sass: ['./scss/**/*.scss'],
scripts: ['./app/**/*.js', './app/*.js']
@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