Skip to content

Instantly share code, notes, and snippets.

View gabceb's full-sized avatar

Gabriel Cebrian gabceb

View GitHub Profile

Keybase proof

I hereby claim:

  • I am gabceb on github.
  • I am gabceb (https://keybase.io/gabceb) on keybase.
  • I have a public key ASC41clzTL3dQM9dHkLDX2xVJ-JrJXUBkMdp0HDDcDVWBQo

To claim this, I am signing this object:

@gabceb
gabceb / backbone_pushstate_router.js.coffee
Created March 18, 2014 21:22
hijack links for pushState in Backbone using Coffeescript. Original JS code at https://gist.github.com/tbranyen/1142129
# Use absolute URLs to navigate to anything not in your Router.
# Only need this for pushState enabled browsers
if Backbone.history && Backbone.history._hasPushState
# Use delegation to avoid initial DOM selection and allow all matching elements to bubble
$(document).delegate("a", "click", (evt) ->
# Get the anchor href and protcol
href = $(this).attr("href")
protocol = "#{this.protocol}//"
## This piece of code is not optimized for beauty or # of lines so don't judge :p
require 'open-uri'
require 'JSON'
url = "http://www.letsrevolutionizetesting.com/challenge"
while true do
url = url.gsub("challenge", "challenge.json")
json = JSON.parse(open(url).read)
@gabceb
gabceb / gist:5113767
Created March 8, 2013 02:27
Handling 404, 401 and 500 exceptions on Rails
class ApplicationController < ActionController::Base
unless Rails.application.config.consider_all_requests_local
#rescue_from Exception, with: :render_500
rescue_from ActionController::RoutingError, with: :render_canvas_404
rescue_from ActionController::UnknownController, with: :render_404
rescue_from AbstractController::ActionNotFound, with: :render_404
rescue_from ActiveRecord::RecordNotFound, with: :render_404
rescue_from ActiveResource::ForbiddenAccess, with: :render_403
end
@gabceb
gabceb / ConvertXLS.ps1
Created May 3, 2011 22:36
Powershell script to convert all xls documents to xlsx in a folder recursively
$xlFixedFormat = [Microsoft.Office.Interop.Excel.XlFileFormat]::xlOpenXMLWorkbook
write-host $xlFixedFormat
$excel = New-Object -ComObject excel.application
$excel.visible = $true
$folderpath = "C:\Users\gabceb\Documents\testXLS"
$filetype ="*xls"
Get-ChildItem -Path $folderpath -Include $filetype -recurse |
ForEach-Object `
{
$path = ($_.fullname).substring(0, ($_.FullName).lastindexOf("."))