HN user

jasonl99

110 karma

[ my public key: https://keybase.io/jasonl99; my proof: https://keybase.io/jasonl99/sigs/ywEkMgK-gBylvQgMx3uzXHyNxzFFyk4krDj_Jm8QqhY ]

Posts2
Comments32
View on HN

I've been playing around with crystal for years, and absolutely love it (I'm a full-time ruby dev using Sequel as an ORM). I wish I had more time to spend with crystal. Kemal (referenced above) is really good, and excellent with websockets.

That said, I started playing around with the Marten framework and while it's really new, it's an amazingly good start. I absolutely love the way that models automatically create migrations. Using Sqlite as a default is good for probably 99% of uses cases, and absolutely good for learning the framework (Sqlite itself is amazingly powerful).

I've been wondering what new shiny toys I was going to play around with over vacation during the holidays, and I now have my answer :).

“The reasonable man adapts himself to the world: the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man.”

― George Bernard Shaw, Man and Superman

I've always used this as an excuse for what might be considered being weird (at least that's what my family tells me).

I agree, and I can't believe more people haven't mentioned it here. I am not going to rehash what anyone can read at the linked site, but it seems like an absolutely great project, and seems to be flying under everyone's radar.

One thing I've found useful when listing tables that you can't exactly remember the name, you can use wildcards.

\dt cust*

will list all tables that start with "cust". It works with other commands as well (like \l).

Also, I like to split my terminal using tmux, and have a neovim editor in one pane, psql in the other. I just keep doing "\i file_name.sql" as I perfect the query.

I definitely agree wholeheartedly about pspg. They even have a FoxPro theme, which has a special place in my heart :).

Visidata 2.0 6 years ago

I can't figure out how to get it configured as a pager (in postgres). I've been using pspg set in my .psqlrc.

I changed it to \setenv PAGER 'vd' and I just get a big chunk of text with no ability to navigate columns. How are you doing it with mysql?

I started using (and subscribed to) Inkdrop[1] after recommendations here and have been very happy with it. Yes, it's $5 a month, but it automatically syncs (encrypted locally first), and has a way of doing full local directory backup that you could sync with github. The the editor is really nicely done (full github-flavor syntax highlighting too).

I'm using clients for Mac, Android and linux (manjaro) and all work well. There are also clients for the other major platforms.

One of the things I really like about it is I can do a screenshot on both Mac & linux, saving to the clipboard rather than a file, and paste it directly into an editor and inkdrop handles everything, including creating a file and corresponding markup. And that all syncs too.

[1] https://inkdrop.app/

I actually started binding my CAPSLOCK key to F5, and I have F5 set as a tmux attention key, but I've never had too much problem with left pinky finger hitting escape..

A side benefit of this is that F5 is mapped to refresh for a lot of apps (Firefox, for one) so I can hit capslock to refresh a page.

Living in Florida, and being married to a wife who considers the presence of cockroaches a dealbreaker for living together, I've managed to keep a roach-free home for several years now without _too_ much effort.

I use this as one part of a multi-pronged approach, dusting around areas they would need to cross to get into the house. It's super-cheap and lasts a long time.

It does need to stay relatively dry, though. When I've needed to repair drywall on occasion, I dust a bunch in the opening figuring it will basically last forever and not get wet.

I also use a bait with boric acid placed in various random areas. I also use a product that slowly emits a vapor in closed areas that basically neuters any roaches that get near it (for places like under the sink). Finally I used Home Defense spray around the outside.

I treat the condo once every three months, and it takes about 30 minutes. I've seen maybe two cockroaches in the past few years, and both were belly-up.

Your comment totally reminds me of an article Tim Urban wrote in 2015 about the dangers of AI (Mr. Urban, if you are around these parts I absolutely love your writing!!).

Within that article he describes "a 15-person startup company called Robotica has the stated mission of “Developing innovative Artificial Intelligence tools that allow humans to live more and work less.” It does not end well.

https://waitbutwhy.com/2015/01/artificial-intelligence-revol...

There's a really cool way to do this that I learned about with ruby here https://gist.github.com/O-I/3e0654509dd8057b539a

Here's a quick demo class that shows the technique. It's amazingly simple.

class Demo EXAMPLE = { "75%" => 0.75, "15%" => 0.15, "9%" => 0.09, "1%" => 0.01 }

  def self.sample(choices = EXAMPLE)
    choices.max_by { |_, weight| rand ** (1.0 / weight) }.first
  end

  def self.show(samples: 10000)
    items = samples.times.map {sample}
    items.each_with_object(Hash.new(0)) do |item, counts|
      counts[item]+=1
    end.sort_by(&:last).reverse.to_ h
  end
end

# Demo.show # => {"75%"=>7480, "15%"=>1525, "9%"=>901, "1%"=>94}

Edit: Sorry for the bad formatting. I added a gist:

https://gist.github.com/jasonl99/25d3c922d73f10a75fe228c2de3...

>The Nurture Option. A well-trained bulldog can be a much, much better dog than an untrained border collie. And one person can accomplish this training with a dog in a few years. Why spend 12,000 years breeding humans instead of putting a bit more effort into training the perfectly serviceable brains that we already have?

The cynic in me says that's exactly what's been done with humans. The school system in the United States was created, in large part, to train factory workers and be obedient citizens.

I think you're right. I run basically the same route every time (varying distances a bit), through a county park that's literally down the same sidewalk where I live. I also listen to the same six or seven songs, changing a few of them every month or two. Most people who know this is my routine think this must be unimaginably boring.

But within a couple minutes, I don't even notice, and I'm just letting my mind drift, sometimes to the extent that I've overshot my turnaround spot by more than a mile just from a lack paying attention

Having experienced this, I can't imagine now going back to the "old way" where I have random songs that differ every time, or different routes that require me to pay attention.

I've often thought the repetitive nature of the same route and the same music actually encourages the metal drift.

I can't download purchased MP3's from amazon's own site, I get "We’re experiencing a problem with your music download. Please try downloading from Your Orders or contact us."

When I go to my orders I get "There's a problem displaying some of your orders right now. If you don't see the order you're looking for, try refreshing this page, or click "View order details" for that order."

It seems that Amazon is eating its own dog food.

I'm going to answer my own question - I tracked it down to a bug in lattice-core that occurred when it couldn't parse incoming JSON, and for some reason it killed the socket server. I fixed it by rescue the JSON parse and all is good now.

I'm trying to get this demo working on an extremely inexpensive plain VPS (running Debian 7), and I'm getting "WebSocket connection to... failed: Invalid frame header". Is that what you saw when you as a result of hitting the 40-50 client limit? I am getting the error on a first connection, so it's probably something different.

I answered this on a different thread, but I've specifically designed things for this scenario. The framework has a class named WebObject. Once instantiated, it stays persisted on the server, and can take on additional subscribers.

At any time, "updates-applied" browser version of the current state of the object can be created with a call to the #content method.

So when a "updatable" occurrence occurs on the browser, you send an update method withe the changes. The changes are packaged up into messages that sent to each subscriber, where they modify the dom.

It's a bit of a reversal, probably, with how people use frameworks that dynamically change content. I make the assumption that the server's instance is the only keeper of object state. Changes made on clients either change object state or they don't; if they are not sure, they send an event back to the server which handles it.

A @WebObject can also have properties that are themselves WebObjects, and the current card game actually has three: ChatRoom, GameStats, and GameObserver.

This pushes the responsibility for rendering content directly where it belongs: on the object where the rendering occurred in the first place.

But it has the side benefit of keep object state, too. The CardGame doesn't have to worry about the state of the ChatRoom (though it can observer and send events to and from it).

The bottom line is that there are only two ways the browser rendering could be wrong: 1) Some packets were missed, or 2) The developer didn't send the correct events, or sent them in the wrong sequence.

The first case could be solved by creating a delivery confirmation layer over the objects.

The second case is probably a little more dicey. The more data contained in a single updatable chunk, the harder it is determine when state changed. That's helped tremendously by the idea of nesting WebObjects (A Room has CardGames which have Players and Games, which have Decks and Cards....each of which take care of updating themselves)

Author here...Well, I started down the websockets path because of how awesome I found crystal to be. I wasn't intending to do this a few months ago, it just sort of took on a life of its own :)

The framework as I've written takes state into account; in fact it was/is a design goal. There are three types of server objects currently - WebObject, StaticBuffer and DynamicBuffer. A WebObject stays instantiated on the server even when no users on viewing it (at some point it will be garbage collected).

At any time, rendering that object will produce the exact representation as seen by someone who has viewed it and been updated with websockets. In fact, the card game is a good example of this. Start a game, draw a few cards, start another game, and then go back to the first. It'll be in the same state you left it in, complete with the events that occurred while you were gone. This was one of the top goals.

DynamicObjects are just arrays of WebObjects in a configurable buffer - think of a list of sports scores, where each item handles its own update.

StaticObjects are an array of simple strings of html (think of tail to view a log file).

I haven't explored that a lot, but my thought was that the amount of setup/teardown for polling goes away, so it's at least an order of magnitude (guessing) better.

I have written the framework to use a single socket connection for all updateable objects on the page.

I couldn't agree with you more. I can't even tell you how many times I've figured out something while on a run or walk -- far too often I've started writing code without thinking it through adequately. Getting away from the keyboard, away from google, away from every possible distraction and just letting your brain have some time to reflect on things is sadly lacking with today's constant barrage of information.

I've started doing something in the past year - when I go for a run, I pick one "small thing" to think about. It might be trouble I'm having with code (javascript Promises, anyone?), or something as unrelated as "why do we drive on the right side of the road in the U.S." I don't always intend to try to find an answer, I just want to get in the habit of just thinking without distraction.

I have a 2013 Jeep Wrangler, that while unrelated to the hacking incident, is quite disturbing in its own right. An Atlanta TV station did a story about the TIPM (Totally Integrated Power Module): http://www.wsbtv.com/news/news/local/channel-2-investigates-...

In my case, the TIPM has failed -- completely -- twice. The first time, I lucked out -- it happend while I was in my condo's parking lot. The Jeep completely died -- engine shut off, power windows didn't work, lights, radio, everything dead. If this had happened on the freeway during the 40-mile freeway drive I was about to do..yikes.

The second time the part failed was overnight. I was awoken at 3 am by my Jeep with its reverse lights on, the horn intermittently beeping, and the headlights and windshield wipers coming on. I could not get it to stop until I disconnected the battery. In both cases the dealership replaced the TIPM. I asked specifically if the part number showed that they had "improved" the part -- but no. It's the same.

There's even been a lawsuit filed to get them to do something about it:

http://www.autosafety.org/cas-calls-nhtsa-investigation-chry...

Long story short -- if you are in the market for a Jeep, PLEASE make sure you are fully informed about the TIPM situation.

> We've mapped the nutrients required by our cells down to a molecular level. We've even got a thorough understanding of the interaction between the food we eat and how the microbial ecosystem in our digestive system breaks down our food as we digest it.

This belief, in a nutshell, is the problem with nutrition. We have done no such thing, but we've convinced ourselves that we have. I have no doubt that we aren't even capable of understanding half the shit that goes on to turn food into energy.

At one point, society killed people who dared claim that the Earth revolved around the sun. We should never think, even for a second, that we have all the answers, and we should be immediately suspicious of any claim that we do.

> You seldom hear about people who lie to their loved ones about their hidden coffee stash, or steal from their child's piggybank to sustain their caffeine fix.

Actually, this brings up an perfect example of the first poster's point. Smoking cigarettes was socially acceptable at one point. Now, it's considered a bad, unhealthy habit. I've known quite a of people who hide, or attempt to hide, their habit from their friends. And I'm quite sure that a good number of parents have taken money from their kids piggybanks to buy cigarettes.