Skip to content

Instantly share code, notes, and snippets.

Avatar

Gabriel Cebrian gabceb

View GitHub Profile
View keybase.md

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 Mar 18, 2014
hijack links for pushState in Backbone using Coffeescript. Original JS code at https://gist.github.com/tbranyen/1142129
View backbone_pushstate_router.js.coffee
# 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}//"
View get_me_that_message.rb
## 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 Mar 8, 2013
Handling 404, 401 and 500 exceptions on Rails
View gist:5113767
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
Powershell script to convert all xls documents to xlsx in a folder recursively
View ConvertXLS.ps1
$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("."))