Adding Captcha to Django project
add django-recaptcha to requirements.txt
Add ‘captcha’ to your installed apps in settings.py
Create your own custom login form. I usually have a custom folder for forms that I am subclassing so project_name/overrides/login/forms.py
from django.contrib.auth import forms as auth_forms
from captcha.fields import ReCaptchaField
from captcha.widgets import ReCaptchaV2Checkbox
class ProjectLoginForm(auth_forms.AuthenticationForm):
captcha = ReCaptchaField(
public_key=captcha_public_key,
private_key=captcha_private_key,
widget=ReCaptchaV2Checkbox(
attrs={
}
)
)
def __init__(self, *args, **kwargs):
super().__init__(**kwargs)
- Create your own custom login view
project_name/overrides/login/views.py
from django.shortcuts import redirect
from django.contrib.auth import views as auth_views
class ProjectLoginView(auth_views.LoginView):
def __init__(self, *args, **kwargs):
super().__init__(**kwargs)
- Go to urls.py and add in your new subclasses
from project_name.overrides.login.views import ProjectLoginView
from project_name.overrides.login.forms import ProjectLoginForm
- Create a new /account/login url as so
url(r'^account/login/$', ProjectLoginView.as_view(template_name='project_name/login.html', form_class=ProjectLoginForm), name='login')
All done!
January 9, 2023
Wash Trading Mousepads
I love Icemat glass mousepads. I’ve bought about 5 of them (only because I’ve broken a couple with phones falling on them or having them fall off my desk). Prior to Covid, I only owned 2 so have acquired about 3 more since then. For those not familiar with the icemat, it is a glass mousepad that was popular among gamers and computer enthusiasts in the early 2000s. It was known for its smooth and durable surface, which provided excellent tracking for optical and laser mice. However, the icemat was eventually discontinued and became a rarity in the market. Refer to my blog post here Finding a replacement icemat
As a big fan of the icemat, I started buying a large number of them around 2 years ago. I then relisted them on ebay.com at absurdly high prices, hoping to capitalize on their rarity and nostalgia factor. I sold one to a friend of mine at and absurd price and then managed to sell 1 at these inflated prices to someone else. This ended up catching the attention of other buyers.
The news of these high sales seemed to have spread. People started listing icemats at several hundreds of dollars but in reality I think I was the only person purchasing them. Realistically, the icemat is probably only worth around a hundred dollars at most. The inflated prices are a result of my artificial manipulation of the market, which created a false sense of the actual price of the icemat. Here you can see some of the absurd prices the icemat is going for:

December 8, 2022
Can you afford to be an entrepreneur?
With modern insurance plans how does one afford to be an entrepreneur?
Asked a group of friends who are solo developers running their own companies/projects (without VC funding) how much they pay for health insurance? All are paying upwards of 500$/month for healthcare with deductibles above 7-8 thousand dollars. Several have stopped working solo due to health issues that have blown them past any sort of runway they had. Currently the only ‘solutions’ that I can see are:
Entrepreneurs must already be extremely wealthy to have a nest egg that will support them through illness
Under the age of 26 so they can be on their parents insurance
Get married so they can be on their spouses plan
Get VC funding -> Hire a bunch of people -> Get an employee health care plan for everyone
How does an American afford to become an entrepreneur?
November 22, 2022
How to automatically update all git repos in a folder
As someone who has many github repo folders on their server I wanted an easy way to update all of them regularly with minimal points of failure so I made this script:
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\nPulling in latest changes for all repositories...\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
echo "";
echo ""$i"";
# We have to go to the .git parent directory to call the pull command
cd "$i";
cd ..;
# finally pull
# the old name
git pull origin master;
# the new PC friendly name
git pull origin main;
# lets get back to the CUR_DIR
cd $CUR_DIR
done
echo "Complete!"
I have it run automatically every 10 minutes using cron
*/10 * * * * cd ~/ && bash ~/update_git_repos.sh
Obviously it would be more ideal if it only ran when a repo was updated but like I said, I wanted less points of failure.
November 11, 2022
Copilot causes popular projects to become more popular
I have been using Github copilot for the past several months and I honestly think its one of the best ‘tools’ I have ever used. I suspect it is writing about 50% of the code I produce and only about 10-20% of the time it is wrong/needs to be changed.
Approximately a week ago I started using HTMX and noticed that I would have to explicitly force co-pilot to use htmx by telling it in the comments despite it being littered all over my project. After an inflection point I no longer had to tell it. A similar experience happened on the backend side as co-pilot would often recommend using requests versus urllib. This raises several interesting questions:
Will the popular libraries become more popular as copilot, by default, will suggest using them?
How will computer science eduction move forward? Outside of fundamental topics any sort of simple high school or college level programming assignment can be done in 10 seconds using copilot
My experience is skewed as a full stack developer who often jumps between 3 or 4 different languages. The biggest advantage for me is that copilot can ‘help me remember’ the different formatting of the languages rather than the logic of the code. I suspect that the advantages of copilot is lessened by those who work in a single language but I can’t confirm that?
What is the ideal price point for this? I would easily pay 50-100$ a month to use this but I suspect I am in the minority.
October 24, 2022
Games based on Real World Locations
As a person who travels often, I always like to do some research before I visit a new location. If I have the time, playing a game based on the location can give me a little bit of understanding of the area. I feel it immerses you and makes you appreciate the culture of the location more. It’s also a great way to make your kids more interested. One of my favorite things is hearing my little one make a reference to something they saw in the video game and make the connection to real life. Here is a short list that I was able to come up with
Africa - Far Cry 2
Alaska, United States - Red Dead Redemption 2
Blackwater, Missouri - United states - Red Dead Redemption 2 (Blackwater)
Chernobyl, Ukraine - Call of Duty 4: Modern Warfare, S.T.A.L.K.E.R
Chicago, Illinois - Watch Dogs
Donetsk, Ukraine - Call of Duty Warzone, Watch Dogs
Egypt- Assassins Creed
Hong Kong, China - Sleeping Dogs
Himalaya, Asia - Far Cry 4
Hollywood, California -Overwatch (Hollywood Map <-> Paramount Studios)
Italy - Assassins Creed 2 and Assassins Creed Brotherhood, Forza Horizon 2, Final Fantasy XV (Altissia), Dark Souls (Anor Londo)
Los Angeles, California - L.A. Noire, Grand Theft Auto: San Andreas
Louisiana, United States (Parts of it) - Red Dead Redemption 2
Las Vegas, California - Fallout: New Vegas
Manchester, England - Resistance: Fall of Man
Miami, Florida - Grand Theft Auto: Vice City
Moscow, Russia - Metro 2033
New Orleans, United States - Red Dead Redemption 2
Northeast Colonial America - Fallout 4
New York, New York - Grand Theft Auto 3 & 4, The Division, Marvel’s Spider-Man, The Warriors
Paris, France - Assassins Creed Unity
San Francisco, California, United States - Watch Dogs 3
Seattle, Washington, United States - Infamous Second Son, The Last of Us 2
Syria - Assassins Creed
Thailand - Tomb Raider Underworld
Tokyo, Japan - Persona 5, Yakuza
Washington, DC, United States - The Division 2, Fallout 3
Yosemite Valley, California, United States - Red Dead Redemption 2
Here is a cool list on a map. Feel free to contribute. Map
October 4, 2022
Subscribe to my newsletter to get notified of new posts