Redis and Memcached

Main difference Redis Memcached in-memory (except OOM or AOF/RDB enabled) data store and it is not volatile in-memory cache and it is volatile has data types no data types keys with a maximum size of 512MB and also values up to 512MB keys with a maximum size of 250B and values up to 1MB How Redis achieves persistence Redis supports persistence, thus it’s called a data store, in two different ways: ...

September 17, 2023 · 2 min · hengist

SICP

Building Abstractions with Procedures At first this book talk about elements of programming is interesting primitive expressions means of combination means of abstraction in this book we are going to use scheme language, and I use chicken interpreter, just because I like it’s interesting name. this language use prefix notation like this (+ 1 2 3 4 5 6 7 8 9) name something like value (define size 2) this associate the value 2 with the name size define procedure (define (suqare x) (* x x)) or (define square (lambda (x) (* x x)) this is some kind of syntactic sugar, but the lambda type is more essential. a good question asked at the end of first class, what's the difference between the following two expressions (define a (* 5 5 )) (define (b) (* 5 5)) a ==> 25 (a) ==> Error: call of non-procedure: 25 b ==> #<procedure (b)> (b) ==> 25 applicative order versus normal order “fully expand and then reduce” method is normal-order, and “evaluate the arguments and then apply” method is applicative-order evaluation, and the second method is the interpreter actually uses. partly because of the additional efficiency obtained from avoiding multiple evaluation of expressions, and more significantly, normal-order evaluation becomes much more complicated to deal with when we leave the realm of procedures that can be modeled by substitution. ...

August 6, 2023 · 2 min · hengist

One bug I encountered and some thoughts

I met a bug recently, it’s because I didn’t notice the return value of a system call, and use it directly, sadly the compiler not be able to identify this kind problem, until I run it, I notice the program will never enter one condition. finally I found the getenv system call returns char* and I compare it with a string in C++, so this will not equal forever. This reminds me a book called Algorithms + Data Structures = Programs. I must know what data structure I manipulated with. Under this promise, I will write good and correct programs. So deal with function input well is a good habit with doubt. ...

July 30, 2023 · 1 min · hengist

Default value of function

Should I set default value when write a function, and where to set? In the declaration or the implementation the answer is in the declaration, and should in header file. In case of other part uses this function and not set a default value, if set a default value in the implementation, the other file included this file can’t know what default value is, and not able to compile it. For example ...

July 27, 2023 · 1 min · hengist

cryptography

common sense there are five solution to solve unser problems symmetric cryptography public-key cryptography hash Message Authentication Code Digital Signature threat speciality solution eavesdrop Confidentiality 1 & 2 falsity Integrity 3 & 4 & 5 disguise Authenticity 4 & 5 denial Nonrepudiation 5 shoule use public crypto algorithm, instead of private crypto algorithm cryptography in history caesar cipher just brute-force attack #include <cctype> #include <iostream> using namespace std; void func(string s) { for (int i = 0; i < 26; ++i) { string temp(s); for (auto &c : temp) { c = tolower(c); c = ((c + i) - 97) % 26 + 97; } cout << temp << endl; } } int main() { string s; cin >> s; func(s); } simple substitution cipher Letter_frequency ...

July 24, 2023 · 2 min · hengist

Git via HTTPS

It’s always frustrating to use Git because of some wall. I recently read a blog from manateelazycat, he suggests a way to use Git via HTTPS, just need to edit ~/.ssh/config and add the following config in it Host github.com Hostname ssh.github.com Port 443 User git Test it ❯ ssh -T git@github.com Hi <USERNAME>! You've successfully authenticated, but GitHub does not provide shell access. Git via HTTPS

July 18, 2023 · 1 min · hengist

name conflict multiple libs

Here is the Question /*A.c*/ #include <stdio.h> int sayHi() { printf("Hi, this is AAAAA\n"); return 0; } int sayOut() { sayHi(); printf("Use this to introduce AAAAA\n"); return 0; } /*B.c*/ #include <stdio.h> int sayHi() { printf("Hi, this is BBBBB\n"); return 0; } int sayOut() { sayHi(); printf("Use this to introduce BBBBB\n"); return 0; } #include <stdio.h> extern int sayOut(); int main() { sayOut(); return 0; } # if link A first >gcc test.c -L. -lA -lB >./a.out Hi, this is AAAAA Use this to introduce AAAAA # if link B first >gcc test.c -L. -lB -lA >./a.out Hi, this is BBBBB Use this to introduce BBBBB First solution at first i use dlopen to explicitly load a dynamic library ...

July 6, 2023 · 3 min · hengist

Zlib is still alive

as far as we know, zlib was forced to shut down by the USA government. However, it still remains available on the dark web, we can visit it through the tor-browser, and its address is posted on the Wikipedia, Here is the address: loginzlib​2vrak5zzpcocc3ouizykn6k5qecgj2tzlnab5wcbqhembyd.onion

July 6, 2023 · 1 min · hengist

Build IDE with emacs

I am not recommended to build from scratch, there are several community driven configuration framework, like Doom Emacs Spacemacs… etc. I am highly recommend to use Doom Emacs, it’s very easy to install, just follow it’s Getting Started Guide After install it, open it and type spc+f+p to open config file, int the init.el ,we can Remove comments to enable some feature(make sure to execute doom sync to install the feature), like cc, python, and so many tools that can help us to do many things. ...

July 5, 2023 · 1 min · hengist

Advantages using Gentoo

After using several Linux distributions, it hard for me to find one suit me well, I have been using openSUSE TW for about two years, it is an excellent system, help me and take care of all the miscellaneous. But when I started getting involved with Linux Kernel, I would like to try some interesting features like the musl libc and no-multilib system, and it is easy to customize my own system from kernel to software. If a want a feature I can tell the system I need it and recompile the software, of course other system can do that too, but Gentoo offers the most convenient way to do such thing through it’s “USE flag”. ...

July 4, 2023 · 1 min · hengist