AI-generated Vegan Recipe Site
I recently came across Fly.io’s article on LangChain. I decided to give it a spin and created my own Vegan Recipe site based on the template they gave. You can check it out here: https://greatvegan.recipes. Note that the design kinda sucks because I (unfortunately) am not a designer. Sorry!
Apple is Effectively Paying You to Borrow Money from Them
With the introduction of the Apple Savings Account, Apple is now effectively paying you to borrow money from them. All you have to do is:
- Add money to your Apple Savings account. This money will be used to pay off your Apple Card balance at the end of the month.
- Remember to pay off your Apple Card in full every month so that you are not charged interest.
Back in my finance days, we would have called this
arbitrage. Big win for us Apple customers!
Video Game Data Linear Regression
Today I was experimenting with the new Elixir Scholar library. My goal was to translate the following Colab: https://colab.research.google.com/drive/1Jq1QLC9x7PoovRdJbLKi_Pj_pm9l-6No
You can find the Livebook where I translated that Colab to Elixir here: https://github.com/danieljaouen/video-game-data/blob/main/video_game_data.livemd
As you can see if you run the Livebook, linear regression probably wasn’t the best model here, but I was just using this as a Scholar learning exercise, so I am pretty happy with how this turned out. We probably would have had better results had we removed the outliers, but I will leave that as an exercise for the reader.
I recently installed OpenSUSE Tumbleweed on an old laptop I had lying around my apartment. I did so to test out my new install script ( https://github.com/danieljaouen/dotfiles/blob/main/install.sh ) which still had some rough edges (and still does). I figured I’d write a blog post about the setup process along with some comments.
First, I thought the installer was very intuitive. I didn’t keep the old Windows partition, so partitioning was a breeze with the installer. Just a few clicks to get everything partitioned. Overall, the process took about half an hour total. Not bad!
I also like that SUSE offers a rolling release in the form of Tumbleweed. I have some experience with Arch, so that is a nice touch. Nothing beats not having to upgrade your system every so often.
One thing I’ve read is that OpenSUSE doesn’t have some popular packages. While most of the packages in my installer script were available, I did notice that
dufwas not. I recently installed Arch on a server and noticed it did have
duf. Not a big deal, but something to watch out for if you do want to install OpenSUSE.
Overall, my experience so far with OpenSUSE has been pleasant. You can download the installer here: https://get.opensuse.org/tumbleweed/. Hopefully, this has been helpful to you. Have a great day!
emacsclient and fzf
I recently came across Andrew Quinn’s article on fzf: https://andrew-quinn.me/fzf/
I just thought I’d add that, you can open up a fzf-inded file in
emacsclientby typing into your terminal
Of course, you will need to have
Hey there! Tonight I was feverishly working on a basic Phoenix 1.7.0 app that lets me store various links. The goal was to build out a site that would replace having to keep a whole bunch of tabs open in my laptop and mobile browsers. Here it is: https://loulinks.net. Enjoy!
ChatGPT and Flask
I recently used ChatGPT to generate a Flask app that automatically generates the current price of Solana. You can check it out here: https://github.com/danieljaouen/chatgpt-solana-price
Wishing you and your close ones a very Happy Holidays! May the worst times of your 2023 be as the best times of your 2022. 🙂
A Brief Introduction to Phoenix and LiveView (Part 2)
This is a continuation of Part 1, which you can find here:
Now, let’s navigate to the
index.html.heexfile, which is located in
The first thing we encounter is something that looks like an HTML tag, but is actually a LiveView function component. We can tell that it is a function component because it begins with a
.. You can find the definition of the header component in
lib/todo_web/components/core_components.ex. We can see that it has a class attr, an inner_block, a subtitle, and associated actions slots.
:actions, we see that there is a
.link. This is defined in LiveView itself (see:
deps/phoenix_live_view/lib/phoenix_component.ex— search for “
def link“. Feel free to also read the documentation at the top of the file). You can find the documentation for the
patchattr in the file listed above (search for
"attr.(:patch"). The long and short of it is that
/todo_items/newis first translated into a Verified Route (note the
~psigil), which then will call
Next, we have a
.table. You can also view this function component in
lib/todo_web/components/core_components.ex. Basically, the table function component has three attrs (
rows) and a slot
colwhich takes an optional attr
labelplus a slot
rowsattr passes each list item into the
:letslot of the associated slot, and the
JS.navigate, which will, in turn navigate the page to the
show.exLiveView. You can learn more about the
JSmodule here: https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.JS.html
Next, we have the
modalfunction component, which is displayed only when the
[:new, :edit]. Basically, it renders a LiveComponent, which you can find in
lib/todo_web/live/todo_item_live/form_component.ex. You can read more about LiveView’s LiveComponent’s here: https://hexdocs.pm/phoenix_live_view/Phoenix.LiveComponent.html
And that’s it! Now we navigated through
index.html.heex, so you should have a better understanding of function components and where you can find the docs for them.
Again, if you gained value from this article, feel free to throw me a dollar or two on my Buy Me a Coffee page, which you can find here: https://www.buymeacoffee.com/danieljaouen
Thanks for reading!
A Brief Introduction to Phoenix and LiveView (Part 1)
I will assume that you have Elixir 1.14 installed. We are going to be using Phoenix version 1.7 in this tutorial. To install it, run the following command in your terminal:
mix archive.install hex phx_new
You may need to uninstall your previous version first (if you had it installed already):
mix archive.uninstall phx_new
Creating the App
Great! Now, let’s begin our Phoenix project by using the
mix phx.new todo
Great! Now let’s
cdinto the new
tododirectory and run the following commands:
Great! That created the initial PostgreSQL database for us. Now, let’s run the following command to make sure everything was set up correctly:
iex -S mix phx.server
Now browse to
localhost:4000and you should see the Phoenix welcome page. If not, you will need to debug the reason you are getting your specific error.
Creating the Todos
First, let’s take a look at the help dialog that ships with Phoenix by running the following command:
mix help phx.gen.live
Feel free to read this at your convenience. Now, let’s create the Todos using the following command:
mix phx.gen.live Items TodoItem todo_items text:string
Next, follow the instructions printed to your terminal about modifying your
Next, run the generated database migrations:
Now restart the Phoenix server and re-navigate to
localhost:4000/todo_itemsand you should see the listing page for your TodoItems. Great!
Navigating the Generated Code
Now that we have the Todo app up-and-running, let’s navigate through the code to get a glimpse at how things work under the hood.
First, let’s take a look at index.ex, the generated Elixir code for the index LiveView. We notice five functions:
mountis called when the client connects and is used to set up the initial
socket. You will notice that there is no
renderfunction, and that is because Phoenix uses a particular convention to display its templates: if there is an associated
index.ex, that template will be used.
handle_paramsis called whenever we have a live navigation event. These events are what you would normally have separate HTTP requests for. You can learn more about
handle_eventis called whenever we have a JS “delete” event pushed to the page. Finally,
list_todo_itemssimply calls the associated context’s function.
Join me next time when we dive into
index.html.heex. In the mean time, feel free to browse through the additional generated code.
If you gained value from this post, feel free to throw me a dollar or two on my Buy Me a Coffee page, which you can find here:
Your support goes to the cost of keeping the server up and is never unappreciated. Thanks!