Skip to content

Instantly share code, notes, and snippets.

View infojunkie's full-sized avatar
🎶

Karim Ratib infojunkie

🎶
View GitHub Profile
@infojunkie
infojunkie / recotype-neo4j.php
Created September 6, 2011 01:48
Load tweets from Drupal / MySQL into Neo4j graph database using Neo4jPHP.
#!/usr/bin/env php
<?php
$_SERVER['HTTP_USER_AGENT'] = 'cli';
$cwd = getcwd();
$dir = dirname(__FILE__) . '/..';
chdir($dir);
include('includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
@infojunkie
infojunkie / tree.groovy
Created September 6, 2011 02:36
Gremlin steps for tree traversal.
// Taken from: https://gist.github.com/1170000
// Gremlin user-defined defined tree() steps
// inTree() and outTree()
// closure can't have the same name as the defined step
_tree = { vertices ->
def results = []
vertices.each() {
results << it
@infojunkie
infojunkie / HelloPHPExcel.php
Last active March 23, 2018 14:04
HelloPOI - first experiment with Apache POI vs. PHPExcel
#!/usr/bin/php
<?php
require('PHPExcel/Classes/PHPExcel.php');
$workbook = PHPExcel_IOFactory::load($argv[1]);
$sheet = $workbook->getSheet(0);
foreach ($rit = $sheet->getRowIterator() as $row) {
foreach ($cit = $row->getCellIterator() as $cell) {
echo $cell->getCoordinate() . " - ";
@infojunkie
infojunkie / views_join_translation.module
Last active December 17, 2015 17:19
A Drupal Views join handler to be used with node translation relationships. This join returns translated nodes *or* the node itself if it is not translated. This is useful to guarantee that some node is returned. To understand the context: http://thereisamoduleforthat.com/content/view-nodes-and-their-translations.
<?php
/**
* Implements hook_views_data_alter().
*/
function views_join_translation_views_data_alter(&$data) {
$data['node']['translation']['relationship']['join_handler'] = 'views_join_translation';
}
/**
<?php
/**
* Implements hook_views_query_alter().
*/
function demo_i18n_views_query_alter(&$view, &$query) {
unset($query->relationships['node_node']);
unset($query->relationships['node_node_1']);
unset($query->relationships['node_node_2']);
unset($query->table_queue['node_node']);
@infojunkie
infojunkie / gist:11232218
Created April 23, 2014 21:00
keybase.md
### Keybase proof
I hereby claim:
* I am infojunkie on github.
* I am kratib (https://keybase.io/kratib) on keybase.
* I have a public key whose fingerprint is 242A D815 51B9 39D4 7013 0F1F E814 5192 B6EA 54BC
To claim this, I am signing this object:
@infojunkie
infojunkie / devel_forms.info
Last active September 15, 2021 01:41
Debug info for Drupal forms
name = Devel forms
description = Tools for developing and debugging Form API.
package = Development
core = 7.x
dependencies[] = devel
@infojunkie
infojunkie / token_theme.info
Last active August 29, 2015 14:24
Drupal theme tokens
name = Token Theme
description = Create tokens for theme settings.
core = 7.x
@infojunkie
infojunkie / midi-invert.py
Created August 18, 2016 00:03
MIDI keyboard inversion using music21
#!/usr/bin/python
import sys
from music21 import *
mf = midi.MidiFile()
mf.open(sys.argv[1])
mf.read()
s = midi.translate.midiFileToStream(mf)
for n in s.flat.notes:
for p in n.pitches:
@infojunkie
infojunkie / youtube-album.md
Last active August 24, 2021 04:26
Convert audio track/album to YouTube video

youtube-album

A recipe to prepare audio file(s) for YouTube upload. Video will be a slideshow of images on repeat.

Requires: imagemagick ffmpeg

  1. Convert images to required size. Here I assume .png files and output to png/ folder. See http://www.imagemagick.org/Usage/crop/#extent