This is possible using Arel, but not as simple as it might seem, since the basis of using AR/Arel for queries is to select from a table, and in the query above, the NULL and ” aren’t columns in our User table. So those are the tricky parts of the query. The key is to use
to select those values. It just consists of a left and a right value, e.g.
Arel::Nodes::As.new( left, right )
, where your select is on the left and the alias on the right.
This is how I would write the above query using Arel:
The above code works for MySQL. Apparently the syntax has to be changed a little for Postgres. (Postgres doesn’t like the column aliases to be quoted). You can use Arel.sql() to make an “SQL literal” for handling that. Using Arel.sql() prevents quoting of the alias and passes what you want directly to the SQL engine as-is.
The modified code below should work for both MySQL and Postgres (But I think that the Arel::Nodes::As behavior should be handled correctly for Postgres by the pg adapter – I might make a pull request for that later).
(Edit: I think that column aliases in Postgres have to be double-quoted (or not at all), but Arel doesn’t do that. I would think this is a problem with Arel or the connection adapter, and should be handled appropriately.)
I was just reading up on wrapping APIs and just came to another realization regarding Bitcoin. In a payment system using only Bitcoin, there is absolutely no need for PCI compliance. Zero. That’s right:
Bitcoin eliminates PCI compliance.
There’s no private data to store. No customer data exists that a criminal can then steal and rack up charges. Since Bitcoin payments are a push from the customer, instead of a pull from the merchant, there’s no need for any PCI compliance. Customer security is simply “baked in” to the protocol.
Think of how many millions (probably billions) of dollars are spent by large corporations every year, just to be PCI compliant. I know first-hand that the largest company in the world spends (at least) millions on PCI. There are yearly audits, infrastructure costs galore. All CC data must be encrypted. It’s a huge freaking hassle.
And forget about the small guys. There’s no way small businesses could ever hope to store CC data themselves (and be in compliance with PCI standards) — which is why they have to rely on companies like Stripe and Braintree to accept credit card payments.
I like Stripe and Braintree, but I like even more the fact that millions of dollars can be saved simply by using Bitcoin.
Things like this are what makes Bitcoin so amazing. This is just one example. Bitcoin takes everything we think we “know” about electronic payments and flips it on its head.
As I’ve said before, a lot of people a lot smarter than me could explain Bitcoin a lot better than me… so I’ll leave it up to them.
Both of these videos feature Andreas Antonopoulos, a network and security professional and major Bitcoin evangelist.
Watch This First
The first clip is Andreas speaking at the Milwaukee Bitcoin meetup a couple of weeks ago. You can start watching at 47 minutes and 15 seconds (the link should take you there).
Edit: Ok, I can’t figure out how to the get damn player to start at exactly 47:15, so if it doesn’t take you there, just fast-forward to 47 minutes in.
I have also extracted the audio for anyone interested in just listening to it, which you can get here (trimmed to only include Andrea’s talk):
Watch This Second
Now that you’ve drunk some of the kool-aid, you’re ready for the second round. This one is more intense, and more exciting. You’ll be wanting to pour (fiat) money into Bitcoin after watching this one. This interview discusses the recent failure of a Bitcoin exchange known as MtGox, infamous for their incompetence.
It’s an hour and a half, and I suggest you watch the entire thing. It’s worth it, I promise.
I’ve refrained from posting about Bitcoin until now, mostly because I haven’t had time, which is to say that it hasn’t been prioritized. I have also refrained from posting because I’ve been considering a site re-design, and didn’t want to take the time to mess with it. But I’ve got too many thoughts which I need to get out, plus the “Twenty Fourteen” WordPress theme is pretty clean and simple. I like it. Anyway, here goes…
What is Bitcoin?
So many people have given explanations for this, and all of them a lot better than anything I could write here. According to Google:
Bitcoin is a peer-to-peer payment system and digital currency introduced as open source software in 2009 by pseudonymous developer Satoshi Nakamoto. It is a cryptocurrency, so-called because it uses cryptography to control the creation and transfer of money.
Bitcoin is protocol, a type of electronic money, a payment network, a distributed timestamp server (at it’s core), and much more. It’s an entire infrastructure, and it’s completely distributed and self-healing. I recommend reading the Bitcoin whitepaper if you’re completely new to Bitcoin if you haven’t read it. I promise it’s short.
It’s a Libertarian’s dream, a crypto-nerd’s fantasy, and the great equalizer for the common people. Bitcoin is a payment network, a currency (if you want it to be) and a store of value (much better than those worthless paper notes in your wallet and in your bank accounts). Most people focus on the currency aspect of Bitcoin, and its value relative to the US dollar. It’s so much more than that…
Bitcoin can’t be seized (stolen).
Ok, that’s not entirely true. Bitcoin can be stolen (just as the FBI stole the Bitcoins owned by the operator of the Silk Road). But as long as you’ve taken appropriate security measures, your Bitcoin is safe in your hands. Or on your computer.
Here’s an excerpt from an article by attorney Mark Nestmann that I read yesterday. (You can read the article here.)
…cases like that of Emiliano Gomez Gonzolez, who had the misfortune of being stopped by cops in Nebraska – a state where police get to keep what they seize. State troopers found bundles of currency totaling $124,700 in his car.
Police seized all the money, alleging that it was the proceeds of drug trafficking. Gonzolez tried to get it back in court but lost his case, despite the fact that police found no drugs, drug paraphernalia, or drug records connected to the cash. Nor was he ever accused of any crime. And the Nebraska cops kept it all, less a 20% commission paid to the feds for their assistance in prosecuting the case.
Mark then makes a case for opening a foreign bank account and stashing some of your savings there as a solution. Of course, Bitcoin makes this a non-issue. If the driver had instead been holding his $124k+ in Bitcoin, it simply could not have been seized (as long as he had secured his Bitcoin). Money in foreign banks, however, can be seized by the foreign government which regulates that bank, or by the bank itself, as we saw in Cyprus in April 2013.
Bitcoins are limited
There will only ever be 21 million Bitcoins in existence. Due to the mathematics and cryptography behind Bitcoin, they can’t be copied or created out of thin air. This is a good thing. Since Bitcoins can’t be conjured out of thin air (unlike US dollars, British pounds, Euros, etc.), they retain value.
Bitcoin is global
Bitcoin is global, can be used anywhere in the world, and has value anywhere in the world. Take Chile, for example. What’s the point of holding Chilean pesos if I ever get into a bind and need money here? Chile just elected a Socialist president — what’s to stop her government from dipping into your bank account, just like in Cyprus? The Chilean government can’t dip into your Bitcoins without your approval. They won’t even know you have Bitcoin unless you tell them.
A few predictions
It’s currently January of 2014. My predictions are thus:
Within the next 2-3 years, at least one other “developed” country will enact a Cyprus-style bail-in. Probably France. The US will eventually do it also, for the sake of “national security” of course.
With Bitcoin, there’s no more need for money transmitters (since that’s baked into Bitcoin by default). Western Union? Gone with the next 5 years. Maybe within 2-3, depending on how fast the world adopts crypto-currencies.
Bitcoin is the future. It will destroy banks. It will change the world. Crony-capitalism, in it’s current form, will be finished.
I’m tired of writing/editing in HTML, so I’ll probably move to a markdown-based blogging software in the near future. Here is some of the food that I remembered to log. It’s hardly raw anymore, but at least I’m still eating some salads every day.
Vegetarians in general get a reputation for eating only salads, and I’m not sure why. But raw, leafy greens are a great source of tons of nutrients, like iron. I didn’t eat many during my first year of veganism. I’m convinced of the benefits of leafy greens, so I doubt I’ll quit eating them anytime soon. I really should start eating more raw beets.
update (2013-10-05): Umm… yeah, I’m done with this (daily reporting of nutrition/exercise stats). It stopped being fun after about the first 10 days or so. It was a nice experiment, and I’m glad that Brittany and I are still incorporating more raw foods into our diet. I feel a lot better, but again, that might just be in my head.
English breakfast tea w/hemp mylk
1 Brazil nut
1 large apple
the standard mixed greens salad
Lady Grey tea w/4 ginger biscuits & some hemp mylk