Jacob Padilla Profile Banner
Jacob Padilla Profile
Jacob Padilla

@jpjacobpadilla

Followers
927
Following
135
Media
52
Statuses
108

I’m an NYU Stern student, photographer, open-source developer, and blogger. Projects: Photography & Articles 👇

NYC / Boston
Joined October 2021
Don't wanna be here? Send us removal request.
Explore trending content on Musk Viewer
@jpjacobpadilla
Jacob Padilla
1 year
The easiest way to make a QR code in #Python !
Tweet media one
1
7
25
@jpjacobpadilla
Jacob Padilla
1 year
🐍 #Python tip: Want to print out a specific month's calendar? Use Python's built-in calendar module!
Tweet media one
1
3
18
@jpjacobpadilla
Jacob Padilla
11 months
🐍 #Python Tip: You can use the assignment expression (walrus operator :=) in while loops to both get input and check conditions in a single line!
Tweet media one
0
8
18
@jpjacobpadilla
Jacob Padilla
11 months
The requests package is excellent, but it has no Asyncio support :( HTTPX uses an API similar to the requests package but does have Asyncio and HTTP2 support!
Tweet media one
0
11
21
@jpjacobpadilla
Jacob Padilla
11 months
#Python tip: Use the pathlib module to get your current working directory!
Tweet media one
3
9
19
@jpjacobpadilla
Jacob Padilla
11 months
In #Python 3.12 you can use itertools.batched() to batch iterables into smaller, more manageable chunks!
Tweet media one
1
9
18
@jpjacobpadilla
Jacob Padilla
1 year
#Python tip: Ever wondered how to dynamically retrieve the source code of a function? Use inspect.getsource() (it returns a string)!
Tweet media one
1
5
15
@jpjacobpadilla
Jacob Padilla
11 months
By default, Pandas opts for float64 and int64 for numerical columns, which isn't always memory-efficient. If you know your data's range, you may want to consider using the dtype argument to optimize memory usage when loading data.
Tweet media one
2
6
18
@jpjacobpadilla
Jacob Padilla
1 year
Want to dissect a URL into its components in #Python ? Use urlparse from urllib.parse!
Tweet media one
4
8
16
@jpjacobpadilla
Jacob Padilla
11 months
Enum classes in #Python make your code more readable! Define categories with the Enum Python module and use auto() for automatic numbering.
Tweet media one
2
5
14
@jpjacobpadilla
Jacob Padilla
11 months
Use the #Pillow package in Python to change the brightness of your images in #Python !
Tweet media one
0
6
17
@jpjacobpadilla
Jacob Padilla
11 months
Simplify your resource management in #Python with multiple context managers in a single 'with' statement. 🛠️🐍
Tweet media one
1
5
15
@jpjacobpadilla
Jacob Padilla
1 year
Don't forget about the else statement in #Python for-loops! If you don't break out of the loop, the code inside of the else statement will be executed!e
Tweet media one
0
4
11
@jpjacobpadilla
Jacob Padilla
1 year
Control the number of threads accessing a shared resource concurrently with a #Python semaphore! In the example, every instance of the "MyThread" class represents an individual thread. All these instances can access the shared class variable "semaphore". This variable is an
Tweet media one
0
5
12
@jpjacobpadilla
Jacob Padilla
11 months
Change the color of text output with ANSI Escape Codes! #Python
Tweet media one
1
4
11
@jpjacobpadilla
Jacob Padilla
1 year
Harnessing the * operator in Python! 🐍 a gets the first item *b collects all middle items c gets the last!
Tweet media one
2
4
13
@jpjacobpadilla
Jacob Padilla
11 months
🐍 #Python Tip of the Day: To sort a list of tuples based on the second element, use the sorted() function with a lambda key:
Tweet media one
0
4
12
@jpjacobpadilla
Jacob Padilla
11 months
Make custom iterators in #Python with the __iter__ and __next__ dunder methods!
Tweet media one
0
4
10
@jpjacobpadilla
Jacob Padilla
11 months
Easily figure out if something is a file or a directory using the #pathlib module from the Python Standard Library 🐍
Tweet media one
4
6
11
@jpjacobpadilla
Jacob Padilla
11 months
Did you know that you can combine dictionaries in #python with |?
Tweet media one
0
2
12
@jpjacobpadilla
Jacob Padilla
1 year
Here's another urllib.parse function: it turns the query string part of a URL into a dictionary!
Tweet media one
1
2
10
@jpjacobpadilla
Jacob Padilla
1 year
🐍 #Python tip: Want to print your JSON data with proper indentation? Use the JSON module! This will display your JSON beautifully indented!
Tweet media one
1
5
8
@jpjacobpadilla
Jacob Padilla
1 year
#Python tip 🐍 You can use the zip() function to combine lists together and turn them into dictionaries!
Tweet media one
1
4
10
@jpjacobpadilla
Jacob Padilla
11 months
The reduce function in #Python can be very useful for applying a function in a step-by-step manner. Great for merging many Pandas DataFrames together!
Tweet media one
0
3
8
@jpjacobpadilla
Jacob Padilla
1 year
Did you know you can make an asynchronous list comprehensions in Python? #Python #pythonprogramming #Asyncio
Tweet media one
2
3
8
@jpjacobpadilla
Jacob Padilla
11 months
Handle async timeouts gracefully in #Python with asyncio's wait_for function! ⏱️🐍 #AsyncProgramming #CodeTips
Tweet media one
0
1
10
@jpjacobpadilla
Jacob Padilla
1 year
#Python tip: Use the glob module to search for files! 📂 In this example, I'm searching for all .py files in the directory that this Python code is running in: #coding #programming #developer #codeTips
Tweet media one
2
4
8
@jpjacobpadilla
Jacob Padilla
1 year
32 #Python dunder methods you should know for making custom classes: > __init__ & __new__: For object initialization and creation. obj = MyClass(args) > __str__: String representation of object. str(obj) > __repr__: Official representation. repr(obj) > __add__: Addition
2
4
6
@jpjacobpadilla
Jacob Padilla
1 year
Using contextlib.closing with #SQLite ensures database connections are always properly closed, even if exceptions occur! #pythonprogramming #python #SQL
Tweet media one
2
4
9
@jpjacobpadilla
Jacob Padilla
1 year
#Python Tip: Use textwrap.shorten() to truncate text at word boundaries!
Tweet media one
1
4
6
@jpjacobpadilla
Jacob Padilla
10 months
Learn how to use Argon2 for password hashing, store user data in an SQLite database, and manage sessions effectively with signed cookies! #Python
0
2
7
@jpjacobpadilla
Jacob Padilla
1 year
#Python tip: You can use the secrets module to generate passwords/keys!
Tweet media one
1
3
6
@jpjacobpadilla
Jacob Padilla
11 months
🐍 #Python Tip: Did you know you can use defaultdict with a lambda function to set custom default values? In this example, any non-existent key returns the string 'Jacob'. It's a powerful way to customize your dictionary's behavior! #PythonTips #FlexibilityInCode 💡
Tweet media one
0
2
5
@jpjacobpadilla
Jacob Padilla
11 months
@Python_Dv But what if you intentionally want to throw an exception if “age” is not in the dictionary…
0
0
5
@jpjacobpadilla
Jacob Padilla
1 year
How to make your own context managers in #Python I’m talking about the “with something as obj” statements. You just need to add __enter__ and __exit__ to your classes! Read how __enter__ & __exit__ actually work 👇
1
1
2
@jpjacobpadilla
Jacob Padilla
1 year
Due to the migrant crisis in #NYC and the bad government interface, getting an appointment to receive an #IDNYC card is nearly impossible. So, I made this API to scan the availability of IDNYC appointments across all dates, locations, and times. Version 1.0 is out now!
1
0
4
@jpjacobpadilla
Jacob Padilla
11 months
Some cool ChatGPT/DALL-E generated images:
Tweet media one
Tweet media two
Tweet media three
1
0
3
@jpjacobpadilla
Jacob Padilla
11 months
@driscollis Interesting! I’ve never used this before. What would the use case be for using this over a higher level package like Flask and a lower level thing like Asyncio streams?
3
0
3
@jpjacobpadilla
Jacob Padilla
1 year
#Python & #SQLAlchemy tip: You can set the isolation level of a Connection from Engine.connect(). See image for example! Possible values: "AUTOCOMMIT" "READ COMMITTED" "READ UNCOMMITTED" "REPEATABLE READ" "SERIALIZABLE"
Tweet media one
0
0
2
@jpjacobpadilla
Jacob Padilla
1 year
@adrian_horning_ Have you run into any problems with standardizing the output from the model?
1
0
2
@jpjacobpadilla
Jacob Padilla
11 months
@neetcode1 :%s/IDE/VIM/gi
0
0
2
@jpjacobpadilla
Jacob Padilla
11 months
@driscollis This is a great package!
0
0
1
@jpjacobpadilla
Jacob Padilla
1 year
Quick #Python Tip: You can send values to generators! After sending the value to the generator, Python will execute the code until the next yield statement.
Tweet media one
0
0
2
@jpjacobpadilla
Jacob Padilla
1 year
So just to be clear, port would not be None if there was a specific port after the domain. Example: 127.0.0.1:5000 would return a port of 5000. However, if port is None, you can infer the port via the scheme: 443 = https 80 = http
0
0
2
@jpjacobpadilla
Jacob Padilla
1 year
#Python tip: You can see a function's bytecode via the "dis" module
Tweet media one
0
0
2
@jpjacobpadilla
Jacob Padilla
11 months
@driscollis My favorite pip command is probably “pip show [package]”. Has come in handy a few times!
1
0
1
@jpjacobpadilla
Jacob Padilla
1 year
@saxboatsec It’s pretty handy! Although, I generally just use the glob method from pathlib these days.
1
0
1
@jpjacobpadilla
Jacob Padilla
11 months
@driscollis Seaborn 🌊
0
0
1
@jpjacobpadilla
Jacob Padilla
1 year
Which way do you run code inside a #Python virtual environment? METHOD 1: $ source venv/bin/activate $ python METHOD 2: $ venv/bin/python
Method 1
5
Method 2
3
2
3
1
@jpjacobpadilla
Jacob Padilla
9 months
In #Python , wrapping one object over another can result in the loss of valuable metadata; that's why using functools.wraps is crucial when developing your own Python decorators!
0
2
1
@jpjacobpadilla
Jacob Padilla
1 year
@raymondh Sounds like a Chicken-and-egg situation
Tweet media one
0
0
1
@jpjacobpadilla
Jacob Padilla
9 months
Learn how to deploy Uptime Kuma on Google Cloud's free Virtual Machines with Docker, monitor websites, and configure instant Slack alerts for site issues.
0
1
1
@jpjacobpadilla
Jacob Padilla
11 months
@bill2bond As far as I know, you can only use Headless Selenium in Google Colab since their is no GUI support on GC.
0
0
1
@jpjacobpadilla
Jacob Padilla
1 year
@Python_Dv Why not just use the built-in secrets module?
0
0
1
@jpjacobpadilla
Jacob Padilla
11 months
@GunalanD95 So you know how you can use a with statement with a single context manager like such: with Object as o: [code] Sometimes you may need to nest context managers like: with ObjectA as a: with ObjectB as b: [code] Well you can actually combine the first two lines!
0
0
1
@jpjacobpadilla
Jacob Padilla
1 year
You can also make async context managers!
Tweet media one
0
0
1
@jpjacobpadilla
Jacob Padilla
1 year
@driscollis Pillow is great!
1
0
1
@jpjacobpadilla
Jacob Padilla
1 year
@akshay_pachaar @driscollis Nice post! I’m curious how the two tables are actually joined together? Are both columns hashed and then joined? Is it a nested loop join? Merge join?
0
0
1
@jpjacobpadilla
Jacob Padilla
1 year
I can then use the context manager class as such:
Tweet media one
1
0
0
@jpjacobpadilla
Jacob Padilla
11 months
@adan_vivero It’s always time to debug
1
0
1