Skip to content

Instantly share code, notes, and snippets.

View bichotll's full-sized avatar
😶
Doing stuff..

Jaume Tarradas Llort bichotll

😶
Doing stuff..
View GitHub Profile
@bichotll
bichotll / gist:c6701673764950e558f5
Created April 30, 2014 11:15
javascript private methods benchmark
/*
The aim of this test is to check the performance (as speed) and the memory creating instances of objects with public or private methods.
We want to see if create a private method in js really hurts the performance.
For that we will compare the performance creating so many instances and checking the performance
*/
function Public(){
this.publicMethod = function(){
@bichotll
bichotll / gist:4f8ecc929886c1d958a1
Created May 5, 2014 11:02
symfony linux permission problems
#solve symfony linux permission problems
sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
@bichotll
bichotll / list-files.sh
Last active August 29, 2015 14:02
Add directory at Home.md (for Wikis)
#create rutes
tree -fi | sed -r 's/\.\/|.md//g' | tail -n +2 | \
while read CMD; do
echo '['$CMD']('$CMD')'
echo ''
done > list-files.md
#check the file length
numberLines=$(cat list-files.md | wc -l)
@bichotll
bichotll / DefaultController.php
Created June 11, 2014 10:02
symfony controller action - how to unsecure but dynamical url parameters example
/**
* Test with / on the url
*
* @Route("/test/{test}", requirements={"test" = "(.*)"})
* @Method("GET")
* @Template()
*/
public function testAction($test) {
if($otherLinks)
{
@bichotll
bichotll / ContainerTestCase.php
Created June 30, 2014 15:32
Bundle testing with container setUp - not mine
<?php
require_once __DIR__.'/../../../../../../../app/AppKernel.php';
class ContainerTestCase extends WebTestCase {
private $container;
public function setUp() {
$this->app = new \AppKernel('test', true);
@bichotll
bichotll / gist:d29d2db9be78950241eb
Created September 2, 2014 11:28
shitty wp code - breadcrumb
function the_breadcrumb() {
global $post;
//var_dump($post);
echo '<ol class="breadcrumb" id="breadcrumbs">';
if (is_front_page() && !is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo _e('Home');
@bichotll
bichotll / functions.php
Created September 20, 2014 10:56
Get X posts by custom type
<?php
//show just X posts for custome type
function modify_num_posts_for_clients($query) {
if ($query->is_main_query() && $query->is_post_type_archive('client') && !is_admin()) {
$query->set('posts_per_page', -1);
}
}
add_action('pre_get_posts', 'modify_num_posts_for_clients');
" fdFDa %$£$£fdsaas\\fd465 65 as ".toLowerCase().trim().replace(/ /g,'-').replace(/[^\w-]+/g,'')
@bichotll
bichotll / Rater.js
Created March 30, 2015 17:05
Rater react component
'use strict';
var React = require('react');
var Star = React.createClass({
getDefaultProps: function () {
return {
isActive: false,
nStar: 0
}
@bichotll
bichotll / index.html
Created April 11, 2015 16:40
FormValidation // source http://jsbin.com/mikinu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FormValidation</title>
</head>
<body>
<form id="form" action="http://giphy.com/gifs/xnp2bUzXDhYnS">
<div>
<label for="name">First name</label>