This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
Having trouble dismissing the keyboard in your React Native app on iOS? Would you like the keyboard to simply go away after a user taps somewhere else on the screen after entering some text into a TextInput? Here’s what you’re looking for: <TouchableWithoutFeedback> and Keyboard.dismiss() are the React Native equivalents of Tap Gesture Recognizer and resignFirstResponder. Simply wrap your view in a <TouchableWithoutFeedback> component and call the Keyboard.dismiss() method onPress and the keyboard will automatically dismiss itself when a user taps an area of the screen outside of the currently selected <TextInput>:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
Quick little rant and opinion piece here tonight on the blog. I’ve been programming a lot lately in ReactJS and React-Native, following along with all of the various quickstart guides and tutorials related to the React tech stack, and have found myself thrust into this brave new world of JavaScript where variables do not exist. In this new world var is out, and const is in!
At least that’s how it appears looking at all of this “modern” JavaScript code I’ve been working with. I can’t remember the last time I saw the keyword var. But tonight I sort of had an epiphany: These constants don’t seem very constant to me. We’re using them just like variables!
To test this out, I fired up repl to see, can you just write over a constant whenever you feel like it? Or if you declare a new constant with the same name, is all forgiven? Well here’s what I found out. The JavaScript interpreter will get mad at you and crash if you try to write over a constant, or declare a new constant with the same name. But, if you declare a new constant inside a function you can write over it as many times as you like!
So… essentially this is what I’ve been seeing in all the modern JavaScript code I’ve been looking at. People are using constants just like variables, except the constants are always inside of a render() function or something similar so you can keep writing over it over and over and over again.
I’m sure most professional React developers know this. However, this seems pretty stupid to me. Why use a constant if you actually want a variable? I’m sure the answer has something to do with immutability! and functional programming! But I’m not buying it. const is not constant, and the emperor has no clothes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
Quick post here tonight on how to setup a new flask app for development on a Mac. In the past I’ve done all of my Python/Flask development on a Windows desktop computer, but since I’m now doing all of my development on a Macbook Pro, I wanted to write another little quickstart reference for myself or anyone else out there on the internet to get up and running with Python and Flask on a Mac (assumes you’ve already installed Python 3, if you haven’t, please visit https://python.org):
First, create a directory for your new Flask project
$ mkdir MyNewFlaskApp
Navigate to your newly created directory
$ cd MyNewFlaskApp
Create your virtual environment
$ python3 -m venv venv
Activate the virtual environment
$ source venv/bin/activate
Make sure Flask is installed
(venv) $ pip3 install Flask
Now write the actual python code for your flask application. We’ll call our python script my_new_flask_app.py. Save this script in your MyNewFlaskApp directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
I’ve been working with a student of mine recently in Golang and noticed that my skills were sort of lacking! So here’s a quick little cheat sheet reference for coding in Golang. If you need any help getting your computer setup to run Golang, check out Learn Go in 12 Minutes on YouTube.
If you haven’t already installed Golang and set up your environment, do that first…
Step 1: Install Golang
Then, create your “go” directory where you will store all of your golang projects on your local machine:
$ cd $HOME
$ mkdir go
$ cd go
$ mkdir src
$ cd src
Next, create a subdirectory for your project:
$ mkdir hello
$ cd hello
Now create a file called hello.go which will contain our hello, world program:
package main
import "fmt"
func main() {
fmt.Printf("hello, golang\n")
}
Compile & Run:
$ go build
$ ./hello
Last, check out the example below (based on Learn Golang in 12 Minutes) as a reference/cheatsheet:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Need to work with command line user input? Another cheatsheet:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Need to ping a JSON API? More cheatsheet goodness from the folks at RapidAPI:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
Tonight using Auth0 I started integrating social login with Google, Facebook, and Twitter into the latest development version of my personal finance app, Moolabeast, and found myself wondering: Do users need to signup? Or can they just log in?
While testing this new integration it appears there is no difference between signing up and logging in using a social media account. However, I really wanted to make sure that I get this right so I decided to dig a little deeper into the issue. Long story short: there is no difference between signing up and logging in. If a user clicks on “log in” instead of “sign up”, the end result is the same. Apparently Auth0 has just stuck with this old signup/login paradigm as it’s what internet users are used to. First I sign up, then I log in.
So I hope this clears up some confusion if you happen to be integrating social login with Auth0 into your app. Happy hacking my friend!
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
This is actually a cross-post of a comment I posted recently to Hacker News. Unsurprisingly, the comment received negative 1 upvotes. However, I think this is an import piece of information that has gone missing from the World Wide Web, so I wanted to bring it back: The 100 Year Historic Decline of Dividend Payout Ratios for S&P 500 Companies
The hacker news thread on which I commented was regarding a recent headline on increasing S&P 500 Buybacks, but what I think is more troubling is the decline in dividend payout ratios, not the increase in buybacks. But the two are closely related, so let’s take a look:
100 years ago, companies on average dispersed 90% of their earnings back to shareholders as dividends. But by the 1970’s however that number fell to below 50%. Fast forward to the 2000’s and the payout ratio is down to around ~30%.
What happened? Companies used to distribute their profits back to their owners, the shareholders. But that isn’t what’s happening anymore. In my amateur historical analysis, I believe there are two causes for this disastrous trend:
1) Tax dodging 2) The Casino/Gambling Mentality of Stock Market Investing
My theory is that the trend started with investors 50 to 100 years ago looking to dodge taxes, and gain a little free compounding. Makes sense! Right?
But it’s just gone too far. Now investors receive almost nothing for owning a stock. Take Apple Inc. for example. In 2019 Apple made a profit of $55 billion. How much of that did they pay back to their shareholders? $14 billion.
And Apple isn’t even the most egregious case. They at least pay a dividend. Google, Amazon, and Facebook combined paid $0 back to their shareholders this year!
So how has this insanity continued to go on for so long? The answer is simple: Adults don’t know what stocks are. They think that a stock is a thing that you buy, its price goes up and down, and the game is to try and sell the stock when the price goes up, and hope that the price doesn’t go down. And the machine that keeps the whole thing moving along is the Stock Buyback.
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
Alright, so let’s get to it: How to debug a realm database running on a physical device:
Unfortunately, you cannot debug a realm database running on a physical device if it is already in production.
Hopefully this saves someone out there a ton of heartache, but after you have pushed your app out in to production, you can’t just open up a .realm file from your device using Realm Studio due to security restrictions. So if you happen to find yourself struggling to open a realm database that’s running on your personal device, and can’t seem to access the .realm file to debug it, it could be that your device isn’t allowing access to the file because it is a production app and is not debuggable via USB and Android Studio, etc.
If you need to be able to debug and inspect Realm database instances running on live production versions of your app, this may be possible with Realm’s new Realm Cloud product. However, I haven’t checked out Realm Cloud and Realm Sync just yet as I’m still getting my feet wet with Realm DB.
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
Fret not distressed developer! Using the ON DUPLICATE KEY UPDATE feature of SQL with Python, MySQL, and mysql.connector can be a bit of a doozy once you add in parameterizing your queries. This personally took me quite awhile to figure out since most of the SQL references regarding ON DUPLICATE KEY UPDATE do not include the Python/mysql.connector specific aspects, and most of the Python/mysq.connector references do not mention ON DUPLICATE KEY UPDATE.
So here is the trick, you won’t be passing the SQL query values like usual with %s for the UPDATE part of your query. Instead you will write something like VALUES(name_column). For reference, here is a little snippet of code from one of my projects which should guide you in the right direction:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io
Tonight I started hacking on an old project on which I’m currently bringing back to life, a chrome extension which saves all of the pages you visit to the Internet Archive’s Wayback Machine. It’s called The Internet Archivist’s Intrepid Extension.
Unfortunately I had to kill off the first version of the extension because cloudflare started blocking all of my traffic. However, I discovered today that Archive.org has an API for submitting links programmatically. So the Intrepid Extension is back!
After an hour or so of hacking I’ve put together a pretty simple prototype and thought maybe I should share the source code here on the blog in case anyone else is stumbling around the internet looking for a solution. Enjoy!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Your privacy is important to me. It is my (Christopher Pedersen) policy to respect your privacy regarding any information I may collect from you on my app, FatCamp.
I only ask for personal information when we truly need it to provide a service to you. I collect it by fair and lawful means, with your knowledge and consent. I also let you know why I am collecting it and how it will be used.
I only retain collected information for as long as necessary to provide you with your requested service. What data I store, I will protect within commercially acceptable means to prevent loss and theft, as well as unauthorized access, disclosure, copying, use or modification. I don’t share any personally identifying information publicly or with third-parties, except when required to by law.
My app may link to external sites that I do not operate. Please be aware that I have no control over the content and practices of these sites, and cannot accept responsibility or liability for their respective privacy policies.
You are free to refuse our request for your personal information, with the understanding that I may be unable to provide you with some of your desired services.
Your continued use of my website will be regarded as acceptance of our practices around privacy and personal information. If you have any questions about how I handle user data and personal information, feel free to contact me (chris@topherpedersen.com).