1. Open vim 2. Enter `:e ++ff=dos` 3. Enter `:set ff=unix` 4. Save it
dev-log
From bottom to top, from top to bottom
Wednesday, February 14, 2024
Thursday, May 24, 2018
vimrc - Check the file encoding before write and change it to what you want
I wanted to save almost every files into euc-kr encoding. But my system uses utf-8 as the default character set.
Therefore, I needed to check the file encoding before saving files and change it if necessary.
Here is what I added to my vimrc script to do this.
Therefore, I needed to check the file encoding before saving files and change it if necessary.
Here is what I added to my vimrc script to do this.
Sunday, May 13, 2018
Detect unicode encoding from BOM (Byte order mark)
To work with strings in a file, I need to know in which unicode the file is encoded. The kind of magic number which is called BOM (Byte Order Mark) let you know which unicode is used.
For more information about BOM, you can get it from wikipedia.
Here is the python code to find out which unicode is used.
For more information about BOM, you can get it from wikipedia.
Here is the python code to find out which unicode is used.
Friday, January 12, 2018
Translate the number of ethernet frames into bps
How to calculate bps based on the number of ethernet frames?
To do this, I need to know the frame size of a ethernet frame.
Based on Wikipedia page explaining ethernet frame, a frame size on the layer 1 (physical layer) is 84 bytes for a 64 byte ethernet frame.
Minimum ethernet frame size is 64 bytes including 14 byte ethernet header and 4 bytes of CRC after the payload.
On layer 1, 8 bytes for the preamble and the frame delimiter and 12 bytes of inter-frame gap are also needed. Therefore, you need 84 bytes for the 64 bytes ethernet frame on layer 1.
The table below is from Wikipedia.
To do this, I need to know the frame size of a ethernet frame.
Based on Wikipedia page explaining ethernet frame, a frame size on the layer 1 (physical layer) is 84 bytes for a 64 byte ethernet frame.
Minimum ethernet frame size is 64 bytes including 14 byte ethernet header and 4 bytes of CRC after the payload.
On layer 1, 8 bytes for the preamble and the frame delimiter and 12 bytes of inter-frame gap are also needed. Therefore, you need 84 bytes for the 64 bytes ethernet frame on layer 1.
The table below is from Wikipedia.
Layer | Preamble | Start of frame delimiter | MAC destination | MAC source | 802.1Q tag (optional) | Ethertype (Ethernet II) or length (IEEE 802.3) | Payload | Frame check sequence(32‑bit CRC) | Interpacket gap |
---|---|---|---|---|---|---|---|---|---|
7 octets | 1 octet | 6 octets | 6 octets | (4 octets) | 2 octets | 46‑1500 octets | 4 octets | 12 octets | |
Layer 2 Ethernet frame | ← 64–1522 octets → | ||||||||
Layer 1 Ethernet packet & IPG | ← 72–1530 octets → | ← 12 octets → |
Let's suppose that you received 1,400,000 frames per second.
1,400,000 frames * 84 bytes * 8 = 940800000 bits
As a result, 1,400,000 FPS can be translated into 940.8 Mbps.
Thursday, January 11, 2018
The history about getting started Saleor on OS X El Capitan
I log what I do to get started a simple shopping mall with Saleor.
The whole procedure is followed on the Saleor's "Getting started" document.
As a result, I got Node.js v9.3.0 and webpack installed.
When I did "npm install", shell could not find npm. To make it work, I did "nvm use stable".
The whole procedure is followed on the Saleor's "Getting started" document.
Prerequisites
Install python
I use pyenv, so that I installed Python version 3.5.1 via the pyenv. I also created the virtual env and upgraded the pip. In this case, I wanted the name of the environment to be "pot".
- pyenv install 3.5.1
- pyenv virtualenv 3.5.1 pot
- pip install --upgrade pip
Install Node.js and webpack module bundler
I wanted to install Node.js via NVM. I followed the instruction from Junsik's Blog.As a result, I got Node.js v9.3.0 and webpack installed.
- curl https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
- nvm install stable
- npm i webpack -g
Install PostgreSQL
I chose the simplest way which is installing Postgres.app. Downloaded it from Postgres.app website and installed it.
Installation
Before the installation, I cloned the source of Saleor on the directory named saleor.
When I tried to install the requirements from "requirements.txt" using pip, I got the error described by the issue of uwsgi. I solved the error with the comment by "gicornachini". After this, I could install the whole packaged from "requirements.txt".
- pyenv activate pot
- cd saleor/
- pip install -r requirements.txt
Prepare Database
- Add the path where the client programs of Postgres are located to ${PATH} (If necessary). After this, restart the terminal.
echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp - Create user (role) with the name you want. -s option makes the user having superuser privilege. -W option force password prompt.
createuser ${USERNAME} -s -W - Find database setting in settings.py and modify it with the name you created.
-- default='postgres://saleor:saleor@localhost:5432/saleor'
++ default='postgres://${USERNAME}:{PASSWORD}@localhost:5432/saleor' - Create database named "saleor"
createdb saleor - Migrate
python manage.py migrate
Prepare front-end
- npm install
- npm run build-assets
Run server
Now, it is ready to run server. Let's get it.
- python manage.py runserver
- Access https://localhost:8000 on your web browser
Wednesday, January 13, 2016
Subscribe to:
Posts (Atom)