Skip to content

Instantly share code, notes, and snippets.

View seifip's full-sized avatar
🧪
Working on colabra.app

Philip Seifi seifip

🧪
Working on colabra.app
View GitHub Profile
Verifying that +seifip is my blockchain ID. https://onename.com/seifip
@seifip
seifip / count_words.py
Created August 11, 2017 15:13 — forked from bradmontgomery/count_words.py
playing with python's `collections.Counter`
"""
Use a Counter to find the most common words in "The Wonderful Wizard of Oz" by
L. Frank Baum.
Available in plain text at:
https://ia700500.us.archive.org/2/items/thewonderfulwiza00055gut/wizoz10.txt
short link: http://bit.ly/thewonderfulwizard
Note: This code also counts the words in the header, so it's not a *realistic*
const x = 0.2 + 0.1;
// ↪ 0.30000000000000004
CREATE OR REPLACE FUNCTION test_float()
RETURNS float AS $$
DECLARE
price float = 0.0;
BEGIN
WHILE price < 10.0 LOOP
price = price + 0.1;
END LOOP;
RETURN price;
END;
const x = 0.2 + 0.1;
// ↪ 0.30000000000000004
CREATE OR REPLACE FUNCTION test_float()
RETURNS float AS $$
DECLARE
price float = 0.0;
BEGIN
WHILE price < 10.0 LOOP
price = price + 0.1;
END LOOP;
RETURN price;
CREATE OR REPLACE FUNCTION test_float()
RETURNS float AS $$
DECLARE
price float = 0.0;
BEGIN
WHILE price < 10.0 LOOP
price = price + 0.1;
END LOOP;
RETURN price;
CREATE OR REPLACE FUNCTION test_numeric()
RETURNS numeric(3, 1) AS $$
DECLARE
price numeric(3, 1) = 0.0;
BEGIN
WHILE price < 10.0 LOOP
price = price + 0.1;
END LOOP;
RETURN price;
INSERT INTO items VALUES ('¥999');
-- ERROR: 22P02: invalid input syntax for type money: "¥999"
-- total_price | quantity
-- ::money | ::integer
-- ----------------------------
-- $3.50 | 4
SELECT price::numeric / quantity FROM items;
-- $0.87
SELECT price::numeric / quantity;
-- 0.87500000000000000000