Skip to content

Instantly share code, notes, and snippets.

View smichaelsen's full-sized avatar
🥋
Changing the world in code

Sebastian Michaelsen smichaelsen

🥋
Changing the world in code
View GitHub Profile
<?php
namespace MyVendor\EventCenter\ViewHelpers\Form;
class TextfieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\TextfieldViewHelper {
/**
* Get errors for the property and form name of this view helper
*

Multiple sys_category fields in one table

When your table has more than 1 field with relations to sys_category you will run into problems because the MM relation table sys_category_record_mm will only store which table a category belongs to - but not the specific field.

You need to extend sys_category_record_mm like this:

Add the following to your extension's ext_tables.sql:

CREATE TABLE sys_category_record_mm (
@smichaelsen
smichaelsen / TypolinkViewHelper.php
Last active December 16, 2015 13:48
Link ViewHelper that accepts a stdWrap.typolink.parameter string
<?php
class Tx_Myext_ViewHelpers_Link_TypolinkViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
/**
* @param string $parameter stdWrap.typolink style parameter string
* @return string
*/
public function render($parameter) {

This script is intented to be used as git post-commit hook. It uses sightsnap (https://github.com/monkeydom/sightsnap) and is based on an example script (https://github.com/monkeydom/sightsnap/blob/develop/examples/lolsnapcommit-hook.rb).

  • When committing it shoots a photo of you and provides some commit meta data as text on that image.
  • It prepares an URL (see lines 8 and 57) which it expects that image to be found on and attaches it as git note to the commit. I do that in Markdown syntax because I hope Github will render git notes as Markdown in the future.
  • Github will show the image url allong with the commit
  • A local folder action (Automator.app) uploads all snapshot images to my server
  • When pushing your changes to the origin (Github) remember to also push the git notes: git push origin refs/notes/*

Example: https://github.com/smichaelsen/typo3-opauth/commit/9d7f6c9b6973282a68760157dc1f64d728088deb

@smichaelsen
smichaelsen / mycm
Last active December 19, 2015 12:39
My recent commits
git log --author="Sebastian Michaelsen" --format="format:%ai %h: %s"
<?php
namespace Smichaelsen\MyExt\ViewHelpers;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Class TimeSpanViewHelper
*
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable('myext', 'tt_content', 'category1');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable('myext', 'tt_content', 'category2');
@smichaelsen
smichaelsen / tmux_backup
Created November 27, 2013 09:16
tmux script to start (or re-attach) a backup session. The session launches a custom backup script and Time Machine.
if [ `tmux ls | grep -c backup` -gt 0 ]; then
echo "Session found. Attaching.."
else
echo "Session not found. Creating.."
tmux new-session -s backup -n bilder -d
echo "Building window#1 (bilder)"
tmux split-window -v -t backup:1
tmux send-keys -t backup:1.1 '~/backup_bilder' C-m
@smichaelsen
smichaelsen / hosts
Last active December 29, 2015 12:59
List configured ssh hosts
# Lists your configured SSH hosts
#
# example .ssh/config:
#
# +----------------------------------+
# |# Intranet |
# |Host Bilbo |
# | HostName bilbo.intranet |
# | User MyUser |
# |Host Frodo |
@smichaelsen
smichaelsen / remux
Last active December 31, 2015 22:09
restart a tmux session
#!/bin/sh
session=$*
echo "Restarting tmux session: $session"
tmux kill-session -t $session
~/tmux/$session