Right now, I am reading Django for Beginners [1] which is available in EPUB. I could read it in PDF but the experience will not be the same.
1,929 karma · joined July 27, 2014
Right now, I am reading Django for Beginners [1] which is available in EPUB. I could read it in PDF but the experience will not be the same.
Using GNU Stow to manage your dotfiles (2022) https://news.ycombinator.com/item?id=32253018
def createUser(attributes, "admin") do
create(attributes) |> setupAdmin |> setupNotifications
end
def createUser(attributes, "customer") do
create(attributes) |> setupCustomer |> setupNotifications
end
# example
User.createUser(%{name: "laura", age: 30}, "admin")
Here, we chain functions using a pipe, |>, assuming that each function returns a user-like variable, like %User{}I also liked the idea of using a callback for decoupling code (although that approach was discouraged by many users in this post). It could be done in Elixir as follows:
def createUserCallback(attributes, callback) do
create(attributes) |> callback.() |> setupNotifications
end
# example
User.createUserCallback(%{name: "laura", age: 30}, &User.setupCustomer/1)
User.createUserCallback(%{name: "laura", age: 30}, &User.setupAdmin/1)
Since callback can be any kind of function, we can use pattern matching to enforce that the return type of each function is a user, ie %User{}: def createUserCallback(attributes, callback) do
user = %User{} = create(attributes)
user = %User{} = callback.(user)
user = %User{} = setupNotifications(user)
user
end
Another approach is using a @spec annotation to define the signature of the callback.Full code:
defmodule User do
defstruct name: nil, age: nil, type: nil
defp create(_attributes = %{name: name, age: age}) do
%User{name: name, age: age}
end
defp setupNotifications(user = %User{}) do
IO.puts("User created #{user.type}: #{user.name}")
user
end
def setupAdmin(user = %User{}) do
%User{ user | type: "admin" }
end
def setupCustomer(user = %User{}) do
%User{ user | type: "customer" }
end
def createUser(attributes, "admin") do
create(attributes) |> setupAdmin |> setupNotifications
end
def createUser(attributes, "customer") do
create(attributes) |> setupCustomer |> setupNotifications
end
def createUserCallback(attributes, callback) do
user = %User{} = create(attributes)
user = %User{} = callback.(user)
user = %User{} = setupNotifications(user)
user
end
endhttps://stackoverflow.com/questions/3241929/python-find-domi...
https://dev.to/producthackers/creating-a-color-palette-with-...
$ time wget https://download.virtualbox.org/virtualbox/6.1.28/virtualbox-6.1_6.1.28-147628~Ubuntu~eoan_amd64.deb
real 0m8.515s
user 0m0.125s
sys 0m0.487s
According to [2], user + sys would be a better measurement than real for comparing Python, Cython, and C++.[1] https://www.hostinger.com/tutorials/linux-time-command
[2] https://stackoverflow.com/questions/10265162/the-meaning-of-...
I like to play with new toys. However, it's hard to find solutions for novel tech, though.
I just noticed that ~/.vimrc adds a small delay, even if it is empty. This is the test case:
Create a file with about 10 emtpy lines and type:
esc switch to normal mode
gg go to the top
ctrl + v, G select all lines
shift + i switch to insert mode
- line just type something
esc this will duplicate the first line until the end of the file
If you repeat the test case with no ~/.vimrc, you will notice that the lines are changed faster.- Show in Breadcrumb to show the package name > class > function in the top of the editor
- Open Call Hierarchy to show all places where a class/variable is used.
- Show Type Hierarchy to show how a given class is derived from Object.
- Debug Shell for running snippets in the debugger.
I know that I can use grep or ag for some of them, but I rather prefer to see the hierarchy as shown in Eclipse.
- The login page (gdm3) does not detect when I touch the touchpad. I need to press it hardly to get a click. I read somewhere that it is a feature for tablet-like devices.
- For some unknown reason, gdm3 is listening for click events. As a result, I cannot use my touchpad in i3. The only fix I've found is to install Xubuntu. So I end up installing Ubuntu, i3, and Xubuntu in that order. The login page of Xubuntu (lightdm) does not mess with the touchpad in i3. You can say, just install lightdm alone. However, that does not work, though.
- Regarding snaps, my only complaint is the file dialogs of Firefox (file chooser, save as...) in i3. Again, some process is capturing events. Every time I want to type a file name when saving a file, the dialog instead trigger the autocomplete menu. So instead of typing the name for saving the file, the dialog shows me file matches. Very annoying. That only happens in i3.
[1] https://rxi.github.io/lite_an_implementation_overview.html
I would like to use a tool like Tauri or Wails that relies on Python and that let me choose the underlying framework (Django, Flask, etc). That will be great for packaging a web application as an executable.
> But another important goal is inventing new methods, new techniques, and yes, new tricks. In the history of science and technology, the engineering artifacts have almost always preceded the theoretical understanding: the lens and the telescope preceded optics theory, the steam engine preceded thermodynamics, the airplane preceded flight aerodynamics, radio and data communication preceded information theory, the computer preceded computer science.
[1] https://www.reddit.com/r/MachineLearning/comments/7i1uer/n_y...
> Convinced me to leave Java and start doing Ruby instead. Did a lot more programming languages since then.
So you did not like the book?