Skip to content

Instantly share code, notes, and snippets.

View fvosberg's full-sized avatar

Frederik Vosberg fvosberg

View GitHub Profile
¯\_(ツ)_/¯
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 / 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';
cwd="$(pwd)/$( dirname "${BASH_SOURCE[0]}" )"
cpd="$(pwd)/$( dirname "${BASH_SOURCE[0]}" )/.."
@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}
}
}
@fvosberg
fvosberg / apache.conf-chef
Created July 15, 2015 07:32
Small Lamp Config
# for small servers
default['apache']['timeout'] = 30
default['apache']['keepaliverequests'] = 10
default['apache']['keepalivetimeout'] = 5
# only for prefork
default['apache']['prefork']['startservers'] = 3
default['apache']['prefork']['minspareservers'] = 3
default['apache']['prefork']['maxspareservers'] = 5
default['apache']['prefork']['maxrequestworkers'] = 10
default['apache']['prefork']['maxconnectionsperchild'] = 0
@fvosberg
fvosberg / CustomActionController.php
Created January 29, 2015 10:20
Get an invalid object in the "show form" action
public function initializeNewAction() {
if( !$this->request->hasArgument('newObject') && $this->request->getHttpRequest()->hasArgument('newObject') ) {
$this->request->setArgument('newObject', $this->request->getHttpRequest()->getArgument('newObject'));
}
}
@fvosberg
fvosberg / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@fvosberg
fvosberg / Views.yaml
Created December 1, 2014 10:22
Overwrite paginate template via views.yaml
-
requestFilter: 'parentRequest.isPackage("My.Package") && isSubPackage("ViewHelpers\Widget") && isController("Paginate")'
options:
templatePathAndFilename:
'resource://My.Package/Private/Templates/ViewHelpers/Widget/Paginate/Index.html'
@fvosberg
fvosberg / gist:c41ad554de3f44e81676
Created October 8, 2014 10:29
Javascript html special chars
function escapeHtml(text) {
var map = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;'
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });