our ability to deal with pain is directly proportional to our ability to see pain elsewhere.
Subroto Bagchi
admin
HOWTO : Query json data in SQLite
A self note for querying json data in SQLite. BTW, I think SQLite is an under utilized and under appreciated swiss army tool for data storage and manipulation. And thanks to Richard Hipp, it is free.
If you have a column defined as a json type in your SQLite database, quickest way to search for the data is json_extract
. A full set of functions available are documented at https://www.sqlite.org/json1.html
If you have a column named family_details
in a table family
with the following json in it as an example
{
"father": {
"name": "dad",
"birthday": "1/1/2000",
"pet_name": "daddy"
},
"mother": {
"name": "mom",
"birthday": "1/1/2001",
"pet_name": "mommy"
},
"sons": [
{
"name": "son_one",
"birthday": "1/2/2020",
"pet_name": "sonny_one"
},
{
"name": "son_two",
"birthday": "1/2/2021",
"pet_name": "sonny_two"
}
],
"daughters": [
{
"name": "princess_one",
"birthday": "1/2/2020",
"pet_name": "princy_one"
},
{
"name": "princess_two",
"birthday": "1/2/2021",
"pet_name": "princy_two"
}
]
}
and you want to print the name of the father, you can use
select json_extract(family_details, '$.father.name') as father_name
from family
json_extract
uses the name of the column and the json node as parameters. In this case, we used $
(which denotes the root), father
and name
(under father) as the json node.
Overheard : Services vs Product businesses
In the services business, you get paid to say yes to everything.
In the product business, you get paid to say no. By convincing the customer that you are not going to give what they want, but what they need.
– Sanveet Singh (CEO of $PAR) on a podcast with Richard Sosa
Overheard : On appreciation
Everyone needs to feel appreciated. It doesn’t matter what they do, it doesn’t matter who they are, that’s a need in everybody.
– Grace McNiel (Hugh Jackman’s mom)
Hugh Jackman mentioned this quote on a podcast with Tim Ferriss. Highly recommend listening to the podcast. Hugh shared a lot more such wisdom in it. My admiration for Hugh went up a couple more notches after listening to it.
Collection of tools to serve local content on your workstation to the Internet
A quick collection of tools you can use to serve/publish content/applications on your local dev to the Interwebs. Some use cases for these types of tools..
- Developed a static website and want to show it someone that is not right next to you.
- Developed an API that you want an app or user to access from the web
List of tools:
- https://ngrok.com/ : Most popular tool for this purpose. the free tier is enough for most use cases.
- https://tunnelto.dev/ : Latest entrant in this space. In addition to have a paid hosted service, you can run this for free on your own server. But that defeats the pupose of having a tool to use in a pinch to share content :).
- http://pagekite.net/ : Been around for 10+ years. Similar to tunnelto.dev, you can run this on you own server or pay (very nominal price) for the hosted service.
Fatherhood..
Today being Father’s day, some reflections on fatherhood. I think people go through different stages on how they view their dad.
Admiration ( 0 – teen years) : Your dad is a superhero. He can lift you up (just imagine another human being able to lift you up, throw you in the air and then catch you safely :-).. mindblowing!!). He can apparently conjure ice cream at will. You feel safe in his embrace. He is superman!
Respect (teen – having a kid of their own) : By the time you are in your teens, you are probably stronger than your dad :). Your admiration turns to respect. Your dad is the guy that is always their despite not getting anything in return.
Love (After having kids of their own) : You understand what it means to be responsible for another human being!! All that admiration and respect turns to love ❤️
Overheard : Value of a business (stock)
A cow for her milk; a hen for her eggs; and a stock,
John Burr Williams
by heck, for her dividends.
HOWTO : Python string search
Quick self-note 🙂
different ways to search for content in a string in python
- Basic (and quickest)
if 'content' in string:
- String.find (second quickest and doesn’t need additional module)
if string.find('content'):
- re.match (uses regex engine, most powerful)
import re
if re.search('content', string)
Good discussion here : https://stackoverflow.com/questions/4901523/whats-a-faster-operation-re-match-search-or-str-find
HOWTO : Replace first space in a line using Notepad++
Search for ^([^\s]*)(\s)
Replace with $1 AND_WHAT_EVER_STRING_YOU_WANT
Here is an example of searching for first space in a line and adding “',
” to the string
Overheard : Process
Love this quote about process attributed to Tobi Lutke in multiple interviews. He said it in different ways, but here is the gist
There are three kinds of processes
- Process that makes things that were previously impossible to do, possible. That’s good.
- Process that makes something that was previously possible significantly simpler, which is also good.
- Remaining 99.9% of all process that exists in corporate America is the third category, which is actually just telling people to behave slightly different from what common sense tells them to do.
Source :