Skip to content

Instantly share code, notes, and snippets.

Avatar

Jose Antonio Guerra jaguerra

  • Tuenti
  • Madrid
View GitHub Profile
@jaguerra
jaguerra / MyCommandController.php
Last active Oct 15, 2015
Execute CLI extbase CommandController as an admin user
View MyCommandController.php
<?php
namespace My\MyExtension\Command;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class MyCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController {
/**
* Make _cli_lowlevel admin for this controller...
*/
View Git add untracked files to gitignore
git status --porcelain | awk '($1 ~ /\?\?/) {print "/" $2}' >> .gitignore
@jaguerra
jaguerra / check.sql
Created Mar 30, 2015
Check and migrate all HTML cObjects from the database while upgrading to TYPO3 CMS 6.2
View check.sql
SELECT sys_template.config, REPLACE(config, ' HTML', ' TEXT')
FROM `sys_template`
INNER JOIN pages ON pages.uid = sys_template.pid
WHERE `config` REGEXP BINARY 'HTML'
AND sys_template.deleted = 0 AND sys_template.pid >= '0'
AND pages.deleted = 0
@jaguerra
jaguerra / SomeRepository.php
Created May 7, 2013
RAW result query on Extbase
View SomeRepository.php
<?php
function findRaw(){
$localQuery = $this->createQuery();
$storagePageIds = $localQuery->getQuerySettings()->getStoragePageIds();
$querySettings = $localQuery->getQuerySettings();
$querySettings->setReturnRawQueryResult(TRUE);
$localQuery->setQuerySettings( $querySettings );
@jaguerra
jaguerra / pageTSConfig.ts
Created Apr 24, 2013
TYPO3 RTE htmlarea allow iframe, script and html5 data attributes
View pageTSConfig.ts
#
# Permitir iframe, embed, script en RTE
#
RTE.default.proc.allowTags := addToList(iframe,embed,script,object,param,a,ul,li,ol)
RTE.default.proc.allowTagsOutside := addToList(iframe,embed,script,object,param,a,ul,li,ol)
RTE.default.removeTagsAndContents := removeFromList(script,object,param,a,ul,li,ol)
RTE.default.proc.HTMLparser_db = 0
RTE.default.proc.entryHTMLparser_db = 0
RTE.default.proc.exitHTMLparser_db = 0
@jaguerra
jaguerra / pre-commit
Created Apr 15, 2013
Git pre-commit hook to launch rake
View pre-commit
#!/bin/bash
# Adapted from http://jimneath.org/2012/05/05/precompile-assets-using-a-git-hook.html
# source rvm and .rvmrc if present
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
[ -s "$PWD/.rvmrc" ] && . "$PWD/.rvmrc"
# precompile assets if any have been updated
if git diff-index --name-only HEAD | egrep '^css/sass' >/dev/null ; then
@jaguerra
jaguerra / css2scss.sh
Last active Oct 24, 2017
Many CSS 2 LESS (or SCSS)
View css2scss.sh
#!/bin/bash
find . -name '*.css' -type f | while read fullfilename
do
filename=`basename $fullfilename`
extension="${filename##*.}"
filename="${filename%.*}"
echo "Converting $fullfilename"
sass-convert -T scss --indent t -C $fullfilename > sass/_$filename.scss
done
@jaguerra
jaguerra / db_utf8_fix.php
Last active Nov 30, 2018
Script to convert TYPO3 DB from latin1 to UTF8. Includes conversion of fields containing serialized PHP arrays into binary fields to avoid breakage.
View db_utf8_fix.php
<?php
/******************************************/
// db_utf8_fix.php //
// Original author: J. van Hemert //
// Original Date: 26-10-2011 //
// //
// Fixes encoding when utf-8-encoded data //
// is stored in tables with other (e.g. //
// latin_swedish_ci) encoding. //
// Will convert all columns in all tables //
@jaguerra
jaguerra / fix-double-encoding.sh
Last active Dec 10, 2015
Fix double encoded utf-8 in mysql
View fix-double-encoding.sh
#!/bin/bash -e
DB_HOST="$1"
DB_USER="$2"
DB_PASSWORD="$3"
DB_NAME="$4"
mysqldump -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASSWORD" --opt --quote-names \
--skip-set-charset --default-character-set=latin1 "$DB_NAME" > /tmp/temp.sql
@jaguerra
jaguerra / resize.sh
Created Jul 27, 2012
SH Resize JPG files with size > 1 Mb
View resize.sh
#!/bin/bash
find . -name '*.jpg' -type f -size +1M -not -name '*backup*' | while read filename
do
if [ ! -e "$filename.backup.jpg" ]
then
echo "Backup of $filename.backup.jpg"
cp "$filename" "$filename.backup.jpg"
fi
echo "Limpiando datos de perfil $filename"
gm identify "$filename"