Skip to content

Instantly share code, notes, and snippets.

View infojunkie's full-sized avatar
💭
🎶

Karim Ratib infojunkie

💭
🎶
View GitHub Profile
@infojunkie
infojunkie / serverless.yml
Last active August 16, 2021 06:48
Upload Zoom files to AWS S3
service: labyrinth-service
provider:
name: aws
iamManagedPolicies:
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
iamRoleStatements:
- Effect: Allow
Action:
- lambda:InvokeFunction
@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
@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 / 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 / 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
<?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.php
Last active June 5, 2026 19:17
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';
}
/**
@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() . " - ";