Skip to content

Instantly share code, notes, and snippets.

View fvosberg's full-sized avatar

Frederik Vosberg fvosberg

View GitHub Profile
@fvosberg
fvosberg / example.ts
Created August 14, 2015 13:49
Replace link in Translation with TypoScript
privacy_policy_label = TEXT
privacy_policy_label.data = LLL:fileadmin/Pipapo/Private/Language/locallang.xlf:label.privacy_policy
privacy_policy_label.stdWrap.replacement.10 {
search = %%%link%%%
replace.stdWrap.typolink {
parameter = {$privacy_policy.pid}
}
}
cwd="$(pwd)/$( dirname "${BASH_SOURCE[0]}" )"
cpd="$(pwd)/$( dirname "${BASH_SOURCE[0]}" )/.."
@fvosberg
fvosberg / create_db.sql
Created August 31, 2015 19:39
Create Mysql database with user
CREATE DATABASE `databasename` CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON `databasename`.* TO `username`@localhost IDENTIFIED BY 'password';
for i in $(docker-machine ls | grep digitalocean | awk '{print $1}'); \
do printf "\x1B[01;33m\n$i\n\x1B[0m" && docker-machine ssh $i ls /swapfile || \
docker-machine ssh $i -- \
"fallocate -l 1G /swapfile && chmod 600 /swapfile && mkswap /swapfile && \
echo -e '\n/swapfile none swap defaults 0 0' >> /etc/fstab && swapon -a && free -htl"; done
¯\_(ツ)_/¯
@fvosberg
fvosberg / memory_usage.php
Created December 29, 2015 14:42
Display memory usage
$size = memory_get_usage(TRUE);
$unit = array('b','kb','mb','gb','tb','pb');
$mem = @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
@fvosberg
fvosberg / Gulpfile.js
Created January 25, 2016 21:10
Gulpfile for phpunit in composer project
var gulp = require('gulp');
var exec = require('child_process').exec;
var path = require('path');
var fs = require('fs');
gulp.task('phpunit', function() {
var class_file_to_test_file = function(class_path) {
var test_file = class_path.replace(/\/Classes\//g, '/Tests/Unit/');
return test_file.slice(0, -4) + 'Test.php';
};
@fvosberg
fvosberg / jquery-wrapper.js
Created March 9, 2016 11:09
Wrapper for jquery functions
function executeWithJquery(callback) {
(function($){
if(!$) {
if(typeof console === 'object') {
console.log('This plugin requires jQuery.');
}
return;
}
callback();
})((typeof jQuery !== "undefined" ? jQuery : null));
@fvosberg
fvosberg / ssh-agent.sh
Created March 17, 2016 11:56
Start SSH-Agent
eval `ssh-agent` # or
exec ssh-agent bash
ssh-add
@fvosberg
fvosberg / install-composer.sh
Created April 19, 2016 20:24
Install composer oneliner for bash with curl
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer