using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select pg_class.relname::text as table_name, pg_attribute.attname::text as column_name, pg_type.typname::text as column_type | |
from pg_attribute | |
join pg_class on pg_class.oid = pg_attribute.attrelid | |
join pg_type on pg_type.oid = pg_attribute.atttypid | |
where column_name not in ('ctid', 'oid', 'xmin', 'cmin', 'xmax', 'cmax', 'tableoid', 'insertxid', 'deletexid'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jsonp(url, cb) { | |
const randomString = () => | |
Math.random().toString(36).substring(2, 15) | |
const script = document.createElement('script') | |
const fn = randomString() | |
window[fn] = res => { | |
cb(res) | |
delete window[fn] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `byId` reducer | |
// ramda | |
return merge(state, { [payload.id]: payload }); | |
// pure ES6 | |
return Object.assign({}, state, { [payload.id]: payload }; | |
// pure ES7 | |
return { ...state, [payload.id]: payload }; | |
// ramda | |
return dissoc(payload.id, state); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imagina que estamos implementando una tienda online, que vende solo 3 productos: | |
Codigo | Nombre | Precio | |
_______________________________ | |
AM | Agua mineral | 3.11€ | |
AC | Aceite | 5.00€ | |
CA | Cafe | 11.23€ | |
El departamento de marketing es fan de las promociones de tipo 2x1 (si compras dos productos iguales, uno de ellos es gratis). Y quiere que haya un descuento de este tipo en Agua mineral. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('99 Bottles',function(){ | |
it('shows have X bottles',function() { | |
result = Bottles.print(99); | |
expected_result = "99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall." | |
expect(result).toBe(expected_result); | |
}); | |
it('shows have 2 bottles',function() { | |
result = Bottles.print(2); | |
expected_result = "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
class Calculator extends Component { | |
render() { | |
return ( | |
<div className="Calculator"> | |
</div> | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
def greet | |
'outside' | |
end | |
end | |
module A | |
class User | |
def greet | |
'inside' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EquilibriumPoint | |
ERROR_CODE = -1 | |
def initialize(arr) | |
@arr = arr | |
end | |
def get_point | |
indexes_without_edges.each do |index| | |
return index if equilibrium_point?(index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# | |
# LearnRubyByExample: | |
# | |
# Ruby is a highly expressive programming language. | |
# Testing software is an expressive way to communicate how it works. | |
# | |
# In the middle of a night awake for allergy and insomnia, and some days after the 1st _why day, | |
# I've tried to combine Ruby and testing to help teaching ruby with some goals in mind: |
NewerOlder