Skip to content

Instantly share code, notes, and snippets.

View Nemo64's full-sized avatar

Marco Pfeiffer Nemo64

View GitHub Profile
@Nemo64
Nemo64 / symcc.sh
Created February 27, 2014 08:23
A script that kills all caches in symfony
DEFAULT_ENVIREMENTS=( dev prod )
FILE_USER=`whoami`
if [ $# -gt 0 ]
then ENVIREMENTS=$*
else ENVIREMENTS=$DEFAULT_ENVIREMENTS
fi
echo change ownership of app/cache app/logs and web/bundles to $FILE_USER
chown -RL $FILE_USER app/cache app/logs web/bundles
@Nemo64
Nemo64 / horizontal.html.twig
Last active August 29, 2015 13:56
These is a symfony form style for bootstrap3 horizontal forms
{% block form_row %}
{%- spaceless %}
{% set label_width = label_width|default(4) %}
{#{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %}#}
<div class="form-group{% if errors|length > 0 %} has-error{% endif %}">
{% set label_class = (label_attr.class|default('') ~ ' col-sm-' ~ label_width ~ ' control-label')|trim %}
{% set label_attr = label_attr|merge({ label_attr: { class: label_class } }) %}
{{ form_label(form, null, label_attr) }}
<div class="col-sm-{{ 12 - label_width }}">
{{ form_widget(form, { attr: attr }) }}
@Nemo64
Nemo64 / select2-autobind.js
Last active August 29, 2015 13:56
automatically attaches select2 to all selects with the js-select2 class. All data-* attributes are passed as options to select2, eg. <select class="js-select2" data-minimum-input-length="3"></select>
// automatically attaches select2 to all selects with the js-select2 class
// All data-* attributes are passed as options to select2, eg. <select class="js-select2" data-minimum-input-length="3"></select>
// use the update event if you add new html (ajax etc.)
$(document).on("ready update", function (e) {
var $target = $(e.target);
$target.find("select.js-select2").each(function () {
var $select = $(this);
var options = $select.data();
for (var key in options) {
var option = options[key];
@Nemo64
Nemo64 / datepicker.js
Created March 5, 2014 09:40
jquery-ui datepicker if no support for type="date"
// check for support of a datepicker
// assume that the browser must be able to parse the date if it is of type date
$.support.datepicker = (function () {
var el = document.createElement('input'), notADateValue = 'not-a-date';
el.setAttribute('type', 'date');
el.setAttribute('value', notADateValue);
return !(el.value === notADateValue);
})();
@Nemo64
Nemo64 / c
Created June 26, 2014 15:03
Symfony app/console or bin/console shortcut to the simple letter "c". It also allows for autocompletion.
#!/bin/bash
CONSOLE_BIN=`symfony_console_binary`
if [ $CONSOLE_BIN ]
then
$CONSOLE_BIN $*
else
echo "no console binary found"
fi
@Nemo64
Nemo64 / SvgImportViewHelper
Created July 17, 2014 07:22
An Extbase ViewHelper which inlines svgs into the template
<?php
class SvgImportViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
{
private static $id = 0;
/**
* Renders the content.
*
* @param string $src
* @return string
@Nemo64
Nemo64 / bootstrap_tabs.js
Created July 18, 2014 15:17
remember which bootstrap tab was active while navigating. This is a very cheap cookie trick and it requires jquery-cookie.
// behavior for tabs
// FIXME can create unexpected behavior with multiple tabs on one page, also with multiple browser tabs/windows
$(document).on('click', '[data-toggle="tab"], [data-toggle="pill"]', function(event) {
var hash = $.prop(this, "hash");
$.cookie('active-tab', hash, { path: '/' });
});
$(window).on('popstate hashchange ready load', function() {
var cookieTab = $.cookie('active-tab');
var tab = cookieTab || null;
@Nemo64
Nemo64 / formhandler.js
Created August 25, 2014 10:31
common js form additions
/**
* User: Marco Pfeiffer
* Date: 04.04.13
* Time: 09:43
*/
(function ($) {
var IMPORTANT_FORMS = "form:not(.unimportant):not([target])";
var IMPORTANT_INPUT_FIELDS = ":input[name]:not(.unimportant)";
@Nemo64
Nemo64 / .bashrc
Created August 31, 2014 10:59
Very dynamic and colorfull .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files for examples
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
# If not running interactively, don't do anything!
[[ $- != *i* ]] && return
@Nemo64
Nemo64 / githistory.sh
Created November 9, 2015 15:14
git history for multiple folders
#!/usr/bin/env bash
#!/usr/bin/env bash
REPS=`find /home/dev/Workspace -maxdepth 4 -type d -name ".git"`
USERNAME=`git config --get user.name`
echo "search for history of ${USERNAME}"
for REP in $REPS
do