Skip to content

Instantly share code, notes, and snippets.

View albertobajo's full-sized avatar

Alberto Bajo albertobajo

  • Sage
  • Bilbao
  • 22:48 (UTC +02:00)
View GitHub Profile
@albertobajo
albertobajo / 20190626_daily_coding_problem.rb
Last active June 28, 2019 10:11
20190626 Daily Coding Problem
# Good morning! Here's your coding interview problem for today.
# This problem was asked by Uber.
# Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.
# For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].
# Follow-up: what if you can't use division?
# Results
# user system total real
# div: 0.003087 0.000214 0.003301 ( 0.003285)
# rotate: 0.421551 0.004000 0.425551 ( 0.425792)
@albertobajo
albertobajo / jquery.cookie-policy.js
Last active August 29, 2015 14:24
jQuery Cookie Policy
@albertobajo
albertobajo / parse_signed_request
Created November 10, 2010 10:03
Python implementation of Facebook's php signed_request parser: http://developers.facebook.com/docs/authentication/canvas
import hmac
import simplejson as json
from base64 import urlsafe_b64decode
from hashlib import sha256
def parse_signed_request(signed_request, secret):
[encoded_sig, payload] = signed_request.split('.')
# decode data