Skip to content

Instantly share code, notes, and snippets.

View markuspoerschke's full-sized avatar

Markus Poerschke markuspoerschke

View GitHub Profile
@markuspoerschke
markuspoerschke / gist:350e3db6dfaa1a7aebfcab4c8a63df43
Created May 7, 2020 14:07
Remove all branches except master
git branch | egrep -v "(^\*|master|dev)" | xargs git branch -d
@markuspoerschke
markuspoerschke / file.php
Created April 4, 2019 08:30
Get SQL query as string from Extbase Query
<?php
// ...
$queryParser = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class);
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->convertQueryToDoctrineQueryBuilder($query)->getSQL());
@markuspoerschke
markuspoerschke / clear_gitlab_runner_cache.sh
Created November 29, 2017 16:41
Clear GitLab Runner cache
docker ps -f status=exited | grep "\-cache-" | awk '{print $1}' | xargs docker rm
@markuspoerschke
markuspoerschke / get_jira_tasks_from_commits.sh
Last active November 29, 2017 16:40
Get Jira task-keys from commit messages.
# This will get all task keys that are relevant for the version 2.5.0 release
git log 2.4.0..2.5.0 --pretty=oneline | perl -ne '{ /(\w+)-(\d+)/ && print "$1-$2,"}'
@markuspoerschke
markuspoerschke / page.ts
Last active December 19, 2015 09:29
TYPO3: Using typolink in scheduler
# In your TypoScript you should add the absolute prefix
# or URL would look like this: http://www.example.com/var/www/news/mein-artikel
config.absRefPrefix = /
@markuspoerschke
markuspoerschke / customList.tex
Created April 25, 2013 17:56
Create a custom list for LaTeX. For my final paper for a degree as computer specialist I needed to add a glossary and a table of acronyms. I did not want to use a package. For this reason I looked for a simple solution: `\newenviroment` offers the possibility to define a custom list. Here is an Example on how to define a custom list.
% Custom list for glossary
\newenvironment{glossarydescription}{
\begin{list}{}{
\setlength{\labelsep}{0mm} % space before text.
\setlength{\labelwidth}{44mm} % width of the label.
\setlength{\leftmargin}{44mm} % adjust margin. same size as labelwidth.
\renewcommand{\makelabel}[1]{\textbf{##1\space}\dotfill\space} % \dotfill creates a line of dots. you can also use \hfill
}
}
{\end{list}}
@markuspoerschke
markuspoerschke / hashStringFunction.php
Created January 23, 2013 13:22
Simple hashing function in PHP. Any alogrithm supported by the build in hash() function can be used. This function actually only adds rounds and concatenate the string with a salt.
<?php
/**
* @param $string string The string/password to be hashed
* @param $salt string The salt that will be added to the string
* @param $rounds int Number of rounds
* @param $algo string The algorithm that should be used for hashing
* @return string Returns the hashed string
*/
function createHash($string, $salt = '', $rounds = 500, $algo = 'sha256') {
@markuspoerschke
markuspoerschke / router.php
Created October 7, 2012 15:50
Simple router.php for using the PHP 5.4 built-in webserver
<?php
// Filename of requested file...
$requested = __DIR__ . $_SERVER['REQUEST_URI'];
// If file exists use file
if (file_exists($requested) && !is_dir($requested)) {
return false;
}
@markuspoerschke
markuspoerschke / ModelAdmin.php
Created September 7, 2012 17:30
SonataAdminBundle: Validate Unique
class ModelAdmin extend Admin
{
// ...
public function validate(ErrorElement $errorElement, $object)
{
// find object with the same uniqueField-value
$other = $this->modelManager->findOneBy($this->getClass(), array('uniqueField' => $object->getUniqueSlug()));
if (null !== $other && !$other->equals($object)) {
@markuspoerschke
markuspoerschke / InvoiceAdmin.php
Created September 5, 2012 15:14
Translate value in SonataAdminBundle list
class InvoiceAdmin extends Admin
{
// ...
protected function configureListFields(ListMapper $list)
{
$list
->addIdentifier('name')
// Use "trans" type to translate the given value