Skip to content

Instantly share code, notes, and snippets.

View dcadenas's full-sized avatar

Daniel Cadenas dcadenas

View GitHub Profile

Keybase proof

I hereby claim:

  • I am dcadenas on github.
  • I am dcadenas (https://keybase.io/dcadenas) on keybase.
  • I have a public key ASAZotTtny79SxzwfBbCE4ST3pl63YtUo3Pnj5oOpOj32go

To claim this, I am signing this object:

@dcadenas
dcadenas / ajaxtest.js
Last active October 22, 2016 02:41
Testing rawgit
(function(){
var url = 'https://api.ipify.org/?format=json';
var createCORSRequest = function(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
@dcadenas
dcadenas / excusa
Created April 26, 2016 21:52
Generador de excusas para bash
#!/usr/bin/env bash
a=(
'En cuanto arreglemos el goteo de recursos'
'En cuanto completemos las pruebas'
'En cuanto hayamos optimizado el código'
'Apenas nos arreglen el bug'
'Cuando se solvente el problema de instalación'
'Cuando averiguemos por qué se cae el proceso'
'Cuando hayamos mejorado el rendimiento'
'En cuanto completemos la restauración'
@dcadenas
dcadenas / threads.rb
Last active February 12, 2016 14:41
How to find origin of current running threads
require 'objspace'
ObjectSpace.trace_object_allocations_start
def all_child_threads
Thread.list - [Thread.current]
end
trap(:INFO) {
puts "#" * 90
all_child_threads.each do |t|
@dcadenas
dcadenas / missing_heroku_config_vars
Created June 6, 2015 01:37
Shows ENV vars in the Rails app that can't be found in the heroku config
#!/bin/bash
echo "These ENV variables only exist in the rails app but not in the heroku config"
echo
envs_in_rails() {
git grep "ENV\[" | sed "s/.*ENV\[['\"]\(.*\)['\"]\].*/\1/" | sort | uniq
}
envs_in_heroku() {
@dcadenas
dcadenas / capybara_cheatsheet.rb
Created November 6, 2014 13:49
Capybara Cheatsheet
### Navigating
visit('/projects')
visit(post_comments_path(post))
### Clicking links and buttons
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click_on('Link Text') # clicks on either links or buttons
click_on('Button Value')
#!/usr/bin/env bash
[[ $# -gt 0 ]] || { echo "Usage: $(basename $0) remoteport localport"; exit 1; }
autossh -M 0 -v -nNT4 -o "TCPKeepAlive no" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 1" -o "ExitOnForwardFailure yes" -R $1:localhost:$2 vps
@dcadenas
dcadenas / gist:566434ba0af9f3eabb07
Created July 23, 2014 21:10
A directive to deal with angular's problem when using $location and anchor links
myApp = angular.module('myApp')
#Ensures that:
# 1) all links contained in the directive's element that are not handled
# by angular do a full page reload bypassing html5mode.
# 2) all anchor links are prefixed with the current url so that the base
# path doesn't interfere
myApp.directive 'externalLinks', ->
link: (scope, element, attrs, controller) ->
@dcadenas
dcadenas / gist:9102336
Created February 19, 2014 21:45
Git + pivotal tooling
#!/bin/env bash
# ~/bin/githelpers
pivotal_commit() {
git commit -m "$@ [#$GIT_PIVOTAL_NUM]"
}
pivotal_commit_and_finish() {
git commit -m "$@ [Finishes #$GIT_PIVOTAL_NUM]"
}
SomeComponent {
background-color: red;
SomeComponent-someDescendant {
width: 100%;
}
}
SomeComponent-someDescendant {
background-color: white;