Skip to content

Instantly share code, notes, and snippets.

View tacone's full-sized avatar
💭
¯\_(ツ)_/¯

tacone

💭
¯\_(ツ)_/¯
View GitHub Profile
@tacone
tacone / rewriteProperties.js
Last active August 29, 2015 13:57
How to interpolate/evaluate javascript object keys
/**
* Will evaluate all the keys of a given object containing a plus sign "+"
* to the expression result.
*
* example:
* var a = 2;
* var obj = { " 'hello' + a " : true };
* rewriteProperties(obj); // returns { hello2: true }
*
*/
@tacone
tacone / gist:8f270be8814c107399e5
Created July 27, 2014 14:08
Print a Baum tree with Twig
{% macro menuLinks(root, maxdepth) %}
{% import _self as macros %}
{# print a UL tree #}
{% for link in root.children %}
<li>
<a href="{{ link.slug }}">{{ link.name }}</a>
{% if link.children and (maxdepth > link.depth or not maxdepth) %}
<ul>
{{ macros.menuLinks(link, maxdepth) }}
</ul>
@tacone
tacone / wwwwrite.zsh
Last active August 29, 2015 14:05
Give the webserver write permissions on a folder
function wwwwrite () {
sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX $1 && sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx $1
}
@tacone
tacone / rapyd-scratchpad.php
Created September 30, 2014 20:24
Rapyd scratchpad
<?php
function edit ()
{
$model = new Article();
$form = new DataForm($model); //--> $form->model
$form->text('title');
$form->text('author.name');
# ---------------------------------------------------------------------- #
# Target DBMS: MySQL 5 #
# Project name: Northwind #
# Author: Valon Hoti #
# Created on: 2010-07-07 20:00 #
# ---------------------------------------------------------------------- #
DROP DATABASE IF EXISTS northwind;
CREATE DATABASE IF NOT EXISTS northwind;
@tacone
tacone / gulpfile.js
Last active August 29, 2015 14:23
This is my gulpfile. There are many like it, but this one is mine.
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin'),
cache = require('gulp-cache');
var minifycss = require('gulp-minify-css');
@tacone
tacone / MigrateDone.php
Created July 19, 2015 13:53
How to mark Laravel 4 migrations as done without executing them
<?php
use Illuminate\Database\Console\Migrations\BaseCommand;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Database\Migrations\Migrator;
use Symfony\Component\Console\Input\InputOption;
class MigrateDone extends BaseCommand
{
@tacone
tacone / Multiselect.php
Created October 10, 2015 15:13
Multiselect field with Zofe/Rapyd
<?php namespace Zofe\Rapyd\DataForm\Field;
use Illuminate\Support\Facades\Form;
class Multiselect extends Field
{
public $type = "checks";
public $multiple = true;
public $size = null;
public $description = "";
@tacone
tacone / bench.php
Created October 12, 2015 21:03
Arrays and iterators benchmark
<?php
class Aggregate implements \IteratorAggregate
{
protected $var;
public function __construct($var = null)
{
if (is_array($var)) {
$this->var = new ArrayIterator($var);
@tacone
tacone / gist:4534615
Last active December 11, 2015 02:58
How to manage structured data with Bootstrap typeahead.
/* bad indentation is NetBeans' fault, camelCase is Propel's fault */
var retrieveTeachers = function(query, process) {
// let them be json
var transformTeachers = function(teachers) {
return $.map(teachers, function(teacher) {
return {
id: teacher.Id,
FullName: (teacher.Name + ' ' + teacher.Surname),
// these functions allows Bootstrap typehead to use this item in places where it was expecting a string
toString: function() {