Straight from the [wiki]:
Fundamentally, objects (instances) reference one another and therefore form a graph in the mathematical sense (a network including loops and cycles). Relational schemas are, in contrast, tabular and based on the relational algebra, which defines linked heterogeneous tuples (groupings of data fields into a "row" with different types for each field).
Converting linked tabular rows to graph structures is hard, and even described as the [Vietnam of Computer Science][vietnam-of-cs].
Further reading:
- Introduced by [Kent Beck][beck] in the 1990s.
- Part of his software development methodology [Extreme Programming][extreme-programming].
- His exact wording appears in the [White Book][white-book].
The rules can be stated as followed:
Passes all tests
Maximizes clarity
- [Blockchain Basics][blockchain-basics]
- [Bitcoin - Currency for paranoiacs, or an idea that will change the world?][bitcoin-milken]
- [From “What is Blockchain?” to building a blockchain in less than an hour][what-is-blockchain]
- [A blockchain in 200 lines of code][200-loc-blockchain]
- [What is Blockchain Technology?][blockchain-tech]
- [Making Money][making-money]
- [Making Money Trustworthy][making-money-trustworthy]
- [The Truth About Blockchain][blockchain-hbr]
- [Blockchain Demo][blockchain-demo]
- [Blockchain - Wikipedia][blockchain-wiki]
module Damm | |
# See http://en.wikipedia.org/wiki/Damm_algorithm | |
TABLE=["0317598642","7092154863","4206871359","1750983426","6123045978", | |
"3674209581","5869720134","8945362017","9438617205","2581436790"] | |
def lookup number | |
number.to_s.each_char.inject(0) do |m,v| | |
TABLE[m][v.to_i].to_i | |
end | |
end |
I'm trying to figure out if using counter_cache
on a has_many :through
association is still considered kosher in Rails 3.2. I've read several posts that distill the steps for setting this up (e.g., see 1 and 2). On the other hand, it seems like counter_cache
on has_many :through
was an unintended side effect that was never a supported feature of Rails and was ultimately removed.
Here's my specific scenario:
# Event model
has_many :event_attendees, dependent: :destroy
has_many :attendees, through: :event_attendees, source: :user
# EventAttendee model
One of the many reasons I love working with Ruby is it has a rich vocabulary that allows you to accomplish your goals with a minimal amount of code. If there isn't a method that does exactly what you want, it's usually possible to build an elegant solution yourself.
Let's take the example of simulating the rolling of a die.
We can represent a die as an array of its faces.
die = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
{:user {:dependencies [[org.clojure/clojure "1.8.0"] | |
[org.clojure/tools.namespace "0.2.10"] | |
[spyscope "0.1.5"] | |
[criterium "0.4.3"]] | |
:injections [(require '(clojure.tools.namespace repl find)) | |
; try/catch to workaround an issue where `lein repl` | |
; outside a project dir will not load reader literal | |
; definitions correctly: | |
(try (require 'spyscope.core) | |
(catch RuntimeException e))] |
I found myself in a situation where I wanted to examine the layout of the mobile version of a particular website. I tend to use Ruby's OpenURI
module and the Nokogiri
gem for my webscraping needs, and it turns out it's really easy to get a mobile version of the site with a bit more effort:
require 'open-uri'
require 'nokogiri'
# let's look at my GitHub profile as an example
url = 'https://github.com/O-I'
# this opens the URL and parses it as XML
This is one of those things that was right in front of my face, but I figure it's worth a mention. I was trying to figure out the best way to view the source code for Clojure's frequencies
function — ideally while in a REPL. I found this older post mentioning a source
function in the clojure.contrib.repl-utils
namespace. I launched a REPL to see if I could use it and, well, here's what I saw:
$ lein repl
nREPL server started on port 58700 on host 127.0.0.1 - nrepl://127.0.0.1:58700
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.7.0_45-b18
Docs: (doc function-name-here)
(find-doc "part-of-name-here")