Skip to content

Instantly share code, notes, and snippets.

View leocabeza's full-sized avatar

Leonardo Cabeza leocabeza

View GitHub Profile
@leocabeza
leocabeza / response.json
Created April 11, 2023 02:20
@prometeoapi/v1.0#2w61u1blfv5g40m
{
"openapi": "3.1.0",
"info": {
"title": "Prometeo API",
"description": "Endpoints para la api bancaria de Prometeo",
"contact": {
"name": "Prometeo",
"url": "https://prometeoapi.com",
"email": "[email protected]"
},
@leocabeza
leocabeza / objeto.js
Created June 20, 2019 04:32
objeto en javascript
// ejemplo variable
const miConejo = 'Mabel mi negra hermosa <3';
// pero, ¿que pasa si queremos tener más información de nuestro conejito, podríamos hacer:
const miConejoNombre = 'Mabel mi negra hermosa <3'
const miConejoEdad = '8 meses';
const miConejoEsElQueManda = true;
import React from 'react';
const OrderDetail = (props) => {
return (
<li id={props.id}>{props.name}</li>
);
};
OrderDetail.propTypes = {
id: React.PropTypes.number.isRequired,
@leocabeza
leocabeza / my_flatten.rb
Created January 3, 2017 20:03
My own implementation of Ruby's Array flatten
# gem install minitest
require 'minitest/autorun'
# We are modifying the array class to
# implement our own flatten method,
# being careful not to override existing ones
class Array
def my_flatten(tmp = [])
# self.each is assumed by ruby
@leocabeza
leocabeza / exercise
Created December 2, 2016 17:41
codewars
Description:
The test fixture I use for this kata is pre-populated.
It will compare your guess to a random number generated in Ruby by:
(Kernel::rand() * 100 + 1).floor
In Javascript/CoffeeScript by:
Math.floor(Math.random() * 100 + 1)
module Test
def say_hi
p 'say hi'
end
end
class A
include Test
def self.hi
@leocabeza
leocabeza / test.js
Last active September 27, 2016 13:40
Mocha async testing
var assert = require('chai').expect;
var bot = new Bot('TOKEN', {polling: true});
/* ¿cómo hago la prueba, si no puedo simular el evento onMessage? */
bot.onMessage(function(msg) {
console.log('hey there, this is msg: ', msg);
});
it('should receive a valid msg', function(done) {
@leocabeza
leocabeza / flatten.js
Created August 4, 2016 13:32
Javascript function for flattening an angular object
function flatten(ob) {
var toReturn = {};
var regExp = /^\$/i;
for (var i in ob) {
if (!ob.hasOwnProperty(i) || i.match(regExp)) {
console.log('ignoring...', i);
continue;
}
if ((typeof ob[i]) === 'object') {
var flatObject = flatten(ob[i]);
"{\"Error\":\"0\",\"Time\":0.0081,\"Total\":\"425\",\"Page\":1,\"Books\":[{\"ID\":3768861630,\"Title\":\"Ruby Quick Syntax Reference\",\"Description\":\"Ruby Quick Syntax Reference is a condensed code and syntax reference to the Ruby scripting language. It presents the essential Ruby syntax in a well-organized format that can be used as a handy reference.nnYou won't find any technical jargon, bloat ...\",\"Image\":\"http://s.it-ebooks-api.info/6/ruby_quick_syntax_reference.jpg\",\"isbn\":\"9781430265689\"},{\"ID\":438379079,\"Title\":\"grep Pocket Reference\",\"SubTitle\":\"A quick pocket reference for a utility every Unix user needs\",\"Description\":\"grep Pocket Reference is the first guide devoted to grep, the powerful Unix content-location utility. This handy book is ideal for system administrators, security professionals, developers, and others who want to learn more about grep and take new ap ...\",\"Image\":\"http://s.it-ebooks-api.info/3/grep_pocket_reference.jpg\",\"isbn\":\"9780596153601\"},{\"ID\"
/home/leonardo/.rvm/gems/ruby-2.3.0/gems/json-2.0.1/lib/json/common.rb:156:in `parse': 409: unexpected token at '{"ID":1820761299,"Title":"jQuery Pocket Reference","SubTitle":"Read Less, Learn More","Description":"jQuery is the "write less, do more" JavaScript library. Its powerful features and ease of use have made it the most popular client-side JavaScript framework for the Web. This book is jQuery's trusty companion: the definitive "read less, learn more" g ...","Image":"http://s.it-ebooks-api.info/3/jquery_pocket_reference.jpg","isbn":"9781449397227"},{"ID":2071984142,"Title":"XML Pocket Reference, 3rd Edition","Description":"A perennial bestseller, the handy XML Pocket Reference from O'Reilly has been revised once again to give you quick access to the latest goods. In addition to its comprehensive look at XML, this third edition has been updated with new material on Nam ...","Image":"http://s.it-ebooks-api.info/3/xml_pocket_reference_third_edition.jpg","isbn":"9780596100506"},{"ID":1842882902,"Title":"W