Skip to content

Instantly share code, notes, and snippets.

Daniel Cadenas dcadenas

View GitHub Profile
View keybase.md

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 Oct 22, 2016
Testing rawgit
View ajaxtest.js
(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 Apr 26, 2016
Generador de excusas para bash
View excusa
#!/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 Feb 12, 2016
How to find origin of current running threads
View threads.rb
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 Jun 6, 2015
Shows ENV vars in the Rails app that can't be found in the heroku config
View missing_heroku_config_vars
#!/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() {
View capybara_cheatsheet.rb
### 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')
View tunnel
#!/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 Jul 23, 2014
A directive to deal with angular's problem when using $location and anchor links
View gist:566434ba0af9f3eabb07
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 Feb 19, 2014
Git + pivotal tooling
View gist:9102336
#!/bin/env bash
# ~/bin/githelpers
pivotal_commit() {
git commit -m "$@ [#$GIT_PIVOTAL_NUM]"
}
pivotal_commit_and_finish() {
git commit -m "$@ [Finishes #$GIT_PIVOTAL_NUM]"
}
View gist:7312639
SomeComponent {
background-color: red;
SomeComponent-someDescendant {
width: 100%;
}
}
SomeComponent-someDescendant {
background-color: white;
You can’t perform that action at this time.