A incorrigible idealism

  • Emacs/Linux/C/C++…
  • There is only one heroism in the world: to see the world as it is and to love it.
  • About me

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....

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....

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