Skip to content

Instantly share code, notes, and snippets.

View lagartoflojo's full-sized avatar
🇨🇱
en 🇩🇪

Hernán Schmidt lagartoflojo

🇨🇱
en 🇩🇪
  • Nürnberg, Deutschland
View GitHub Profile
@lagartoflojo
lagartoflojo / copy-k8s-resources-across-namespaces.sh
Last active October 30, 2017 16:48 — forked from simonswine/copy-k8s-resources-across-namespaces.sh
Copying kubernetes resources accross namespaces
kubectl get rs,secrets -o json --namespace <OLD_NAMESPACE> | jq '.items[].metadata.namespace = "<NEW_NAMESPACE>"' | kubectl create -f -
@lagartoflojo
lagartoflojo / scroll-shadow.css
Created October 11, 2017 13:02 — forked from travismillerweb/scroll-shadow.css
CSS - Google Scroll Shadow
/*
Gmail/Google Reader Sidebar Scroll Shadows
-------------------------------------------
Neat effect that mimics the scroll shadows that appear in the GOogle sitde bar and visually cues users to scroll up or down depending on their position.
Credit goes to Lea Verou for this awesome find.
Source:
Lea's Talk: http://www.youtube.com/watch?v=3ikye7Qc7Ak
Code Source: http://lea.verou.me/more-css-secrets/#slide9
@lagartoflojo
lagartoflojo / service.rb
Created August 21, 2017 20:17
Dependency Injection example in Ruby
require 'resolv'
class ConferenceDomainsService
def initialize(conference, resolver = Resolv::DNS.new)
@conference = conference
@resolver = resolver
end
##
# Checks if domain correctly points to the hosted version
@lagartoflojo
lagartoflojo / rest-vs-graphql.md
Created December 13, 2016 11:10
REST vs. GraphQL - the problems with REST and how GraphQL aims to solve them

TL;DR: REST endpoints cause latency and bandwidth problems. GraphQL aims to solve those issues. At the SCC, we'd like to create a prototype of a GraphQL API.

REST

For a good number of years now, REST (Representational state transfer) has been the most common way of writing web APIs. While there is no "REST standard", the basic idea is that web servers provide access to resources through unique URLs, and those resources can provide hypertext links to other related resources.

REST example

For example, we could access the user David (the resource) through the URL http://example.com/users/david. We can operate on that resource by using the HTTP verbs GET, POST, PUT, DELETE, etc. To retrieve the resource's data, we can request GET http://example.com/users/david, and receive some JSON, XML or HTML data structure with David's information in return. In that structure, we might find a link the David's friends at `http://example.com/users/

@lagartoflojo
lagartoflojo / try-and-allow.md
Last active September 26, 2016 11:28
How to get your butt bitten by Rails' try and rspec's allow(x).to receive(:bla)

Why Rails' try() and rspec's allow(x).to receive(:bla) can bite you in the butt:

When actions are taken by superusers, we're supposed to append admin_ to the SystemLog event names. For example: when one of us logs in, there should be a SystemLog with admin_log_in event. When normal users log in, there's a SystemLog with log_in event.

If you check your SystemLog table, you'll see that's not currently true ;) And it hasn't been for quite a while. This is surprising, since all of our SystemLog specs are passing!

Digging deeper, we find self.prefixed_event_name(event_name) in SystemLog, which is supposed to add the admin_ prefix. That method checks if the current_user is an admin with: current_user.try(:admin?). current_user could be nil, which is why we use try here. But guess what: the method User#admin? does not exist! We recently renamed admins to superusers, so the correct call should be current_user.try(:superuser?).

But then, how can our tests be passing??

Ember.Handlebars.helper 'format', (body) ->
body = Handlebars.Utils.escapeExpression(body)
body = body.replace(/\n\r?/g, '<br>')
new Handlebars.SafeString(body)
# Usage: {{format stringWithNewLines}}
@lagartoflojo
lagartoflojo / tresleches.md
Last active December 19, 2015 03:58
Receta de Torta Tres Leches

Torta Tres Leches

Bizcochuelo

  • 4 huevos separados
  • 1 1/2 taza de harina
  • 1 1/4 taza de azúcar
  • 4 cucharaditas de esencia de vainilla
  • 3 cucharaditas de polvos de hornear
@lagartoflojo
lagartoflojo / nesting.coffee
Created February 13, 2012 23:12 — forked from geddski/nesting.js
Helper function for nesting Backbone collections (CoffeeScript version)
Backbone.Model::nestCollection = (attributeName, nestedCollection) ->
#setup nested references
for item, i in nestedCollection
@attributes[attributeName][i] = nestedCollection.at(i).attributes
#create empty arrays if none
nestedCollection.bind 'add', (initiative) =>
if !@get(attributeName)
@attributes[attributeName] = []
@get(attributeName).push(initiative.attributes)
@lagartoflojo
lagartoflojo / Bio.markdown
Created August 24, 2011 19:12
Bio para Ataxic

Hernán empezó a los 16 años a crear sus propias páginas web para entretenerse y por trabajo. En ese entonces, Geocities y Tripod la llevaban, toda página debía tener una intro en Flash (si tenía sonido, mejor aún), y todo webmaster que se respetara diseñaba para Internet Explorer 4.0.

Una vez en la universidad, Hernán descubrió, en su temprana versión 1.2, la plataforma Ruby on Rails para la rápida creación de aplicaciones web, y ha dedicado una gran parte de su tiempo libre en perfeccionarse en su uso. Desde entonces, ha desarrollado sitios para tiendas de música (Billboard.cl y Musicland.cl), para una empresa de telecomunicaciones (GTD Manquehue), para una startup (Agendy.com), y para una empresa de asesoría en innovación e incubadora (DictUC).

Actualmente, Hernán está elaborando su memoria, en la cual aplica las últimas tecnologías web en crear una aplicación para el ámbito de la educación y diseñada para dispositivos móviles.