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 / UserController.php
Last active May 9, 2019 10:34
symfony2 - forced and secure user authentication (login) and logout (fos rest example)
//reference http://hasin.me/2013/10/27/how-to-login-a-user-programatically-in-symfony2/
//...
class UserController extends FOSRestController implements ClassResourceInterface {
//...
/**
* Authenticate a user with Symfony Security
*
@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>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Currencies</title>
</head>
<body>
<div>
<label for="incoming-price">The price of the leather bag is</label>
window.getGitTag = function(){
return (
$('#content > h2').text().replace('#', '') +
'-' +
$('#content .subject h3').text().replace('-', '')
).replace(' ', '-').toLowerCase();
};
@bichotll
bichotll / rs.js
Created May 13, 2016 09:11
Get title of the task to create a branch
/**
* Returns the name of the branch regarding the task number and title
* @example XXX-129-remove-blank-space-from-selector-view
*/
function rsGetTitle() {
return $('#key-val').text() + '-' + $('#summary-val').text().toLowerCase().replace(/ /g, '-');
}