Materialized Views in Postgres
https://hashrocket.com/blog/posts/materialized-view-strategies-using-postgresql
2025 on Tumblr: Trends That Defined the Year
Not today Justin
Show & Tell
Three Goblin Art

Discoholic đȘ©
YOU ARE THE REASON
Monterey Bay Aquarium
One Nice Bug Per Day
I'd rather be in outer space đž

blake kathryn

@theartofmadeline
art blog(derogatory)

ç„æ„ / Permanent Vacation
ojovivo
Jules of Nature

Product Placement

Origami Around
taylor price

romaâ
wallacepolsom
seen from United Kingdom

seen from United States

seen from Netherlands
seen from Singapore
seen from United States
seen from Germany

seen from United States

seen from France
seen from Finland

seen from Thailand

seen from Netherlands
seen from United States
seen from United States
seen from Poland

seen from Japan
seen from Malaysia

seen from United States
seen from United States
seen from TĂŒrkiye

seen from Hong Kong SAR China
@todaybrianlearned
Materialized Views in Postgres
https://hashrocket.com/blog/posts/materialized-view-strategies-using-postgresql
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
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
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.
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?Â