Materialized Views in Postgres
https://hashrocket.com/blog/posts/materialized-view-strategies-using-postgresql

Discoholic 🪩

⁂
wallacepolsom
$LAYYYTER
i don't do bad sauce passes

祝日 / Permanent Vacation
Aqua Utopia|海の底で記憶を紡ぐ
we're not kids anymore.
Sade Olutola
Show & Tell

tannertan36
KIROKAZE

PR's Tumblrdome
h
Cosmic Funnies
Three Goblin Art
Alisa U Zemlji Chuda

izzy's playlists!
YOU ARE THE REASON

seen from United States
seen from United States
seen from Australia

seen from Spain
seen from United States
seen from United States

seen from United Kingdom
seen from Singapore

seen from South Africa

seen from Netherlands
seen from Germany

seen from United States

seen from Malaysia

seen from United States
seen from Singapore
seen from United States

seen from Australia
seen from United States
seen from United States
seen from United States
@todaybrianlearned
Materialized Views in Postgres
https://hashrocket.com/blog/posts/materialized-view-strategies-using-postgresql

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Custom column types in Sequel
http://sequel.jeremyevans.net/rdoc/files/doc/schema_modification_rdoc.html#label-Column+types
We made a custom postgres domain named ‘timezone’. To use it:
column :timezone, ‘timezone’
3 Things I Learned Today
- relearned the ~> syntax in Gemfiles
- RabbitMQ runs on Erlang VM (!)
- I’m still holding onto some of that perspective I always get after coming back from Burning Man. Like, “oh wow I’m thinking this way. That’s interesting to observe.”
Sequel and Postgres time
Trying to have app use database time for everything. Sequel gem docs make it straight forward, of course not in this app. Looking to pull the CURRENT_TIMESTAMP value out of Postgres and use it as a time object in Rails. The code:
Sequel::Model.db.get(Sequel.CURRENT_TIMESTAMP)
This returns a Time class object, and you can do all the normal stuff to it (ie. .to_f, .to_datetime, etc) that you’d expect work.
Now to deal with all the broken tests that use Timecop, because Timecop doesn’t freeze our custom Clock object that pulls database time.
Undo anything in git
https://github.com/blog/2019-how-to-undo-almost-anything-with-git

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Wrangling with a JavaScript text parser that identifies certain tags and can toggle url shortening. Used lots of other places so it has a ton of extra complexity that makes it difficult to understand immediately.
One of those things where you’d love to rewrite it just to feel better about not having something so messy. But is it worth the cost? Usually no.
Overriding primary key in Rails
http://ruby-journal.com/how-to-override-default-primary-key-id-in-rails
Depends how far you want to take it. But basic idea is that a primary key is really only a key with non null and unique constraints. There’s a syntax for doing that in migrations (not null) and with a custom index (unique constraint). Then make sure you define self.primary_key in your model. Lastly set the param in the routes file so you can do params[:name]. Don’t override the #id methods for your model, too many other Rails methods rely on them.
If you’re mocking out a method, such that you’re isolating it’s behavior from hitting an external service (database, etc), you may need to just duplicate the entire logic inside the method with mocks and doubles.
Felt a bit wrong, like I was duplicating logic. But it isolates the method. Maybe there’s an even better way I will learn some day.
3 Things I Learned Today
1. Turing Machine and lambda calculus (Jim Weirich talk)
2. Better feel for using map and reduce
3. ???
Ruby Named Parameters / Keyword Arguments
It’s 2015 and I’m just now seeing code like this in the wild?!?:
def some_method(first_name:, last_name:)
Keyword arguments were added in Ruby 2.0, this particular syntax (no default values) is Ruby 2.1. Released end of Dec 2013.
https://robots.thoughtbot.com/ruby-2-keyword-arguments

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Count number of arithmetic sequences in an array
“Arithmetic” means, from an array with at least 3 values, the difference from one value to the next one remains the same.
eg. [-1,1,3, 5] is arithmetic. [-1,1, 3, 3] is not.
First attempt under the gun of a timed challenge took an hour, almost had a working solution. Code deleted.
Second attempt a few days later, <30 min. Solved. Some recursiveness thrown in there.
You can make Mocks more than just an empty object
Say you’re testing a class. It takes a collection of other objects at initialization, and there’s a class method making a call to the collection to return a subset of objects.
Instead of building out actual objects, you can build mocks that will respond to any methods you want. Can even have a method return other mocks.
Vague for anyone reading this, but it will jog my mind for the specific example.
“The world breaks everyone and afterward many are strong at the broken places.” Ernest Hemingway
The world is breaking me right now.
URI encoding
Let’s say you’re trying to build url strings from a list of names, to then query the Battle.net World of Warcraft API. Let’s say some of those names have non-ASCII characters, names like ‘Doomsday’, etc.
Ruby’s open-uri gem complains hard if characters like this are not encoded correctly.
A simple URI.encode(’CrāzyNaméHére’) gets it done.
Thoughtbot Playbook
playbook.thoughtbot.com
Basically how they do their entire business. Great resource.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Sublime Text - multi-line wrap with tag
Cmd - Shift - L
Ctrl - Shift - W
Type the tag of your choice.
Incredible.
http://www.thenerdary.net/post/29835955835/st2-wrap-each-line-in-an-element
JavaScript puzzle
Write a function that takes a seed number and returns a function, and with every successive call of that returned function it returns a a the value of the seed plus argument.
Vague and hard to explain. I had to ask a bunch of questions to clarify. Here's what he output would look like:
var a = getIterator(10); a(2); => 12 a(4); => 16;
After some monkeying around with explicit variable declarations, we arrived at this:
var a = getIterator(seed) { return function(num) { return seed += num; } };
So how the fuck does this work? Well, lots of assumptions made here about the code is actually be interpreted and executed. After reading about variable hoisting this is how I think it works:
1. getIterator runs only once. It returns the anonymous function defined within it.
2. Before that, because of function hoisting the anonymous function it returns is declared.
3. And before that, the variables are declared.
4. So all that shit runs, and a function with the seed saved in it is retuned and assigned to var a.
5. Now here's where I'm still having questions: how the fuck does the function store state from call to call?