26 Mar 2024
Hi, it has been a while since I updated this blog.
To find my most recent updates, please follow my github profile at (https://github.com/jeffreywu1996) for some of the latest projects I am working on.
I will try to write up some blogs on deep diving into some of the projects when I find some time.
Some projects I am currently working on:
-
Microservice based barista service written with fastapi and postgres (https://github.com/jeffreywu1996/barista-order-service)
-
Eufy streaming security camera ML project (https://github.com/jeffreywu1996/eufy-video-streaming)
-
Virtual world with cars (https://github.com/jeffreywu1996/simulated-network-scenarios) - Need to move to new repo.
22 May 2018
I work quite a bit with python, it’s my go to language whenever I need to a quick script to get something done.
In this guide, I will talk about:
- manage python with homebrew
- virtualenv
- virtualenv wrappper
What’s Homebrew
Homebrew (link) is a package manager for MacOS. If you are familiar with linux, it is the equivilant of apt-get
.
I use homebrew to install and update most of my development tools.
Installing python with Homebrew
Most modern system nowadays should have python installed but usually those python are never updated and are often outdated. You can check its version by typing python --version
in your terminal.
On the MacOS, the default python used is installed by Apple. This version of python is severly outdated (In fact, Apple still uses python 2 which is deprecated now.)
To begin, you should have homebrew installed. (link to install here) If you have not done so, go to the link provided.
Next, simply type brew install python
to install brew’s version of python. As of right now, brew automaticlly installs python 3 to the folder /usr/local/bin. (Default python is at /usr/bin).
To update python, just type brew update
and brew upgrade
. The update will download the new versions of its dependencies and the upgrade will actually upgrade to the new versions.
Virtualenv
Virtualenv allows you to have multiple different development environments. What this means is that I can have a project that uses python 2.7 while another uses python 3.2. Or I might want the old selenium library for legacy code while in another project I will want the newest one.
Virtualenv, or virtual environments, allow you to setup a temporary development environment for each python project.
To install, type pip install virtualenv virtualenvwrapper
.
When you want to create a new virtualenv just type mkvirtualenv <env name>
to initialize a new virtualenv. To activate it, type workon <env name>
. To disable it, type deactivate
.
So there you go, I’ll update this later to talk more about the virtualenv.
WIP.
23 Jan 2018
My computer has been running slow recently from the random junk I installed onto my computer from these couple of years. Besides that, my battery started to discharge really fast – Even the “service battery” warning came up on the battery indicator sign on the top right of the screen.
So I thought since I have a free weekend coming up, I might as well try and factory reset my entire macbook and see if things get better. It will also be a nice way for me to clean up my computer.
When the weekend came, I wiped the entire computer clean. I reformatted the entire disk to make sure nothing gets saved. I wiped it so clean that when I booted up, there was nothing left of the computer, no Apple logo nor a BIOS, only a question mark showed up. I had to reinstall my OS thru the network recovery mode (by pressing ctrl + command + r at startup).
That went ok, and eventually I got my macbook reset to look like it was just out the box. (Well at least software wise.) Once everything is wiped, I had to start installing all the stuff I need on my computer. This includes stuff like chrome, alfred, vlc, iterm, and sublime. After I got all that I had to install the packages I need in the terminal. Those went easy since there was homebrew. Remember how to setup my vim and its color scheme was a lot of work that I can make another
post on it next time.
But anyways, today I was working on a computer security puzzle called the Buffer Overflow Attack. What it is is also for another post in the future. But anyways, I needed to use gdb to look at the stack. However, when I tried to run gdb, I keep getting an error of the lines of “Unable to find Mach task port for process-id 39655: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))”
This reminded me of how way back in sophmore year when I took the computer architecture class (CSE30) which was the first time I learned gdb. I remembered installing gdb on MacOS was a hassle.
Apparently, Apple does not allow programs to have that much of an access privilege that is needed for gdb. A program must be “code signed” for Apple to allow it to run.
Therefore, we had to “code sign” our gdb by creating a certificate saying that we should “trust” whatever program is in this certificate.
And here are the steps:
https://apple.stackexchange.com/questions/309017/unknown-error-2-147-414-007-on-creating-certificate-with-certificate-assist
23 Jul 2017
I never thought I would need to print out code on paper.
But that changed when my CSE 150 professor required us to turn in a hard copy of our source code for HW assignments. My first thoughts were the same as yours. why? lol. Isn’t turning it online much easier to grade?
But anyways, we just do whatever the professor wants us to right?
This seemed like a easy problem at first. I just go in my editor -> File
-> Print
. Easy right? Turns out no, or I wouldn’t write this post. My editor vim did not have the print option since is wrapper inside the terminal. Then, I thought, maybe sublime text would have the option to print code. And then again, it didn’t. Thus, I was stuck. But I still had to turn in my HW.
So I thought of a stupid and naive way, I just screenshot parts of my code as pictures and paste them in the word document and print.
This is what it look like. It got the job done, but it looked freakish. The image sizes were different so the code size were disproportionate and I hated it.
Then, after a couple unsuccessful searches on how to print out code on google (turns out not a lot of people still print code). I figured, vim must have some sort of way to do this.
I found two commands :TOhtml
and :hardcopy > out.ps
.
:TOhtml
outputs a html version of the code that looks exactly like how it looks on my vim editor. Coloring, code highlighting and line numbers are all there. All I had to do is to open the html file with chrome and print from chrome.
:hardcopy > out.ps
outputs a postscript file of the code. This code looks different from vim, but it still outputs.
The default settings did not print with line numbers so I had to add the line set printoptions=number:y
to my vimrc to get it to work. Overall, I feel this is uglier than TOhtml
which looked exactly the same as my terminal.
This is the code in my editor vim.
This is the output using :TOhtml
This is the postscript output using :hardcopy
Both options were native to vim and they both work fine. If you have a nice looking terminal colorscheme, then, :TOhtml
will be the choice for you. If you have an ugly terminal, don’t worry, :hardcopy
got you covered.
The takeaway from this experience is that vim really has every feature you would ever need.
23 May 2017
Writing blog post is fun, but pure text can be boring sometimes. And sometimes a picture is worth a thousand words. Therefore, today I am going to find out how to post images on my blog.
Update: I found a new sneaky way of uploading images.
The method below kind of breaks the https encrytion (the green lock at the top of the url address on your browser, and I don’t like it)
I am not exactly sure of why this happens. But the browser complained that the site is not secure anymore because
Attackers might be able to see the images you’re looking at on this site and trick you by modifying them.
I am not entirely sure what that means, but it does not seem very good.
To overcome that break of security of my site, I have found another way to upload picutres via github.
The trick is to create a issue on the any github repo, drag the image into the issues section and wait for it to upload. After it is done uploading, it will have a link of the picture. And viola, the picture is uploaded to github and you have a link to that picture.
Note. I also changed the picture example below to use the method I learned above to keep my website ‘secure’.
I found a guide here which includes instructions on how to host pictures on the blog.
There is two steps to putting up images on the site.
- First, I need to know how to put up the image on the blog. This can be accomplished easily with using Markdown (which we use to write our blog).
- Second, I need a location to put the image at. In other words, I need to host the image somewhere on the internet.
Show images using Markdown
Here’s a cheatsheet I found online that tells you how to put images up with markdown.
Host images on github
There are many ways to upload images on the internet. A simple google search will show image hosting sites avaliable for free. But why rely on those when we can do it ourselves. I have a minimalist mindset. If I can find a way to do it myself, then that will be the priority.
Since this blog is hosted on github itself, I can create a folder within that repository hosted by github and thus have a directory on the internet where I can host things.
First create a directory that will store the images that I will host.
I will call this directory /assets
Go to the directory of the blog, and type mkdir assets
.
Now, stuff in the /assets
can be accessed on the internet with the link.
For example if I have an image called huis-ten-bosch.png, then I can access it with the link http://jeffreywu1996.github.io/assets/huis-ten-bosch.png
Now, using this link with markdown, we should be able to finally put the image on the internet.
Let’s try it. This is a picture of me last summer at Huis Ten Bosch. Let’s see if it shows up.
Vola! Success.