Skip to content

Instantly share code, notes, and snippets.

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');
@d2bit
d2bit / ultimate-ut-cheat-sheet.md
Created April 16, 2018 15:01 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@d2bit
d2bit / jsonp.js
Created May 24, 2017 17:09
JSONP
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]
}
// `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);
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.
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."
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class Calculator extends Component {
render() {
return (
<div className="Calculator">
</div>
);
class User
def greet
'outside'
end
end
module A
class User
def greet
'inside'
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)
#!/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: