Skip to content

Instantly share code, notes, and snippets.

View jgermade's full-sized avatar
🎨
Working from home

Jesús Germade jgermade

🎨
Working from home
View GitHub Profile
@jgermade
jgermade / parse_yaml.sh
Last active August 9, 2016 22:13 — forked from pkuczynski/LICENSE
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@jgermade
jgermade / atom-custom-style.less
Created October 8, 2015 13:57
Atom - Custom style
atom-text-editor, :host {
background-color: #000000;
}
// style the background color of the tree view
.tree-view {
// background-color: whitesmoke;
font-size: 1.3rem;
font-family: monospace;
}
@jgermade
jgermade / angular-web-component.js
Last active January 31, 2017 14:38
web components playground
angular.module('web.components', []).factory('webComponent', function ($templateCache, $compile) {
function getAttributes (element) {
var $attrs = {}, attrs = element.attributes;
for( var i = 0, len = attrs.length; i < len ; i++ ) {
$attrs[attrs[i].name.replace(/([a-z])-([a-z])/, function (match, a, z) {
return a + z.toUpperCase();
})] = attrs[i].value;
}
return $attrs;
@jgermade
jgermade / alias.sh
Last active July 11, 2022 01:36
sh
alias ll='ls -alF'
alias l='ls -alF'
alias c='clear'
alias .='echo $PWD'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
@jgermade
jgermade / checkout.json
Last active February 21, 2017 12:22
checkout.json
{
"toc": true,
"merchant": {
"confirmation_url": "https://demo.aplazame.com/confirm",
"cancel_url": "/demo-cancel.html",
"success_url": "/demo-success.html"
},
"customer": {
"id": "140",
"email": "[email protected]",
@jgermade
jgermade / get-toolbox.sh
Created August 2, 2016 16:25 — forked from jacobtomlinson/get-toolbox.sh
Docker toolbox for linux
#!/bin/bash
# A quick script to install Docker Engine and Compose
# Run with sudo
# Install Docker Engine
curl -sSL https://get.docker.com/ | sh
# Start Docker
# TODO update to handle multiple distros
service docker start
<?php
// si tienes instalado php-curl, puedes usar la siguente función:
function authorize_order ($aplazame_private_key, $order_id, $is_production = false) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.aplazame.com/orders/$order_id/authorize");
curl_setopt($ch, CURLOPT_POST, true);
// curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
// esto es para no incluir la cabecera de la respuesta
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if(request.readyState === 4) {
if(request.status === 200) {
console.log(request.responseText);
} else {
console.error(request.status, request.statusText, request.responseText);
}
}
@jgermade
jgermade / once.js
Last active November 22, 2016 20:05
function once (fn) {
var result;
return function () {
if( fn ) {
result = fn.apply(this, arguments);
fn = null;
}
return result;
};
}