Posts

Showing posts from January, 2022

C Notes

#include <stdio.h> #include <string.h> int main(void) {     char f[] = "++++";     char c;     char m[11];     int i;     int o_size = 4;     int i_size = 1;          scanf("%c", &c);     memset(m, c, 10);     m[10] = 0;     for (i = 0; i < 5; i++) {         printf("%.*s%.*s%.*s\n", o_size, f, i_size, m, o_size, f);         o_size -= 1;         i_size += 2;     }     return 0; } e.g.: ends_with(filename, ".pdf.epub.mobi"); int ends_with(const char *string, const char *tail) {     const char *s1;     const char *s2;     if (!*tail)         return 1;     if (!*string)         return 0;     for (s1 = string; *s1; ++s1);     for (s2 = tail; *s2; ++s2);     if (s1 - string < s2 - tail)         return 0;     while (*--s1 == *--s2) { if (s2 == tail) return 1; } return 0; } faster bsearch: int monobound_bsearch(uint8_t *key, Digest_t **array, size_t nmemb, size_t size, int (*cmp)(const void *, const void *)) {     size_t mid, top, p

Crystal notes

(0..10).step(2) do |x|      puts x end --- x = ["the","end","game"] x[0..1].each() do |y|      puts y end --- # times method 2.times do |n|      puts n end --- # upto method 0.upto(1) do |n|      puts n end --- For ranges it's simple: x..y defines a range from x to y inclusive and x...y defines a range from x to y exclusive. So if you want the same behavior as times use 0...n. For x.upto(y) there is only one version which will iterate upto and including y.

SQLite3 Regex

sudo apt install sqlite3-pcre sqlite3 /data/DBases/2022-01-housetemps.db -cmd ".load /usr/lib/sqlite3/pcre.so" "SELECT bed,downstairs,InsertedDatetime FROM housetemps WHERE InsertedDatetime REGEXP '\d\d\d\d-\d\d-1[4,5]';"

Nodemcu flash commands

esptool.py.exe erase_flash esptool.py --baud 460800 write_flash --flash_size=4MB -fm=dout 0 esp8266-20210902-2MB-v1.17.bin