Skip to content

Instantly share code, notes, and snippets.

View carlosble's full-sized avatar

Carlos Ble carlosble

View GitHub Profile
@carlosble
carlosble / cards.py
Created July 7, 2020 18:49
Cards game
def who_wins(cards_player1, cards_player2):
ranking = {
'2': 2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
'8': 8,
'9': 9,
@carlosble
carlosble / tests.py
Created July 7, 2020 15:49
String calculator tests
import unittest
# TDD - Test-driven development. ->
# BDD - Behaviour driven development - Outside-in TDD - Mocks
# Inside-out TDD VS Outside-in TDD
# Paso 1: Definir una buena lista de requisitos - Piensa primero cobarde.
##
# Design principles: Less Astonishment/Surprise Principle
@carlosble
carlosble / kata.py
Created July 7, 2020 15:48
String calculator Kata 2
import re
def sum_numbers_in(expression: str) -> int:
if expression is None or expression == "":
return 0
if "," in expression:
tokens = expression.split(',')
total = 0
for token in tokens:
@carlosble
carlosble / kata.py
Created July 6, 2020 18:57
string calculator kata python
def sum_numbers_in(expression: str) -> int:
if expression is None or expression == "":
return 0
if "," in expression:
tokens = expression.split(',')
return int(tokens[0]) + int(tokens[1])
return int(expression)
class StringCalculatorTests(unittest.TestCase):
@carlosble
carlosble / metaprogramming.cs
Created June 22, 2020 14:01
Decorator pattern and metaprogramming with C#
using System;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
namespace Metaprogramming
{
enum Role
{
admin,
@carlosble
carlosble / jsdaycan2017_js_engancha_resumen.md
Last active April 7, 2020 22:08
Por que JavaScript engancha, #JSDayCAN2017
  • Historia:

    • Eich escribió el primer prototipo de JS en 10 dias en Mayo de 1995
    • Creado en poco tiempo, sin restricciones, como en Java las Checked Exceptions o en C# los metodos finales.
    • JavaScript Jabber Podcast con Brendan Eich: https://devchat.tv/js-jabber/124-jsj-the-origin-of-javascript-with-brendan-eich
    • Aprender JavaScript me obligó a estudiar. Kudos a Pasku por la cantidad de recursos que me pasó.
    • Scheme: Higher-order functions o functors, lexical scoping
    • Lo mejor es su flexibilidad, es multiparadigma
  • Douglas Crockford Lectures on JavasScript:

<div id="cards-gui-container">
<label for="deck1">Deck1:</label>
<input id="deck1"/>
<br>
<label for="deck2">Deck2:</label>
<input id="deck2"/>
<input id="whoWinsButton" type="button" value="Who wins?"/>
<br>
<label id="result">The winner is...</label>
@carlosble
carlosble / tests.js
Created June 7, 2017 22:08
Eventually expect
it ('populates store with data returned from server', (done) => {
stubApiClientToReturn({username: 'carlos'});
simulateSearchFormSubmit({username: 'car'});
expectStoredUsersToContainUsername('carlos', done);
});
function expectStoredUsersToContainUsername(username, done){
store.subscribe(eventuallyExpect(() => {
export const createPage = (serverApi, mapState) => {
return connect(
(state) => {
let mapping = {
report: state.report
};
if (typeof(mapState) === 'function'){
return Object.assign(mapping, mapState(state));
}
return mapping;
@carlosble
carlosble / tests.js
Last active June 7, 2017 22:06
Simulating changes in location
let stubApi = {};
let store;
let stubRouter = {
location: {
search: '',
query: {
toDay: '',
fromDay: ''
}
},