Skip to content

Instantly share code, notes, and snippets.

🍄
(S)mushed

Òscar Casajuana elboletaire

🍄
(S)mushed
Block or report user

Report or block elboletaire

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@elboletaire
elboletaire / findWithCityCode.php
Last active Feb 22, 2017
CakePHP 3.X `CASE` question
View findWithCityCode.php
<?php
public function findWithCityCode(Query $query, array $options = [])
{
$expression = $query->newExpr()->addCase([
$query->func()->length(['Cities.code' => 'identifier']),
],[
$query->func()->concat([
'(',
'Cities.code' => 'identifier',
')',
@elboletaire
elboletaire / php
Created Jan 24, 2016
php on cygwin
View php
#!/bin/bash
# e.g. php="/cygdrive/c/Program Files (x86)/php/php.exe"
php="/C/httpd/php56/php.exe"
for ((n=1; n <= $#; n++)); do
if [ -e "${!n}" ]; then
# Converts Unix style paths to Windows equivalents
path="$(cygpath --mixed ${!n} | xargs)"
@elboletaire
elboletaire / description.md
Created Apr 2, 2015
Git hook prepare-commit-msg
View description.md

This git hook extracts the number from a branch and adds it to the commit message as refs. i.e.:

From a branch named whatever-branch-name-5234 will create a commit message like this:

refs #5234
# git COMMIT_MSG comments
@elboletaire
elboletaire / gmail-replace.js
Last active Sep 19, 2015
Removes the gmail caching prefix for images, leaving just the real images.
View gmail-replace.js
var images = document.getElementsByTagName('img');
for (var i in images) {
if (typeof images[i] !== 'object' || typeof images[i].src === 'undefined') continue;
if (/([^#]+)#(https?.+)/.test(images[i].src)) {
var matches = images[i].src.match(/([^#]+)#(https?.+)/);
images[i].src = matches[2];
}
}
@elboletaire
elboletaire / mapmanager.js
Created May 29, 2014
A helper for google maps V3
View mapmanager.js
/**
* MapManager helper class for google maps api V3
*
* @author Òscar Casajuana <elboletaire@underave.net>
* @param {object} options Default options to pass to the map manager
* {
* id: "map", // your canvas id
* multiple_select: true, // set to true to show a multiple select when there are multiple results
* max_points: 23, // max number of points allowed into the map (false to disable)
* limit_alert: "You reached the limit!", // The alert showed when trying to add more points than allowed
View .zsh_aliases
############################
### ----[ Websites ]---- ###
############################
export www=/cygdrive/c/httpd/www
export lliure=$www/lliure
export underave=$lliure/underave
#############################
### ----[ Git & co. ]---- ###
@elboletaire
elboletaire / get-gitignore.sh
Last active Mar 13, 2019
A bash method to get gitignore files from github gitignore's repo
View get-gitignore.sh
get_gitignore() {
local gitignore=https://raw.github.com/github/gitignore/master/$1.gitignore
local exists=`curl -s --head -w %{http_code} $gitignore -o /dev/null`
if [[ $exists -eq 404 ]]; then
echo "El gitignore esmentat no existeix. Comprova que l'has escrit be"
else
curl -s https://raw.githubusercontent.com/github/gitignore/master/$1.gitignore
fi
}
View install.bat
@ECHO OFF
REM -- Automates cygwin installation
SETLOCAL
REM -- Change to the directory of the executing batch file
CD %~dp0
REM -- Configure our paths
SET SITE=http://cygwin.mirrors.pair.com/
View powershell_here.reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\powershell]
"Icon"="%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
@="Obre powershell"
[HKEY_CLASSES_ROOT\Directory\shell\powershell\command]
@="C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe -NoExit -NoLogo -Command Set-Location -LiteralPath '%L'"
[HKEY_CLASSES_ROOT\Directory\Background\shell\powershell]
@elboletaire
elboletaire / unicorn.sh
Created May 13, 2013
Unicorn init.d script
View unicorn.sh
#!/bin/bash
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by elboletaire@underave.net http://github.com/elboletaire
# based on https://gist.github.com/jaygooby/504875 http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
You can’t perform that action at this time.