Skip to content

Instantly share code, notes, and snippets.

Avatar

Karim Ratib infojunkie

View GitHub Profile
@infojunkie
infojunkie / .block
Last active Dec 18, 2016
VexFlow test #1
View .block
license: gpl-3.0
height: 300
@infojunkie
infojunkie / youtube-album.md
Last active Dec 20, 2019
Convert audio track/album to YouTube video
View youtube-album.md

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

for f in *.png; do convert "$f" -resize 800x600 -gravity center -background black -extent 800x600 png/"$f".png; done

@infojunkie
infojunkie / midi-invert.py
Created Aug 18, 2016
MIDI keyboard inversion using music21
View midi-invert.py
#!/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 / token_theme.info
Last active Aug 29, 2015
Drupal theme tokens
View token_theme.info
name = Token Theme
description = Create tokens for theme settings.
core = 7.x
@infojunkie
infojunkie / devel_forms.info
Last active Aug 29, 2015
Debug info for Drupal forms
View devel_forms.info
name = Devel forms
description = Tools for developing and debugging Form API.
package = Development
core = 7.x
dependencies[] = devel
View gist:11232218
### 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:
View demo_i18n.module
<?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 / views_join_translation.module
Last active Dec 17, 2015
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.
View views_join_translation.module
<?php
/**
* Implements hook_views_data_alter().
*/
function views_join_translation_views_data_alter(&$data) {
$data['node']['translation']['relationship']['join_handler'] = 'views_join_translation';
}
/**
@infojunkie
infojunkie / HelloPHPExcel.php
Last active Mar 23, 2018
HelloPOI - first experiment with Apache POI vs. PHPExcel
View HelloPHPExcel.php
#!/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 / tree.groovy
Created Sep 6, 2011
Gremlin steps for tree traversal.
View tree.groovy
// 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
You can’t perform that action at this time.