Skip to content

Instantly share code, notes, and snippets.

@juanxo
juanxo / gist:775de750f7eb6e15cd31
Created June 17, 2014 18:13
to use it: git careful-forcepush
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
git fetch
LOCAL_HASH=`git show-ref -s refs/heads/$CURRENT_BRANCH`
REMOTE_HASH=`git show-ref -s refs/remotes/origin/$CURRENT_BRANCH`
if [ "$LOCAL_HASH" == "$REMOTE_HASH" ]; then
echo "There are no changes, force pushing"
git push -f
else
@juanxo
juanxo / gist:1b3682b76b08d1bfed7e
Created April 30, 2014 23:54
Vim function to improve handling of closing buffers
map <leader>bd :Bclose<cr>
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
@juanxo
juanxo / gist:6801190
Last active December 24, 2015 12:59
How really PDO PARAM_* conversions work
PDO::PARAM_STR converts whatever you give it to a string
PDO::PARAM_INT converts bools into longs
PDO::PARAM_BOOL converts longs into bools
That's all, and when I say all, I mean EVERY. POSSIBLE. MOTHERFUCKING. CONVERSION. wtf?!?!?
So, for some strange reason, my INT database field ID loads up as an string, and I cant elegantly make a INT out of it...
@juanxo
juanxo / fizzbuzz.rb
Created July 30, 2013 03:57
My take on FizzBuzz kata using ruby
module FizzBuzz
extend self
def get(number)
result = ''
result << 'Fizz' if multiple?(number, 3)
result << 'Buzz' if multiple?(number, 5)
return result if result.any?
number.to_s
end
@juanxo
juanxo / gist:5994255
Created July 14, 2013 13:22
Books recommended by the always awesome @pasku1
Clean Code
Diseño Ágil con TDD
Growing Object-Oriented Software, Guided by Tests
Apprenticeship Patterns: Guidance for the Aspiring Software Craftsman
@juanxo
juanxo / gist:5712988
Created June 5, 2013 10:30
An informal review of the MashMeTV Frontend

MashMeTV Front End review

Why?

As one of my passions is Web Performance, something I do whenever I apply for an open position is to review how well they are doing on the front end.

This is a review of the landing page only, I keep other secrets for the Friday xD

Review

@juanxo
juanxo / gist:5572374
Last active December 17, 2015 07:19
I wanted to know how well MashMeTV were doing on the BBVA Open Talent 2013 challenge, but the page didn't have any way to sort the results by votes, so I came with this. To use it, go to any page in https://www.centrodeinnovacionbbva.com/opentalent/votaciones, fire up you browser console and paste this script. Results will be stored in 'applicat…
(function(){
var script, totalPages, requests, i;
script = document.createElement('script');
script.src = "//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js";
script.onload = loadUnderscore;
document.body.appendChild(script);
window.applications = [];
requests = [];
@juanxo
juanxo / Custom.css
Created October 5, 2012 00:45 — forked from bentruyman/Custom.css
IR_Black Theme for Chrome Developer Tools
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@juanxo
juanxo / fucknaks.coffee
Created July 18, 2012 21:27
Hubot script to inhibit naks violent reactions
module.exports = (robot) ->
robot.hear /./i, (msg) ->
sender = msg.message.user.name.toLowerCase()
if ( sender == "naks")
msg.reply "Shut the fuck up!"