DevHeads.net

Postings by Gerald Bauer

Ruby Quiz - New "Front End" Website (Pages) @ https://planetruby.github.io/quiz

Hello,

For easy reference (and for your information) - the "back end"
ruby quiz pages in the github repo now also get published (rendered)
on the "front end" thanks to jekyll (and github pages).

See <a href="https://planetruby.github.io/quiz" title="https://planetruby.github.io/quiz">https://planetruby.github.io/quiz</a> for "easy-to-read" pages using
the default primer theme.

Cheers. Prost.

PS: All quizzes are still open - send in your code snippets :-) or
questions and comments for public dicussions.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

Ruby Quiz - Challenge #5 - Crypto Mining - Find the Winning Lucky Number - Nonce (=Number used ONCE) for the Proof-of-Work (PoW) Hash (SHA-256)

Hello,

It's Friday. Ruby Quiz time! Join us. Let's keep going with a new
Ruby Quiz [1] every Friday.
Here we go:

Challenge #5 -Crypto Mining - Find the Winning Lucky Number - Nonce
(=Number used ONCE) for the Proof-of-Work (PoW) Hash (SHA-256)

Let's find the the winning lucky lumber, that is, nonce (=Number used ONCE)
for the proof-of-work (PoW) hash using SHA-256.

Aside: What's a (Crypto) Hash?

Classic Bitcoin uses the SHA256 hash algorithm.

Ruby Conferences ‘n’ Camps in 2019 - What’s Upcoming? Anything Missing? (Please Tell)

Hello,

Over at planet ruby - we try the second year running put together a
"definitive" world wide ruby conferences & camps calendar for 2019 [1]
(see 2018 [2] for what happened this year :-) for all to use and
share.

If any ruby conference or camp is missing, let us know here (or
better edit the datafile in yaml [3] on github :-)). Yes, the calendar
page is built with ruby (and jekyll and friends) and all is open
source and dedicated to the public domain (that is, no rights
reserved; use as you please etc.)

Cheers.

Ruby Quiz - Challenge #4 - Turn Humanitarian eXchange Language (HXL) Tabular Records into Named Tuples

Hello,

Let's honor the tradition and post a new Ruby Quiz [1] every Friday.
Here we go:

Challenge #4 - Turn Humanitarian eXchange Language (HXL) Tabular
Records into Named Tuples

Let's turn tabular data using the Humanitarian eXchange Language (HXL)
hashtag convention from array of array of strings
to array of named tuples (also known as hash dictionaries).

Aside: What's Humanitarian eXchange Language (HXL)?

Humanitarian eXchange Language (HXL) [2]
is a (meta data) convention for
adding agreed on hashtags e.g.

csvhuman v0.1 - read tabular data in the CSV Humanitarian eXchange Language (HXL) format

Hello,

I've put together a first version of the csvhuman library / gem [1] that
adds support for the Humanitarian eXchange Language (HXL) to ruby
and lets you read tabular data in the
comma-separated values (CSV) with Humanitarian eXchange Language
(HXL) [2] hashtags format.

Questions and comments welcome.

[1] <a href="https://github.com/csvreader/csvhuman" title="https://github.com/csvreader/csvhuman">https://github.com/csvreader/csvhuman</a>
[2] <a href="https://github.com/csvspecs/csv-hxl" title="https://github.com/csvspecs/csv-hxl">https://github.com/csvspecs/csv-hxl</a>

Cheers.

record library / gem v1.2 - named tuples / records with typed structs / schemas

Hello,

I've updated the (new) record library / gem [1] that lets you define
named tuples / records with typed structs / schemas. How?

Step 1: Define a (typed) struct for your records / named tuples.

Ruby Quiz - Challenge #3 - Read the English Premier League (EPL) Standings Table from a Web Page

Hello,

Let's honor the tradition and post a new Ruby Quiz [1] every Friday.
Here we go:

Challenge #3 - Read the English Premier League (EPL) Standings Table
from a Web Page [2]

Let's read the English Premier League (EPL) Standings Table
from a web page.

Ruby Quiz Adopts Code of Conduct - Be A Mensch.

Hello,

To help build a strong and welcoming community the (new) Ruby Quiz
[1] has adopted a code of conduct [2].

Happy ruby quiz time. Be a mensch. Cheers. Prost.

[1] <a href="https://github.com/planetruby/quiz" title="https://github.com/planetruby/quiz">https://github.com/planetruby/quiz</a>
[2] <a href="https://github.com/planetruby/quiz/blob/master/CODE_OF_CONDUCT.md" title="https://github.com/planetruby/quiz/blob/master/CODE_OF_CONDUCT.md">https://github.com/planetruby/quiz/blob/master/CODE_OF_CONDUCT.md</a>

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

Ruby Quiz #1 - Bonus - Three More Difficulty Levels (2, 3, 4) - Commas Inside Quotes and Double Up Quotes in Quotes, ...

Hello,

Thanks for the first three entries - all passing the level 1 test. Yay!

If that was too easy :-) I added three more difficulty levels
to the challenge.[1]
.

### Level 2 - Commas Inside Quotes and Double Up Quotes in Quotes

Let's turn Shakespeare's "literal" Hamlet quote:

```
Hamlet says, "Seems," madam! Nay it is; I know not "seems."
```

into

```
1, "Hamlet says, ""Seems,"" madam! Nay it is; I know not ""seems."""
```

And the test reads:

``` ruby
def test_parse_level2
records = [["1", "Hamlet says, \"Seems,\" madam!

Why the CSV standard library is broken (and how to fix it) Part VII or What's Your Type? Guess. Again. And Again. And Again. Guess What's a Schema For?

Hello,

I've written a new (and sevenths) episode on why the CSV standard
library is broken (and how to fix it).

The heart of the CSV standard library is the String#split kludge.

What else is dangerously simplistic and naive?

Let's have a look at the built-in type conversion [1].
Will it surprise you? Yes, it is broken, broken, broken. How? Why?

Questions and comments welcome. Cheers.

Ruby Quiz - Challenge #2 - Calculate the Bitcoin Genesis Block Hash (SHA-256)

Hello,

To kick start the new Ruby Quiz let's add another "real world" puzzle.

Challenge #2 - Calculate the Bitcoin Genesis Block Hash (SHA-256)

Let's calculate the classic bitcoin (crypto) block hash from scratch (zero).
Let's start with the genesis block, that is block #0
with the unique block hash id
`000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f`.

Note: You can search and browse bitcoin blocks using (online)
block explorers.

Why the CSV library is broken (Part VI) - or Fixes in Alternative CSV Libraries or Fast, Faster, Fasterer, Fastest

Hello,

I've written a new (and sixth) episode on why the CSV standard
library is broken (and how to fix it). Let's have a look at fixes
in alternative CSV libraries out there. [1]

The alternative listed are just a start - there are many more.
Any great alternative CSV libaries missing? Please, tell.

Also reprinted from the article (another) classic:

Unfortunately, the csv library is a dead horse.

Ruby Code Quiz - How can I parse quoted values with String#split?

Hello,

can anyone help out. I cannot get this to work.
I try to parse the line ‹"1", "2" , "3"›.
Ideally single or double quotes don't matter ‹"1", '2' , "3"›.

Any insight appreciated. Cheers. Prost.

The code:

parts = parse.split(@col_sep_split_separator, -1)
if parts.empty?
if in_extended_col
csv[-1] << @col_sep # will be replaced with a @row_sep
after the parts.each loop
else
csv << nil
end
end

# This loop is the hot path of csv parsing. Some things may be non-dry
# for a reason.

Why the CSV standard library is broken (and how to fix it), Part V or Escaping the Stray Quote Error Hell - Do You Want Single, Double, or French Quotes With That Comma?

Hello,

I've written a new (and fifth) episode on why the CSV standard
library is broken
(and how to fix it).

Let's have a look at quotes and leading and trailing spaces. The
episode is titled "Escaping the Stray Quote Error Hell - Do You Want
Single, Double, or French Quotes With That Comma?" [1]

Questions and comments welcome. Cheers.

Vienna.rb Talk Notes: Mining for Gold Using the World's #1 and Most Popular Data Format (w/ Ruby and CsvReader)

Hello,

the talk notes from yesterday's Vienna.rb meetup titled Mining for
Gold Using the World's #1 and Most Popular Data Format (w/ Ruby and
CsvReader) [1].

tabreader library / gem v1.0 - read in tabular datafiles in text in the tabular (TAB) format

Hello,

I've published the tabreader library / gem version 1.0 [1]
that lets you read in tabular datafiles in text in the tabular (TAB) format.

Yes, it's as simple as:

line = "1\t2\t3"
values = line.split( "\t" )
pp values
# => ["1","2","3"]

or the "magic" packaged up in `TabReader`:

line = "1\t2\t3"
values = Tab.parse_line( line ) ## or TAB.parse_line or
TabReader.parse_line
pp values
# => ["1","2","3"]

or use the convenience helpers:

txt <<=TXT
1\t2\t3
4\t5\t6
TXT

records = Tab.parse( txt ) ## or TAB.parse or TabReader.pars

csvjson library / gem v1.0 - read tabular data in the CSV <3 JSON format, that is, comma-separated values CSV (line-by-line) records with JSON encoding rules

Hello,

I've published a new library / gem, that is, csvjon that lets you
read tabular data in the (new) CSV <3 JSON format, that is,
comma-separated values CSV (line-by-line) records with javascript
object notation (JSON) encoding rules.

What's CSV <3 JSON?

CSV <3 JSON is a Comma-Separated Values (CSV)
variant / format / dialect
where the line-by-line records follow the
JavaScript Object Notation (JSON) encoding rules.
It's a modern (simple) tabular data format that
includes arrays, numbers, booleans, nulls, nested structures, comments and more.
Example:

# "Vanilla" CSV <3 JSON

Why the standard CSV library author deserves our hugs and thank yous

Hello,

I’ve written a new episode in the why the csv standard library is
broken, broken, broken (and how to fix it).

It’s a new introduction to the series titled “I apologize - Sorry,
Sorry, Sorry.” [1] to clarify that I am in no way blaming the author
(really I’m blaming YOU :-), that is, all the free-loaders waiting for
a miracle.

The author or the authors of the standard CSV library deserve our
hugs and thank yous for the great work and many hours (for sure many
unpaid and volunteered) put into the CSV library. We are all standing
on the shoulders of giants. Thank you.

Why the CSV standard library is broken (and how to fix it), Part IV or Numerics a.k.a. Auto-Magic Type Inference for Strings and Numbers?

Hello,

I've written a new (and fourth) episode on why the CSV standard library is
broken, broken, broken (and how to fix it).

Let's have a look at numerics a.k.a. auto-magic type inference for
strings and numbers [1].

Here's the challenge for the standard csv library.
Let's read data.csv:

1,2,3
"4","5","6"

Using these popular two rules (bonus for NaNs - not a number).

Rule 1: Use "un-quoted" values for float numbers e.g. 1,2,3 or 1.0,
2.0, 3.0 etc.

Rule 2: Use quoted values for "non-numeric" strings e.g.

csvreader v1.0 - read tabular comma-separated values (csv) the right way (incl. hash readers, converters, enumerables, dialects, and more)

Hello,

I've uploaded [version 1.0 of the new comma-separated values
csvreader library / gem [1] that lets you read tabular data in the
comma-separated values (csv) format the right way :-), that is, the
basic methods such as `Csv.read `or `CsvHash.read` use best practices
out-of-the-box with zero-configuration.

Under the hood the new library includes purpose-built "backend"
parsers (e.g.

Glim - A new faster jekyll website compiler clone / alternative (in ~3000 lines of ruby)

Hello,

Jekyll not fast enough? Why not build a compatible faster clone /
alternative from scratch / zero (in ruby)? [1] Sounds crazy?

Allan Odgaard (of TextMate fame) has just done it and with about 3
000 lines of ruby code offers even more features than jekyll itself
:-) e.g. built-in tags and categories for collections, lazy evaluation
and parallized builds, better defaults, and much more. Find out more
at the Glim website compiler source project repo [2]

Happy publishing w/ ruby. Cheers. Prost.

PS: By the way - did you know?

Why the CSV standard library is broken (and how to fix it), Part III or Returning a CSV Record as an Array? Hash? Struct? Row?

Hello,

I've written a new (and third) episode [1] in the series
why the CSV standard library is broken, broken, broken (and how to fix it).

Let's have a look at how to handle csv records. How about returning
an array? hash? struct? row? etc.

Or how about adding new "low-level" parsers for supporting more
dialects and formats or for faster code with c-extensions?

Questions and comments welcome. Cheers.

Ruby Conferences & Camps in 2018 Calendar Update @ Planet Ruby - What's Upcoming?

Hello,

I've updated the ruby conferences & camps in 2018 calendar [1].
What's upcoming?

October

- Sat 6 (1d) Ruby Russia @ Moscow, Russia
- Thu+Fri 25+26 (2d) RubyConf Malaysia @ Kuala Lumpur, Malaysia

November

- Fri 9 (1d) Keep Ruby Weird @ Austin, Texas, United States
- Tue-Thu 13-15 (3d) RubyConf @ Los Angeles, California, United States

Any others? Please tell. Cheers.

Why the CSV standard library is broken, broken, broken (and how to fix it), Part II or The Wonders of CSV Formats / Dialects

Hello,

I've written a follow-up [1] on why the CSV standard library is
broken, broken, broken. Let's have a look at the wonders of CSV
formats / dialects
such as MYSQL CSV export or PostgreSQL CSV or TEXT export.

In a nutshell - the standard CSV parser is a (simplistic) kludge
using string.split() and, thus, needs to get replaced with a "real" parser
that can handle more "edge" cases / formats.

Questions and comments welcome.

Also if want to see other CSV formats pre-configured and supported
"out-of-the-box" in the new csv reader, let us know.

Cheers.

kramup / kramdown-service v1.0.0 - Live Markdown Editor and HTTP JSON API w/ Sinatra v2

Hello,

I've updated the kramdown-service / kramup library and tool [1]
that lets you start your own local live markdown editor browser app and
json http api service w/ sinatra v2. Example:

Step 0 - Install the gem e.g.

$ gem install kramdown-service

Step 1 - Start the server / service e.g.

$ kramup

Step 2 - Open up the editor page in your browser e.g. use
`http://localhost:4567`.

That's it.

Enjoy. Cheers. Prost.

PS: Did you know?

EuRuKo (European Ruby Konference) 2018 @ Vienna (Austria) - 24+25th/Aug - Live Stream (Incl. All Talks)

Hello,

FYI: the EuRuKo 2018 just kicked off this morning in Vienna,
Austria. Big thanks to Ramón Huidobro (@SenorHuidobro), Super Princess
Pilar (@Tamacodechi) and the org team for making in happen.

Follow along with the EuRuKo 2018 live stream on YouTube for all
talks the next two days! [1].

Cheers. Prost.

[1] <a href="https://www.youtube.com/watch?v=YhPP_Knq0qM" title="https://www.youtube.com/watch?v=YhPP_Knq0qM">https://www.youtube.com/watch?v=YhPP_Knq0qM</a>

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

Why the CSV standard library is broken, broken, broken (and how to fix it)

Hello,

I’ve written up an article titled “Why the CSV standard library is
broken, broken, broken (and how to fix it)” [1].

Why not let’s make ruby the best it can be for data wrangling -
starting with the humble comma-separated values (CSV) format - the
world’s most popular data interchange format in text :-).

Try it yourself.

csvreader - read tabular data in the comma-separated values (csv) format the right way

Hello,

I've started to put together a new library / gem, that is, csvreader [1] -
that lets you read tabular data in the comma-separated values (csv) format
the right way :-), that is, uses best practices such as

- stripping / trimming leading and trailing spaces,
- skipping comments and blank lines,
- "fixes" quote errors and more

all out-of-the-box with zero-configuration.
And, thus, fixes some major bugs in the (old) standard csv library
with a purpose-built parser (instead of a supposed "faster" split(",") kludge).

Happy data wrangling with ruby. Cheers.

tabreader - read in tabular datafiles in text in the tab format; yes, uses values = line.split("/t")

Hello,

I've put together a new library / gem, that is, tabreader
that lets you read in tabular datafiles in text in the tab format;
yes, uses

values = line.split( "/t" )

or use the packaged up

TabReader.parse_line( ... )

or any of the convenience helpers incl.