Skip to content

Instantly share code, notes, and snippets.

@akerouanton
akerouanton / .bash_aliases
Last active February 1, 2016 09:21
Bash macro preventing composer execution with xdebug enabled
COMPOSER_PATH=`which composer`
composer() {
if ! php5query -s cli -m xdebug >/dev/null; then
$COMPOSER_PATH $@
return
fi
# Re-enable xdebug even after a ctrl-c (SIGINT)
# and clear the signal handler
trap 'sudo php5enmod xdebug; trap - INT' INT
@rponte
rponte / simple_method.js
Last active June 11, 2016 09:13
Delaying actions on keypress with jQuery
$('#mySearch').keyup(function() {
clearTimeout($.data(this, 'timer'));
var wait = setTimeout(search, 500);
$(this).data('timer', wait);
});
function search() {
$.post("stuff.php", {nStr: "" + $('#mySearch').val() + ""}, function(data){
if(data.length > 0) {
$('#suggestions').show();
@bigcalm
bigcalm / fail_demo.html.twig
Created February 6, 2013 14:38
Using Symfony2, DQL and knplabs/knp-paginator-bundle - how to get around "Cannot count query which selects two FROM components, cannot make distinction"
<ul>
{% for project in pagination %}
<li>{{ project.name }} has {{ project.?? }} tasks</li>
{% endfor %}
</ul>
@eddywashere
eddywashere / pre-commit
Last active March 25, 2017 00:38
Git hook that prevents commits to master
#!/bin/sh
#
# Git hook that prevents commits to master
# use --no-verify to bypass this hook
# ex: git commit -m "init commit" --no-verify
branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
echo "Direct commits to the branch master are not allowed"
exit 1
@xocasdashdash
xocasdashdash / infinite-scroll.js
Created August 24, 2014 13:42
Simple infinite scrol with jQuery and a Symfony2 backend
is_processing = false;
last_page = false;
function addMoreElements() {
is_processing = true;
$.ajax({
type: "GET",
//FOS Routing
url: Routing.generate('route_name', {page: page}),
success: function(data) {
if (data.html.length > 0) {
@fsevestre
fsevestre / BooleanType.php
Last active December 26, 2018 16:15
Boolean form type for Symfony2 + tests (library: https://github.com/fsevestre/BooleanFormType)
<?php
namespace AppBundle\Form\Type;
use AppBundle\Form\DataTransformer\BooleanTypeToBooleanTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class BooleanType extends AbstractType
@scmx
scmx / upgrade-install-ruby-2-1-2-ubuntu-12-04.md
Last active November 6, 2019 15:31
Upgrade/Install ruby 2.1.2 #ubuntu #12.04 #14.04

Upgrade/Install ruby 2.1.2

ubuntu 12.04 14.04

Reference http://stackoverflow.com/a/18490935/2037928

Login as root

Install needed packages

apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
@JusteLeblanc
JusteLeblanc / materialize_form_theme.html.twig
Created February 27, 2017 21:09
Symfony2 form theme to integrate Materialize in your Symfony2 forms
{% extends 'form_div_layout.html.twig' %}
{% block form_row -%}
<div class="row{% if (not compound or force_error|default(false)) and not valid %} has-error{% endif %}">
<div class="input-field col s12">
{{- form_widget(form) -}}
{{- form_label(form) -}}
{{- form_errors(form) -}}
</div>
</div>
@paulund
paulund / wordpress-base-custom-data.php
Created September 24, 2013 16:27
A PHP class to handle CRUD functionality in WordPress default tables.
<?php
/**
* Abstract class which has helper functions to get data from the database
*/
abstract class Base_Custom_Data
{
/**
* The current table name
*
* @var boolean
@mpalourdio
mpalourdio / php-cs-fixer
Created November 12, 2014 21:24
@fabpot php-cs-fixer config for PhpStorm
parameters
--level=psr2 --verbose fix $FileDir$/$FileName$
working directory
$ProjectFileDir$