Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'rest-client'
require 'xmlsimple'
require 'net/http'
require 'crack'
class Resource
TOKEN = "poner_token_aqui"
BASE_URL = "http://api.umov.me/CenterWeb/api/#{TOKEN}"
@MrCoffey
MrCoffey / countries_information.json
Created June 12, 2015 17:21
Parse a json file with extra data into a new file containing only required data
[
{
"name": {
"common": "Aruba",
"official": "Aruba",
"native": {
"nld": {
"official": "Aruba",
"common": "Aruba"
},
@MrCoffey
MrCoffey / using_whenever.md
Last active January 23, 2021 04:38
Usando whenever con rake

CREANDO TAREAS CON WHENEVER Y RAKE

Es posible que en algún momento lleguemos a necesitar que alguna tarea deba ser ejecutada cada cierto tiempo en estos trabajos se conocen como cronjobs.

En este breve ejemplo exploramos como implementarlos en una applicación de Ruby On Rails, por ejemplo en uno de nuestros tutoriales explicábamos como enviar correos a todos nuestros usuarios con la ayuda de rake, si bien podemos ejecutarla nosotros mismos, sería mucho mejor si alguien hiciera ese trabajo por nosotros. Bueno para esto existe Whenever una gema que nos permite programar tareas haciendo uso de cron log.

La cuestión es que cron, luce así:

SHELL=/bin/bash
CREATE TABLE IF NOT EXISTS `mydb`.`galleta` (
`id` INT NOT NULL COMMENT '',
`name` VARCHAR(45) NULL COMMENT '',
`price` VARCHAR(45) NULL COMMENT '',
PRIMARY KEY (`id`) COMMENT '')
ENGINE = InnoDB
CREATE TABLE IF NOT EXISTS `mydb`.`venta` (
`id` INT NOT NULL COMMENT '',
`total` VARCHAR(45) NULL COMMENT '',
@MrCoffey
MrCoffey / product-hunter.coffee
Created August 27, 2015 20:25
Product hunter
Slack = require('slack-node')
os = require('os')
jsonHttp = require('json-http')
#Slack stuff
webhookUri = 'https://hooks.slack.com/services/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'
slack = new Slack
slack.setWebhook webhookUri
#Kimono uri
@MrCoffey
MrCoffey / deployment.md
Last active September 20, 2015 19:38
Descripcion de como hacer el deploy en servidores remotos

Guia de deployment

`cd /home/toor/apps/sercappital-odd/releases/20150920183427

Paso 1 - Conexion al servidor remoto

La conexion debe efectuarse, via SSH proveida por el administrador del servidor, por medio del siguiente comando.

  $ ssh -i ruta_a_la_llave -p puerto usuario@ip
@MrCoffey
MrCoffey / gist:3a6fe552364a2bab9c95
Created January 24, 2016 16:54 — forked from learncodeacademy/gist:5850f394342a5bfdbfa4
SSH Basics - Getting started with Linux Server Administration

###SSH into a remote machine###

ssh [email protected]
#or by ip address
ssh [email protected]

exit: exit ###Install Something###

#If it's a new server, update apt-get first thing
@MrCoffey
MrCoffey / generateDFP.js
Last active February 3, 2016 22:46
Codigo de credibanco para Generar FingerPrint
var InvocarDFP, initDFP;
InvocarDFP = function(e, t, n) {
var a, f, l, o, str, u;
console.log('https://h.online-metrix.net/fp/clear.png?org_id=' + n + '&session_id=' + t + e + '&m=1');
o = document.createElement('p');
str = 'background:url(\'https://h.online-metrix.net/fp/clear.png?org_id=\'' + n + '&session_id=' + t + e + '&m=1)';
o.styleSheets = str;
o.height = '0';
o.width = '0';
"{\"status\":500,\"body\":\"\\n\\u003c!DOCTYPE html\\u003e\\n\\u003c!--[if lt IE 7 ]\\u003e \\u003chtml lang=\\\"en\\\" class=\\\"no-js ie6\\\"\\u003e \\u003c![endif]--\\u003e\\n\\u003c!--[if IE 7 ]\\u003e \\u003chtml lang=\\\"en\\\" class=\\\"no-js ie7\\\"\\u003e \\u003c![endif]--\\u003e\\n\\u003c!--[if IE 8 ]\\u003e \\u003chtml lang=\\\"en\\\" class=\\\"no-js ie8\\\"\\u003e \\u003c![endif]--\\u003e\\n\\u003c!--[if IE 9 ]\\u003e \\u003chtml lang=\\\"en\\\" class=\\\"no-js ie9\\\"\\u003e \\u003c![endif]--\\u003e\\n\\u003c!--[if (gt IE 9)|!(IE)]\\u003e\\u003c!--\\u003e \\u003chtml lang=\\\"en\\\" class=\\\"no-js\\\"\\u003e\\u003c!--\\u003c![endif]--\\u003e\\n\\u003chtml\\u003e\\n\\u003chead\\u003e\\n \\u003ctitle\\u003eError\\u003c/title\\u003e\\n \\u003cmeta charset=\\\"utf-8\\\"\\u003e\\n \\u003cmeta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=UTF-8\\\"\\u003e\\n \\u003cmeta http-equiv=\\\"X-UA-Compatible\\\" content=\\\"IE=edge,chrome=1\\\"\\u003e\\n \\u003cmeta na
@MrCoffey
MrCoffey / ways_to_use_vcr.rb
Created February 19, 2016 21:27 — forked from myronmarston/ways_to_use_vcr.rb
Ways to use VCR for a request made by a let block
# 1) Use VCR.use_cassette in your let block. This will use
# the cassette just for requests made by creating bar, not
# for anything else in your test.
let(:foo) { VCR.use_cassette("foo") { create(:bar) } }
it "uses foo" do
foo
end
# 2) Wrap the it block that uses #foo in VCR.use_cassette.