From 52f86ea0075c66e18e4796ad88f45541da8b4de5 Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 7 Mar 2019 23:26:17 +0100 Subject: some cleanup and such --- 080_blog/00015_Admin/00005_Miscellanous/index.md | 866 --------------------- .../00015_Admin/00005_Notes-on-Hosting/index.md | 53 ++ 080_blog/00015_Admin/00008_Docker/index.md | 14 + .../00010_Various-Cheat-Sheets/00120_GDB/index.md | 29 + .../00020_Benchmarking-and-Stress-testing/index.md | 68 ++ 080_blog/00015_Admin/00030_Fixing-HDD/index.md | 48 ++ 080_blog/00015_Admin/00040_Oneliners/index.md | 41 + .../00090_Miguels-KVM-Adventures/index.md | 12 +- .../00030_The-Hell-of-Autotools/index.md | 74 ++ .../00040_Various-notes-on-Building/index.md | 93 +++ 080_blog/00018_Building/index.md | 3 + .../00035_A-quick-Trumpet-in-Blender/1.png | Bin 90433 -> 0 bytes .../00035_A-quick-Trumpet-in-Blender/2.png | Bin 741047 -> 0 bytes .../00035_A-quick-Trumpet-in-Blender/3.png | Bin 743011 -> 0 bytes .../00035_A-quick-Trumpet-in-Blender/4.png | Bin 728056 -> 0 bytes .../00035_A-quick-Trumpet-in-Blender/index.md | 25 - 080_blog/00020_3D-Art/index.md | 3 - .../00035_A-quick-Trumpet-in-Blender/1.png | Bin 0 -> 90433 bytes .../00035_A-quick-Trumpet-in-Blender/2.png | Bin 0 -> 741047 bytes .../00035_A-quick-Trumpet-in-Blender/3.png | Bin 0 -> 743011 bytes .../00035_A-quick-Trumpet-in-Blender/4.png | Bin 0 -> 728056 bytes .../00035_A-quick-Trumpet-in-Blender/index.md | 25 + 080_blog/00020_Visual-Art/index.md | 3 + 080_blog/00020_WWW-Projects-and-Apps/index.md | 91 +-- 080_blog/00030_The-Hell-of-Autotools/index.md | 74 -- 080_blog/00035_Programming/00010_IPC/.index.md.swp | Bin 0 -> 12288 bytes 080_blog/00035_Programming/00010_IPC/index.md | 24 + .../00015_Competitive-Coding/index.md | 17 + .../00020_Computer-Science-Literature/index.md | 48 ++ 080_blog/00035_Programming/index.md | 3 + .../00038_Theory/00010_Totient-Function/index.md | 16 + 080_blog/00038_Theory/index.md | 0 .../00040_Graham-Scan/index.md | 128 --- .../00065_Base64-Encoder/index.md | 51 -- .../00120_Lambda-Calculus/index.md | 38 - .../00130_Calculator-on-Parsec-and-GTK/calc.glade | 312 -------- .../00130_Calculator-on-Parsec-and-GTK/calc.hs | 74 -- .../00130_Calculator-on-Parsec-and-GTK/calc.png | Bin 22734 -> 0 bytes .../00130_Calculator-on-Parsec-and-GTK/index.md | 23 - .../00140_Minimalistic-SVG-Generator/SimpleSvg.hs | 179 ----- .../00140_Minimalistic-SVG-Generator/index.md | 31 - .../00140_Minimalistic-SVG-Generator/svg.png | Bin 13130 -> 0 bytes .../00200_Estatico-Page-Maker/index.md | 35 - 080_blog/00040_Haskell-Projects/index.md | 4 - .../00010_Links-and-Notes-and-Literature/index.md | 36 + 080_blog/00040_Haskell/00040_Graham-Scan/index.md | 128 +++ .../00040_Haskell/00065_Base64-Encoder/base64.cast | 322 ++++++++ .../00040_Haskell/00065_Base64-Encoder/index.md | 19 + .../00040_Haskell/00120_Lambda-Calculus/index.md | 38 + .../00130_Calculator-on-Parsec-and-GTK/index.md | 23 + .../00140_Minimalistic-SVG-Generator/index.md | 31 + .../00140_Minimalistic-SVG-Generator/svg.png | Bin 0 -> 13130 bytes .../00150_Applicative-vs-Monadic-Parsing/index.md | 1 + .../00200_Estatico-Page-Maker/index.md | 55 ++ 080_blog/00040_Haskell/index.md | 8 + 080_blog/00110_Fool-Operating-System/index.md | 9 + 56 files changed, 1285 insertions(+), 1890 deletions(-) delete mode 100644 080_blog/00015_Admin/00005_Miscellanous/index.md create mode 100644 080_blog/00015_Admin/00005_Notes-on-Hosting/index.md create mode 100644 080_blog/00015_Admin/00008_Docker/index.md create mode 100644 080_blog/00015_Admin/00010_Various-Cheat-Sheets/00120_GDB/index.md create mode 100644 080_blog/00015_Admin/00020_Benchmarking-and-Stress-testing/index.md create mode 100644 080_blog/00015_Admin/00030_Fixing-HDD/index.md create mode 100644 080_blog/00015_Admin/00040_Oneliners/index.md create mode 100644 080_blog/00018_Building/00030_The-Hell-of-Autotools/index.md create mode 100644 080_blog/00018_Building/00040_Various-notes-on-Building/index.md create mode 100644 080_blog/00018_Building/index.md delete mode 100644 080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/1.png delete mode 100644 080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/2.png delete mode 100644 080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/3.png delete mode 100644 080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/4.png delete mode 100644 080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/index.md delete mode 100644 080_blog/00020_3D-Art/index.md create mode 100644 080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/1.png create mode 100644 080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/2.png create mode 100644 080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/3.png create mode 100644 080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/4.png create mode 100644 080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/index.md create mode 100644 080_blog/00020_Visual-Art/index.md delete mode 100644 080_blog/00030_The-Hell-of-Autotools/index.md create mode 100644 080_blog/00035_Programming/00010_IPC/.index.md.swp create mode 100644 080_blog/00035_Programming/00010_IPC/index.md create mode 100644 080_blog/00035_Programming/00015_Competitive-Coding/index.md create mode 100644 080_blog/00035_Programming/00020_Computer-Science-Literature/index.md create mode 100644 080_blog/00035_Programming/index.md create mode 100644 080_blog/00038_Theory/00010_Totient-Function/index.md create mode 100644 080_blog/00038_Theory/index.md delete mode 100644 080_blog/00040_Haskell-Projects/00040_Graham-Scan/index.md delete mode 100644 080_blog/00040_Haskell-Projects/00065_Base64-Encoder/index.md delete mode 100644 080_blog/00040_Haskell-Projects/00120_Lambda-Calculus/index.md delete mode 100644 080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.glade delete mode 100644 080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.hs delete mode 100644 080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.png delete mode 100644 080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/index.md delete mode 100644 080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/SimpleSvg.hs delete mode 100644 080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/index.md delete mode 100644 080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/svg.png delete mode 100644 080_blog/00040_Haskell-Projects/00200_Estatico-Page-Maker/index.md delete mode 100644 080_blog/00040_Haskell-Projects/index.md create mode 100644 080_blog/00040_Haskell/00010_Links-and-Notes-and-Literature/index.md create mode 100644 080_blog/00040_Haskell/00040_Graham-Scan/index.md create mode 100644 080_blog/00040_Haskell/00065_Base64-Encoder/base64.cast create mode 100644 080_blog/00040_Haskell/00065_Base64-Encoder/index.md create mode 100644 080_blog/00040_Haskell/00120_Lambda-Calculus/index.md create mode 100644 080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/index.md create mode 100644 080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/index.md create mode 100644 080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/svg.png create mode 100644 080_blog/00040_Haskell/00150_Applicative-vs-Monadic-Parsing/index.md create mode 100644 080_blog/00040_Haskell/00200_Estatico-Page-Maker/index.md create mode 100644 080_blog/00040_Haskell/index.md create mode 100644 080_blog/00110_Fool-Operating-System/index.md (limited to '080_blog') diff --git a/080_blog/00015_Admin/00005_Miscellanous/index.md b/080_blog/00015_Admin/00005_Miscellanous/index.md deleted file mode 100644 index d247e7e..0000000 --- a/080_blog/00015_Admin/00005_Miscellanous/index.md +++ /dev/null @@ -1,866 +0,0 @@ -Miscellanous Notes -================== - -A collection of short notes on things I wish to remember. Many topics are heavily outdated. - -Backing up and Restoring Docker Volumes ---------------------------------------- - - July 3, 2017 - -One of my first questions, when starting my docker experience was -how to backup and restore docker volumes. - -### On the source host - -First of all identify your volumes: - - $ docker ps - $ docker inspect my_container_name | grep -C 1 -i Source - -Now you can backup the directory to a tar on your host machine: - - $ docker run –rm –volumes-from my_container_name -v $(pwd):/backup ubuntu tar cvf /backup/backup_db.tar /var/lib/mysql - -### On the target host - -In order to securely copy and restore the volume on the target host one can run: - - $ scp source_host:~/backup_db.tar . - $ docker run –rm –volumes-frommy_container_name -v $(pwd):/backup ubuntu bash -c “cd /var/lib/mysql && tar xvf /backup/backup_db.tar –strip 1″ - -A Growing Collection of Linux Command Line One-Liners ------------------------------------------------------- - -Please believe me... this collection was really supposed to grow over time... - -inside a direcotry show disk usage of all hidden files and directories and sort by size: - - $ du $(ls .* -d | tail -n +3) -hs |sort -h - -inside a direcotry show disk usage of all files and directories (also hidden) and sort by size. -Exclude ./DATA file. - - $ du . -a -d 1 -h –exclude=’./DATA’ | sort -h - -Tar all files in current directory, excluding ./DATA and ./.cache - - $ tar –exclude=’./.cache’ –exclude=’./DATA’ -cvf home_miguel_20180216.tar . - -Find files in ./ARCHIVE NOT belonging to a specific user: miguel - - $ find ARCHIVE/ \! -user miguel - -set folder/ permissions to Read/Browse only for owner recursively - - $ sudo chmod -R u=r,g=,o= folder/ - $ chmod -R u=rX,g=,o= folder/ - -find all mails from Boban when in the maildir full of mailboxes and print only short headers without bodies: - - $ grepmail -H -B -Y ‘(^TO:|^From:)’ Boban * - -not really a one-lier but will print 256 colors in a bash: - - for i in {0..255} ; do - printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i" - if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then - printf "\n"; - fi - done - -Some Tools of Choice --------------------- - -### Systems - -* joomla -* redaxo -* typo3 -* wordpress -* mediawiki - -* oscommerce -* opencart - -* owncloud -* alfresco -* mantis - -* piwik / matomo -* loganalyzer -* goaccess -* nagios / icinga - -### Servers - -* apache -* nginx - -* mariadb / mysql -* postfix -* postgis - -* geoserver - - - -Compilation Notes ------------------ - -### build your own webkit - - March 14, 2018 - -Let’s compile a release with debug info and install to /usr/local - -~~~~~~ {.bash} -wget https://webkitgtk.org/releases/webkitgtk-2.20.0.tar.xz -tar -xvf webkitgtk-2.20.0.tar.xz -cd webkitgtk-2.20.0 -# install all the libs that will be reported missing in the next step. -# I could not find the woff2 stuff in debian so skipped it... -cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_WOFF2=NO -GNinja -# this takes about 30minutes on my i7-4790K .. zzzzz..zzz -ninja -sudo ninja install -~~~~~~~~~~~ - - pkg-config - - pkg-config uses our new build now: - - [1] https://trac.webkit.org/wiki/BuildingGtk - [2] https://webkitgtk.org/ - -### Build and Install GCC - - April 27, 2015 - -#### Preparations -Read the prequisites at -[https://gcc.gnu.org/install/prerequisites.html](https://gcc.gnu.org/install/prerequisites.html) -and get (most recent versions at time of this writing) the following: - -* gcc (5.2.0) -* binutils (2.25.1) - -#### Configure and Build - -* unpack binutils-x.y.z -* create a new directory binutils-x.y.z-build and inside it run the following commands: - -~~~~~~ {.bash} - $ ../binutils-x.y.z/configure --disable-nls --with-sysroot --enable-targets=all - $ make -j4 - $ make install -~~~~~~~~~~~~ - -* unpack gcc-x.y.z and run the contrib/download_prerequisites script inside. -* create a new directory: gcc-x.y.z-build and inside it run: - -~~~~~~ {.bash} - $ ../gcc-x.y.z/configure --disable-nls --enable-languages=c,c++ --enable-threads - $ make -j4 - $ make install -~~~~~~~~~~~~ - -#### Reference - [1] binutils and gcc README files. - [2] https://gcc.gnu.org/install/ - [3] http://wiki.osdev.org/Building_GCC - [4] http://stackoverflow.com/questions/1726042/recipe-for-compiling-binutils-gcc-together - -monad transformers in action ----------------------------- - January 1,2018 - - *Main Control.Monad.Writer Control.Monad.State> runState (runWriterT (get >>= \a -> tell ["foo"] >> put (a*a) >> tell ["bar"] >> tell [show a])) 5 - -emscripten ----------- - October 1,2017 - - sdl2 port - https://github.com/juj/emsdk - android-ndk-r15c - - * accomplish build sys with: sdl2+input+audio+opengl+SDL_net+SDL_thread @ linux, win, osx, ios, android, win-phone, steam, rasp - -LUKS container over sshfs -------------------------- - July 5, 2017 - -* enable user\_allow\_other in /etc/fuse.conf -* sshfs -o allow\_root user@server:/BACKUPS/ ~/mnt/ -* dd if=/dev/urandom of=~/mnt/megaloman bs=1M count=512 -* sudo cryptsetup -y luksFormat ~/mnt/megaloman -* sudo cryptsetup luksOpen ~/mnt/megaloman vol1 -* sudo mkfs.ext4 /dev/mapper/vol1 -* sudo mount /dev/mapper/vol1 /mnt -* df -h | grep vol1 -* sudo umount /mnt -* sudo cryptsetup luksClose vol1 -* fusermount -u ~/mnt - -NOTE: backup your data example use : rsync -a –info=progress2 source dist - -some areas of interest ----------------------- - December 20, 2014 - -Some General Topics I am reasearching right now (or plan to do it). Or used to reasearch... - -* Neuronal Networks -* Deep Learning -* Random Forrests (and other techniques based on Decision Trees) -* Simmulated Annealing -* (Linear) Integer Programming - - -Inter Process Communication ---------------------------- - March 14, 2018 - -We can attach nicely to same memory segment from 2 different processes: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.c .numberLines} -// ipc via shared mem -// attach to shared memory; -key_t my_ftok = ftok("~/surf-webext-dom-shared-mem",'a'); - -int mem_seg=shmget(my_ftok,1024*1024,IPC_CREAT|0660); -if(mem_seg==-1) -{ -g_print("shmget failed: %s\n",strerror(errno)); -} - -shared_buf=shmat(mem_seg,NULL,0); -if(shared_buf==(void*)-1) -{ -g_print("shmat failed: %s\n",strerror(errno)); -} -g_print("attached to shared memory.\n"); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -SSL Certificate CSR -------------------- - - February 20, 2015 - - for apache ssl mod - - first check your old csr if you like: - $ openssl req -text -noout -verify -in CSR.csr - - 1. generate key - $ openssl genrsa -des3 -out www.yourdomain-example.com.key 2048 - - 2. create CSR - $ openssl req -new -key www.yourdomain-example.com.key -out www.yourdomain-example.com.csr - - refs: - [1] https://search.thawte.com/support/ssl-digital-certificates/index?page=content&id=AR1108&actp=LIST - -Competitive Coding ------------------- - March 17, 2015 - -A small selection of websites, which I visit from time to time, addressing competitive coding. - -* topcoder.com -* codeforces.com -* codility.com -* codersclan.ne -* projecteuler.net -* www.codingame.com (need to check this) -* www.codechef.com (need to check this) -* http://psyho.gg/overview-of-programming-contests/ (and read here) -* https://www.hackerrank.com/ -* http://code.google.com/codejam -* https://www.kaggle.com/ – predicitve modelling -* odesk.com / elance - -Comp Science Literature ------------------------ - March 17, 2015 -This is a list of some books, focusing on topics around computer science, which I recently read or am currently reading or want to read :P - -* Meyers, Effective C++ (Addison-Wesley) C++98 only? -* Meyers, More Effective C++ (Addison-Wesley) C++98 only? -* Meyers, Effective STL. C++98 only? -* Sutter, Exceptional C++ -* Sutter, More Exceptional C++ -* Karlson, Beyond the C++ Standard Library: An Introduction to Boost 1st Edition -* Maybe Something on Multiprocessing (?) -* Donald Knuth. The Art Of Computer Programming -* Algorithms 3rd Edition (by Cormen, Leiserson, Rivest, Stein) -* Jonathan Bartlett. Programming from the Ground Up -* C++ in a Nutshell (O’REILLEY, by Lischner) -* C++ Primer (5th Edition) by Lippman, Lajoie, Moo -* The C++ Programming Language 4th Edition -* Anthony Williams, C++ Concurrency in Action: Practical Multihreading -* Dive into Python (2 and 3) by Mark Pilgrim -* Learn You a Haskell for Great Good by Marian Lipovaca -* Real World Haskell -* Version Control with Git (O’REILLEY, by Loeliger & McCullough) (next: 9(10) ?) -* The Linux Command Line, by William Shotts (http://linuxcommand.org/tlcl.php) -* Debian, The Administrators Handbook (by Hertzog and Mas) -* Absolute FreeBSD by Michael W. Lucas -* Modern Operating Systems, Third Edition (by Andrew S. Tannebaum) -* Linux Device Drivers (O’REILLEY, by Corbert, Rubini, Kroah-Hartman) -* Linux Kernel in a Nutshell (O’REILLEY, Greg Kroah-Hartman) - -* Concrete Math (2nd) -* UPENN cis194 - -* STOC '83 Proceedings of the fifteenth annual ACM symposium on Theory of computing / Primitives for the manipulation of general subdivisions and the computation of Voronoi diagrams - -* http://haskellbook.com/ -* Wadler paper "Monads for Functional Programming" -* simon marlow - book (parallel) -* data 6 - course (Github) -* sedgewick & waynes algorithms -* books from appendix, from programming from ground up? - -VNC ---- - April 2, 2015 - -### Server: - $ apt-get install tightvncserver - $ xtightvncserver -geometry 1900×1100 - $ netstat -tap | grep vnc # remember port (e.g.5901) - -### Client: - $ ssh -L 5901:localhost:5901 you@remote # tunnel - $ xtightvncviewer localhost::5901 # in new terminal - -### Kill Server: - $ vncserver -kill :1 # (or :2 etc..) - -Owncloud Notes --------------- - -### Mounting Ownclouds DavFS - - April 15, 2015 - - $ apt-get install davfs2 - - * since owncloud seems to have problems with locks, edit /etc/davfs2/davfs2.conf and set use_locks to 0 in order to allow creating files (as well as probably writing) - - $ mount -t davfs https://secure.sf.com/owncloud/remote.php/webdav /mnt/ - -### rescan/rebuild ownlocud files database - - June 22, 2016 - - inside ownlcoud directory run: - sudo -u www-owncloud php console.php files:scan –all - - -LXC ---- - April 28, 2015 - - maybe worth a try: - - apt-get install lxc; lxc create ctname -t download — -d debian -r jessie - -a amd64; lxc-start -d -n ctname, lxc-attach ctname - - similar tools: chroot/ debootsrap - -Add vim Lang ------------- - May 14, 2015 - - $ sudo apt-get install myspell-pl - $ cd /ush/share/hunspell - $ vim - :mkspell pl pl_PL - -What every programmer should know about ---------------------------------------- - November 7, 2015 - - Undefined behaviour: http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html - Memory: http://lwn.net/Articles/250967/ - Floating point arithmetic: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html - -IDE Comparison --------------- - - December 7, 2015 - -While I love working with vim (ctags, taglist, etc..) and the command line, it might be worth to have a look at the following IDE’s for Java and/or C++: - -* IntelliJ IDEA -* Eclipse -* Eclipse CDT -* Codeblocks -* Netbeans -* Codelite -* KDevelop - -Setup Postfix -------------- - -We want to handle different domains on a single postfix server and have virtual users along real unix users. For the virtual users we use uid/gid 5000. - -Relevant config files are: - - /etc/postfix/master.cf - /etc/postfix/main.cf - /etc/postfix/smtpd_sender_login_maps (tells which emails belong to which login) - /etc/postfix/vmailbox (sepcifies our VIRTUAL mailboxes and the names of the spoolfiles) - /etc/postfix/virtual (aliases for our local unix users) - /etc/dovecot/users (specifies the logins, passwords, home directories,..) - /etc/dovecot/conf.d/10-mail (set inbox and mailbox dirs) - -Be careful about the permissions of the different folders, so uid/gid 5000, postfix and dovecot can access as relevant. - -A very nice tutorial on setting up postfixadmin can be found here: - - https://lelutin.ca/posts/installing_postfix_-_clamav_-_spamassassin_-_dovecot_-_postfixadmin_on_debian_squeeze/ - -Windows Specific Notes ----------------------- - -### disable hiberfile.sys - - September 7, 2017 - - run cmd.exe as administrator: - powercfg.exe -h off - -### GTA4 on NVIDIA-GTX 980 - - April 17, 2016 - - Add following flags : -nomemrestrict -norestriction - Otherwise video memory is not identified correctly. - -### Civilization 4 BTS Autosaves - - September 23, 2016 - - In the file: C:\Users\miguel\Documents\My Games\Beyond the Sword\CivilizationIV - - Adjust: - - ; The maximum number of autosaves kept in the directory before being deleted. - MaxAutoSaves = 100 - - ; Specify the number of turns between autoSaves. 0 means no autosave. - AutoSaveInterval = 1 - -Fool’s Wiki Knowledge -===================== - - February 24, 2016 - -Migrated from our former Mediawiki: - -Welcome to the Foolo-Pedia! Foolo-Pedia is a growing collection of interesting, important, ridiculous or useless information gathered and refined by the SoftwareFools team for all Friends of Fools. We decided to mainly keep this Wiki in english to be compatible with all our costumers and friends. Some destinct pages maybe in polish, german or klingon. - -Articles which might be of universal interest, divided by area and topic. - -## Minilinux - - software fools minimal linux - - 1. usb stick - 2. create one big partition (2gb) - 3. mkefs.ext4 /dev/sdx1 - 4. mount /dev/sdx1 /mnt - 5. compile kernel - 6. cp bzImage /mnt - 7. boot - - 8. - grub> search /bzImage - grub> linux /bzImage root=?? - - PROBLEMS WITH kernel config! - -## Kernel Building - - cd linux-source-[xxx] - make mrproper - cp someconfig .config -i - make oldconfig - make menuconfig - make localmodconfig - make localyesconfig - make - (OPT) make modules - su - make install - (OPT) make modules_install - (OPT) update-intiramfs -c -k [kernel-postfix] - - (REMOVE UNWANTED FILES FROM BOOT!) - update-grub - grub-install /dev/sda - reboot - -## GDB - - http://www.cprogramming.com/debuggers.html - - use gcc or clang with : -ggdb -O0 - - h - help - - r - run - c - continue - n - next - s - step - - b - break - p - print - - wa - watch - - bt - frame - list - info locals - - set = - set substitute-path FROM TO - - call - -## clang - - http://llvm.org/releases/3.7.0/docs/CMake.html - http://clang.llvm.org/get_started.html - put MAKEFLAGS="-j8" or similar in front of your CMake invocations. - - extracted llvm to ~/temp/clang/llvm-3.7.0.src/ - extracted clang to ~/temp/clang/llvm-3.7.0.src/tools/clang/ - extracted compiler-rt to ~/temp/clang/llvm-3.7.0.src/projects/compiler-rt - extracted libcxx to ~/temp/clang/llvm-3.7.0.src/projects/libcxx - - $ cd ~/temp/clang/llvm-3.7.0-build - $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/miguel/opt/llvm-3.7.0 ../llvm-3.7.0.src - $ cmake --build . - $ cmake --build . --target install - -## XMPP - -### Idea - -Today I figured out, once again, that there are many open-source and free (as in freedom) alternatives to all those chat clients and their proprietary protocols, which we dislike and want to avoid. Taking it seriously I decided to set up a XMPP Server on our Softwarefools Server (http://www.softwarefools.com) to finally enable secure and comfortable communication between me, myself and my fellow peers. - -### Starting Point - -* We have a Debian Virtual Private Server (VPS) Running wheezy (stable) -* I just found that tutorial: http://wiki.linuxwall.info/doku.php/en:ressources:articles:ejabberd - -### I. get package - - # apt-get install ejabberd - -### II. adapt config - -In /etc/ejabberd/ejabberd.cfg adapt the hosts line as that: (if you wonder this is Erlang) - - %% Hostname - {hosts, ["softwarefools.com"]}. - -### III. setup certificate - - # mkdir /etc/ejabberd/certs - -For now we skip the rest of that step and proceed with the self-signed certificate provided by Debian. (/etc/ejabberd/ejabberd.pem) - -### IV. restart server - - # /etc/init.d/ejabberd restart - -### V. create user - - # ejabberdctl register miguel softwarefools.com 'pass123' - # ejabberdctl register niki softwarefools.com 'pass321' - -### VI. open ports - - # iptables -I INPUT -p tcp --dport 5222 -j ACCEPT - # iptables -I INPUT -p tcp --dport 5269 -j ACCEPT - -TODO: in fact we need more here! - -### VII. connect with client - -* Get Pidgin http://www.pidgin.im/ -* Connect & Enjoy  - -### Further Work -* certificate -* dns configuration – should provide xmpp info (? - - -## Benchmark - -### Tools for Stress Testing your RIG - - May 12, 2017 - - Some nice tools to stress-test your computer: - - CPU: Prime95 - GPU: FurMark - RAM: MemTest86+ - HDD/SSD: S.M.A.R.T - - Ref: http://www.pcworld.com/article/2028882/keep-it-stable-stupid-how-to-stress-test-your-pc-hardware.html - -### Networking - - 1. Connected my [laptop] and [desktop] via 5meter cat5e cable -> 1000mbit full duplex link - 2. created ~1.5G ramdisks with tmpfs on each. - 3. created a 1 giga file with data from /dev/urandom on [desktop] - 4. copied file with scp from [desktop] to [laptop] - 5. copied file with scp from [laptop] to [desktop] - 6. repeated 4 & 5 10 times : average speed ~70+MB/s from desk & 80+MB/s to desk, link stays up all the time. ping around 0.2-0.3ms - 7. repeated 1-6 with my other 3meter ethernet cable. - 8. tried both direction simultanously which gave a total data throughput even over 100MB/s - -### Hard Disk - -To get some information about the disk run: - -Request identification info directly from the drive, which is displayed in a new expanded format with considerably more detail than with the older -i option. - - $ hdparm -I /dev/sda - -Timings - - $ hdparm -tT /dev/sda - -Clear Cache - - $ echo 3 > /proc/sys/vm/drop_caches - -I am using this block-size and count which results in ~2GB: - - $ dd [...] bs=1048576 count=2048 - -READ: - - $ dd if=test of=/dev/null - $ dd if=/dev/sdX of=/dev/null - -WRTIE: - - $ dd if=/dev/zero of=test - $ dd if=/dev/zero of=/dev/sdX - -smartmontools: - - seatage: - Raw_Read_Error_Rate - Seek_Error_Rate - - example: - % python - >>> 200009354607 & 0xFFFFFFFF - 2440858991 <---- total number - >>> (200009354607 & 0xFFFF00000000) >> 32 - 46 <--- number of errors - -## Fixing HDD after Free Falling - -So you also dropped your hard-disk and some of your secotrs got damaged, -probably by the head hitting the platter? The following short text outlines, -how I approached fixing my disk after it hit the floor. Of course I would -not rely on this disk for mission critical data anymore, but it -might serve as a scratch/temporarily/redundant space. - -Backup all your data in advance because the disk will almost certainly -require reformatting and repartitoning after follwing this procedure! - -Some Tools/Programms I used: - -* smartctl -* hdparm -* grep - -### smartctl - -Try from fastest to slowest to find faulty sector: replace LBAi\_START,LBA\_END with meaningful values. - - smartctl -t [long|conveyence|short|select,LBA_START-LBA_END] -C /dev/sda - -The following did not work for me. Resulted in ‘interrupted by host’ for some reason. -Probably the disks goes to sleep or something. Issueing some read operations every minute might fix this(?) - - -C to run test in foreground mode! - -### hdparm - -You can bi-search via –read-sector if complete ranges are affected (As in my case) and then fix them in one step: - - for i in {36312851..36312886}; do hdparm --write-sector $i /dev/sda; done - -### Example - -Exemplary session fixing one sector: - -**WARNING: this will destroy your data !** - - 1) # smartctl -a /dev/sda | egrep 'Pend|Real|Offline_Unc' - - 5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 4 - 197 Current_Pending_Sector 0x0012 098 098 000 Old_age Always - 47 - 198 Offline_Uncorrectable 0x0010 098 098 000 Old_age Offline - 47 - - 2) # smartctl -t short /dev/sda - - 3) # smartctl -l selftest /dev/sda - - [...] 1 Short offline Completed: read failure 90% 10632 152076520 - - 4) # hdparm --read-sector 152076520 /dev/sda # verification - - [...] reading sector 152076520: FAILED: Input/output error - - 5) # hdparm --write-sector 152076520 /dev/sda - - 6) # smartctl -a /dev/sda | egrep 'Pend|Real|Offline_Unc' - - 5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 4 - 197 Current_Pending_Sector 0x0012 098 098 000 Old_age Always - 46 - 198 Offline_Uncorrectable 0x0010 098 098 000 Old_age Offline - 46 - -## Raid and LVM - - - Also refer to: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/foreward.html - - Here I will write down some of my considarations about setting up a RAID - and LVM. - - We want to get a performance boost and minimize the ssd wear-out. - Also we will not put there any mission-critical files, because the content - of the ssd will not be mirrored. beside regular backups of course. - We also need to take the limited diskspace into account. - while our hdd’s are 2*2TB we only have a single 250MB sdd. - - So we will be looking at files that are: - - * not updated very often - * read often - * not critical if they get lost. - * not too huge - - So I consider for my usecase - * /bin - * /sbin - * /boot - * /lib{,32,64} - - * /usr (without /usr/local) - - That directories will reside on our raid1 since they contain important files: - * /home/miguel - * /root - * /opt - * /usr/local - - Finally we will mount the following things in ram for superfast and temporary space: - - * /tmp - * /var/log (unless you care about logs) - - What about that directories? - consider speed vs. security vs. drive wear-out - - * /etc - * /var - - Never mount swap on your ssd! - - == extending logical volume and fs == - * https://wiki.archlinux.org/index.php/LVM - - # lvextend -L +20G VolGroup00/lvolhome - - resize fs (ext2, ext3 or ext4) - for ext4 this can be done even without unmounting the device - - # resize2fs /dev// - -## Some RAID Problems on my old Desktop - - https://www.thomas-krenn.com/en/wiki/Mdadm_checkarray - https://plone.lucidsolutions.co.nz/linux/io/ssd-on-nvidia-sata-port-generates-error-eh-in-swncq-mode-and-failed-command-read-fpdma-queued/view - https://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array - - Kernel options: sata_nv.swncq=0 - - [ 8625.896029] ata5.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen - [ 8625.896035] ata5.00: failed command: WRITE DMA EXT - [ 8625.896040] ata5.00: cmd 35/00:08:50:06:b0/00:00:13:00:00/e0 tag 0 dma 4096 out - res 40/00:00:00:4f:c2/00:00:00:00:00/40 Emask 0x4 (timeout) - [ 8625.896043] ata5.00: status: { DRDY } - [ 8625.896048] ata5: hard resetting link - [ 8625.896050] ata5: nv: skipping hardreset on occupied port - [ 8626.364038] ata5: SATA link up 3.0 Gbps (SStatus 123 SControl 300) - [ 8631.372026] ata5.00: qc timeout (cmd 0x27) - [ 8631.372031] ata5.00: failed to read native max address (err_mask=0x4) - [ 8631.372033] ata5.00: HPA support seems broken, skipping HPA handling - [ 8631.372035] ata5.00: revalidation failed (errno=-5) - [ 8631.372042] ata5: hard resetting link - [ 8631.372044] ata5: nv: skipping hardreset on occupied port - [ 8631.840045] ata5: SATA link up 3.0 Gbps (SStatus 123 SControl 300) - [ 8631.864140] ata5.00: configured for UDMA/133 - [ 8631.864146] ata5.00: device reported invalid CHS sector 0 - [ 8631.864154] ata5: EH complete - [ 8662.888029] ata5.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen - [ 8662.888036] ata5.00: failed command: WRITE DMA EXT - [ 8662.888041] ata5.00: cmd 35/00:08:50:06:b0/00:00:13:00:00/e0 tag 0 dma 4096 out - res 40/00:00:00:4f:c2/00:00:00:00:00/40 Emask 0x4 (timeout) - [ 8662.888043] ata5.00: status: { DRDY } - [ 8662.888049] ata5: hard resetting link - [ 8662.888051] ata5: nv: skipping hardreset on occupied port - [ 8663.356038] ata5: SATA link up 3.0 Gbps (SStatus 123 SControl 300) - [ 8663.396135] ata5.00: configured for UDMA/133 - [ 8663.396141] ata5.00: device reported invalid CHS sector 0 - [ 8663.396151] ata5: EH complete - [ 8693.864031] ata5.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen - [ 8693.864038] ata5.00: failed command: WRITE DMA EXT - [ 8693.864043] ata5.00: cmd 35/00:08:50:06:b0/00:00:13:00:00/e0 tag 0 dma 4096 out - res 40/00:00:00:4f:c2/00:00:00:00:00/40 Emask 0x4 (timeout) - [ 8693.864045] ata5.00: status: { DRDY } - [ 8693.864051] ata5: hard resetting link - [ 8693.864052] ata5: nv: skipping hardreset on occupied port - [ 8694.332036] ata5: SATA link up 3.0 Gbps (SStatus 123 SControl 300) - [ 8694.356134] ata5.00: configured for UDMA/133 - [ 8694.356141] ata5.00: device reported invalid CHS sector 0 - [ 8694.356150] ata5: EH complete - [ 8724.840030] ata5: limiting SATA link speed to 1.5 Gbps - - - diff --git a/080_blog/00015_Admin/00005_Notes-on-Hosting/index.md b/080_blog/00015_Admin/00005_Notes-on-Hosting/index.md new file mode 100644 index 0000000..1345bf4 --- /dev/null +++ b/080_blog/00015_Admin/00005_Notes-on-Hosting/index.md @@ -0,0 +1,53 @@ +# Miscellanous Notes on Server Hosting specifics + +## LUKS container over sshfs + +* enable user\_allow\_other in /etc/fuse.conf +* sshfs -o allow\_root user@server:/BACKUPS/ ~/mnt/ +* dd if=/dev/urandom of=~/mnt/megaloman bs=1M count=512 +* sudo cryptsetup -y luksFormat ~/mnt/megaloman +* sudo cryptsetup luksOpen ~/mnt/megaloman vol1 +* sudo mkfs.ext4 /dev/mapper/vol1 +* sudo mount /dev/mapper/vol1 /mnt +* df -h | grep vol1 +* sudo umount /mnt +* sudo cryptsetup luksClose vol1 +* fusermount -u ~/mnt + +NOTE: backup your data example use : rsync -a –info=progress2 source dist + +## Ownlcoud + +### Mounting Ownclouds DavFS + + $ apt-get install davfs2 + + * since owncloud seems to have problems with locks, edit /etc/davfs2/davfs2.conf and set use_locks to 0 in order to allow creating files (as well as probably writing) + + $ mount -t davfs https://secure.sf.com/owncloud/remote.php/webdav /mnt/ + +### rescan/rebuild ownlocud files database + + inside ownlcoud directory run: + sudo -u www-owncloud php console.php files:scan –all + +## Postfix + +We want to handle different domains on a single postfix server and have virtual users along real unix users. +For the virtual users we use uid/gid 5000. + +Relevant config files are: + + /etc/postfix/master.cf + /etc/postfix/main.cf + /etc/postfix/smtpd_sender_login_maps (tells which emails belong to which login) + /etc/postfix/vmailbox (sepcifies our VIRTUAL mailboxes and the names of the spoolfiles) + /etc/postfix/virtual (aliases for our local unix users) + /etc/dovecot/users (specifies the logins, passwords, home directories,..) + /etc/dovecot/conf.d/10-mail (set inbox and mailbox dirs) + +Be careful about the permissions of the different folders, so uid/gid 5000, postfix and dovecot can access as relevant. + +A very nice tutorial on setting up postfixadmin can be found here: + + https://lelutin.ca/posts/installing_postfix_-_clamav_-_spamassassin_-_dovecot_-_postfixadmin_on_debian_squeeze/ diff --git a/080_blog/00015_Admin/00008_Docker/index.md b/080_blog/00015_Admin/00008_Docker/index.md new file mode 100644 index 0000000..b7bc5c0 --- /dev/null +++ b/080_blog/00015_Admin/00008_Docker/index.md @@ -0,0 +1,14 @@ +# Docker Volume Backup + +Identify volume: + + $ docker inspect my_container_name | grep -C 1 -i Source + +Backup the directory to a tar file: + + $ docker run –rm –volumes-from my_container_name -v $(pwd):/backup ubuntu tar cvf /backup/backup_db.tar /var/lib/mysql + +Restore the volume: + + $ docker run –rm –volumes-from my_container_name -v $(pwd):/backup ubuntu bash -c "cd /var/lib/mysql && tar xvf /backup/backup_db.tar –strip 1" + diff --git a/080_blog/00015_Admin/00010_Various-Cheat-Sheets/00120_GDB/index.md b/080_blog/00015_Admin/00010_Various-Cheat-Sheets/00120_GDB/index.md new file mode 100644 index 0000000..5aebdf3 --- /dev/null +++ b/080_blog/00015_Admin/00010_Various-Cheat-Sheets/00120_GDB/index.md @@ -0,0 +1,29 @@ +# GDB + + http://www.cprogramming.com/debuggers.html + + use gcc or clang with : -ggdb -O0 + + h - help + + r - run + c - continue + n - next + s - step + + b - break + p - print + + wa - watch + + bt + frame + list + info locals + + set = + set substitute-path FROM TO + + call + + diff --git a/080_blog/00015_Admin/00020_Benchmarking-and-Stress-testing/index.md b/080_blog/00015_Admin/00020_Benchmarking-and-Stress-testing/index.md new file mode 100644 index 0000000..facfc17 --- /dev/null +++ b/080_blog/00015_Admin/00020_Benchmarking-and-Stress-testing/index.md @@ -0,0 +1,68 @@ +# Benchmarking + + May 12, 2017 + +## Tools for Stress Testing your RIG + + Some nice tools to stress-test your computer: + + CPU: Prime95 + GPU: FurMark + RAM: MemTest86+ + HDD/SSD: S.M.A.R.T + + Ref: http://www.pcworld.com/article/2028882/keep-it-stable-stupid-how-to-stress-test-your-pc-hardware.html + +## Networking + + 1. Connected my [laptop] and [desktop] via 5meter cat5e cable -> 1000mbit full duplex link + 2. created ~1.5G ramdisks with tmpfs on each. + 3. created a 1 giga file with data from /dev/urandom on [desktop] + 4. copied file with scp from [desktop] to [laptop] + 5. copied file with scp from [laptop] to [desktop] + 6. repeated 4 & 5 10 times : average speed ~70+MB/s from desk & 80+MB/s to desk, link stays up all the time. ping around 0.2-0.3ms + 7. repeated 1-6 with my other 3meter ethernet cable. + 8. tried both direction simultanously which gave a total data throughput even over 100MB/s + +## Hard Disk + +To get some information about the disk run: + +Request identification info directly from the drive, which is displayed in a new expanded format with considerably more detail than with the older -i option. + + $ hdparm -I /dev/sda + +Timings + + $ hdparm -tT /dev/sda + +Clear Cache + + $ echo 3 > /proc/sys/vm/drop_caches + +I am using this block-size and count which results in ~2GB: + + $ dd [...] bs=1048576 count=2048 + +READ: + + $ dd if=test of=/dev/null + $ dd if=/dev/sdX of=/dev/null + +WRTIE: + + $ dd if=/dev/zero of=test + $ dd if=/dev/zero of=/dev/sdX + +smartmontools: + + seatage: + Raw_Read_Error_Rate + Seek_Error_Rate + + example: + % python + >>> 200009354607 & 0xFFFFFFFF + 2440858991 <---- total number + >>> (200009354607 & 0xFFFF00000000) >> 32 + 46 <--- number of errors diff --git a/080_blog/00015_Admin/00030_Fixing-HDD/index.md b/080_blog/00015_Admin/00030_Fixing-HDD/index.md new file mode 100644 index 0000000..0bae730 --- /dev/null +++ b/080_blog/00015_Admin/00030_Fixing-HDD/index.md @@ -0,0 +1,48 @@ +# Fixing HDD after Free Falling + +So you also dropped your hard-disk and some of your secotrs got damaged, +probably by the head hitting the platter? + +Backup all your data. + +## smartctl + +Try from fastest to slowest to find faulty sector: replace LBAi\_START,LBA\_END with meaningful values. + + smartctl -t [long|conveyence|short|select,LBA_START-LBA_END] -C /dev/sda + +## hdparm + +Bi-search via –read-sector if complete ranges are affected (as in my case) and then fix them in one step: + + for i in {36312851..36312886}; do hdparm --write-sector $i /dev/sda; done + +## Example + +Exemplary session fixing one sector: + +**WARNING: this will destroy your data !** + + 1) # smartctl -a /dev/sda | egrep 'Pend|Real|Offline_Unc' + + 5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 4 + 197 Current_Pending_Sector 0x0012 098 098 000 Old_age Always - 47 + 198 Offline_Uncorrectable 0x0010 098 098 000 Old_age Offline - 47 + + 2) # smartctl -t short /dev/sda + + 3) # smartctl -l selftest /dev/sda + + [...] 1 Short offline Completed: read failure 90% 10632 152076520 + + 4) # hdparm --read-sector 152076520 /dev/sda # verification + + [...] reading sector 152076520: FAILED: Input/output error + + 5) # hdparm --write-sector 152076520 /dev/sda + + 6) # smartctl -a /dev/sda | egrep 'Pend|Real|Offline_Unc' + + 5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 4 + 197 Current_Pending_Sector 0x0012 098 098 000 Old_age Always - 46 + 198 Offline_Uncorrectable 0x0010 098 098 000 Old_age Offline - 46 diff --git a/080_blog/00015_Admin/00040_Oneliners/index.md b/080_blog/00015_Admin/00040_Oneliners/index.md new file mode 100644 index 0000000..c16a515 --- /dev/null +++ b/080_blog/00015_Admin/00040_Oneliners/index.md @@ -0,0 +1,41 @@ +# Oneliners + +A Growing Collection of Linux Command Line One-Liners + +Please believe me... this collection was really supposed to grow over time... + +inside a direcotry show disk usage of all hidden files and directories and sort by size: + + $ du $(ls .* -d | tail -n +3) -hs |sort -h + +inside a direcotry show disk usage of all files and directories (also hidden) and sort by size. +Exclude 'garbage' file. + + $ du . -a -d 1 -h --exclude=garbage | sort -h + +Tar all files in current directory, excluding ./DATA and ./.cache + + $ tar --exclude=.cache -cvf home_miguel_20180216.tar . + +Find files in ./ARCHIVE NOT belonging to a specific user: miguel + + $ find ARCHIVE/ \! -user miguel + +set folder/ permissions to Read/Browse only for owner recursively + + $ sudo chmod -R u=r,g=,o= folder/ + $ chmod -R u=rX,g=,o= folder/ + +find all mails from Boban when in the maildir full of mailboxes and print only short headers without bodies: + + $ grepmail -H -B -Y ‘(^TO:|^From:)’ Boban * + +not really a one-lier but will print 256 colors in a bash: + + for i in {0..255} ; do + printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i" + if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then + printf "\n"; + fi + done + diff --git a/080_blog/00015_Admin/00090_Miguels-KVM-Adventures/index.md b/080_blog/00015_Admin/00090_Miguels-KVM-Adventures/index.md index 7f4e105..722d20f 100644 --- a/080_blog/00015_Admin/00090_Miguels-KVM-Adventures/index.md +++ b/080_blog/00015_Admin/00090_Miguels-KVM-Adventures/index.md @@ -194,7 +194,7 @@ A common use case is to run docker inside the virtual guests, which makes it an } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Optionally you can tell rsyslog to log deamon.* entries into a separate file and adjust logrotation as outlined here [5]. +Optionally you can tell rsyslog to log deamon.\* entries into a separate file and adjust logrotation as outlined here [5]. ## Miscellaneous @@ -202,6 +202,14 @@ Optionally you can tell rsyslog to log deamon.* entries into a separate file and virt-host-validate # validate host virtualization setup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Use this RedHat virtio drivers when you install win10 [6]. + +* https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/ + +Forward ipv4 to an ipv6 only: + +socat TCP4-LISTEN:51247,fork,su=nobody TCP6:[2a01:4f8:192:5112::6]:51247 + ## References [1] https://libvirt.org/formatdomain.html @@ -209,4 +217,4 @@ Optionally you can tell rsyslog to log deamon.* entries into a separate file and [3] http://repo.firewall-services.com/misc/virt/virt-backup.pl [4] https://www.linux-kvm.org/page/Tuning_KVM [5] https://www.wolfe.id.au/2015/05/03/syslog-logging-driver-for-docker/ - + [6] https://www.funtoo.org/Windows_10_Virtualization_with_KVM diff --git a/080_blog/00018_Building/00030_The-Hell-of-Autotools/index.md b/080_blog/00018_Building/00030_The-Hell-of-Autotools/index.md new file mode 100644 index 0000000..746bd82 --- /dev/null +++ b/080_blog/00018_Building/00030_The-Hell-of-Autotools/index.md @@ -0,0 +1,74 @@ +The Hell of Autotools +===================== + March 19, 2018 +In this trivial example we compile a custom **webkit2gtk+ extension** with +**autotools**. For a start we need to provide two files, `Makefile.am` +and `configure.ac`, beside our actual `ext.c` source file, which contains +the extension code itself. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.c .numberLines} +// File: ext.c // + +#include + +G_MODULE_EXPORT void +webkit_web_extension_initialize_with_user_data (WebKitWebExtension *extension, + GVariant *user_data) +{ + g_print("Hello Extension!\n"); +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.makefile .numberLines} +# File: Makefile.am # + +webextension_LTLIBRARIES = libmyappwebextension.la +webextensiondir = /home/miguel/temp + +WEB_EXTENSION_CFLAGS = `pkg-config --cflags webkit2gtk-web-extension-4.0` +WEB_EXTENSION_LIBS2 = `pkg-config --libs webkit2gtk-web-extension-4.0` + +libmyappwebextension_la_SOURCES = ext.c +libmyappwebextension_la_CFLAGS = $(WEB_EXTENSION_CFLAGS) +libmyappwebextension_la_LIBADD = $(WEB_EXTENSION_LIBS) +libmyappwebextension_la_LDFLAGS = -module -avoid-version -no-undefined $(WEB_EXTENSION_LIBS2) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.makefile .numberLines} +# File: configure.ac # + +AC_PREREQ([2.69]) +AC_INIT(ext,0.1,test@example.com) +AM_INIT_AUTOMAKE +AC_CONFIG_SRCDIR([ext.c]) +AC_PROG_CC +LT_INIT +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Put the above files in a new fresh directory and you are ready to see the +powers of autotools in action. + +Run the following commands on your pash prompt: + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} +touch NEWS README AUTHORS ChangeLog +aclocal +autoconf +automake --add-missing +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After this steps, we end up with 18 files in our directory. Finally we +can _configure_, _build_ and _install_ our extension. The following +commands will probably look familiar. Note that the _configure_ step +generates 6 additional files, totaling in **24 files** before the actual +_make_ command is run. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} +./configure +make +make install +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +... just to compile one **single C file**. diff --git a/080_blog/00018_Building/00040_Various-notes-on-Building/index.md b/080_blog/00018_Building/00040_Various-notes-on-Building/index.md new file mode 100644 index 0000000..0639063 --- /dev/null +++ b/080_blog/00018_Building/00040_Various-notes-on-Building/index.md @@ -0,0 +1,93 @@ +# Various Notes on Building + +## Webkit + +Let’s compile a release with debug info and install to /usr/local + +~~~~~~ {.bash} +wget https://webkitgtk.org/releases/webkitgtk-2.20.0.tar.xz +tar -xvf webkitgtk-2.20.0.tar.xz +cd webkitgtk-2.20.0 +# install all the libs that will be reported missing in the next step. +# I could not find the woff2 stuff in debian so skipped it... +cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_WOFF2=NO -GNinja +# this takes about 30minutes on my i7-4790K .. zzzzz..zzz +ninja +sudo ninja install +~~~~~~~~~~~ + + pkg-config + + pkg-config uses our new build now: + + [1] https://trac.webkit.org/wiki/BuildingGtk + [2] https://webkitgtk.org/ + +## GCC + +This is how I build gcc (5.2.0) and binutils (2.25.1). Check [5] first. + +* unpack binutils-x.y.z +* create a new directory binutils-x.y.z-build and inside it run the following commands: + +~~~~~~ {.bash} + $ ../binutils-x.y.z/configure --disable-nls --with-sysroot --enable-targets=all + $ make -j4 + $ make install +~~~~~~~~~~~~ + +* unpack gcc-x.y.z and run the contrib/download_prerequisites script inside. +* create a new directory: gcc-x.y.z-build and inside it run: + +~~~~~~ {.bash} + $ ../gcc-x.y.z/configure --disable-nls --enable-languages=c,c++ --enable-threads + $ make -j4 + $ make install +~~~~~~~~~~~~ + + REF: + + [1] binutils and gcc README files. + [2] https://gcc.gnu.org/install/ + [3] http://wiki.osdev.org/Building_GCC + [4] http://stackoverflow.com/questions/1726042/recipe-for-compiling-binutils-gcc-together + [5] https://gcc.gnu.org/install/prerequisites.html + +## Linux + + cd linux-source-[xxx] + make mrproper + cp someconfig .config -i + make oldconfig + make menuconfig + make localmodconfig + make localyesconfig + make + (OPT) make modules + su + make install + (OPT) make modules_install + (OPT) update-intiramfs -c -k [kernel-postfix] + + (REMOVE UNWANTED FILES FROM BOOT!) + update-grub + grub-install /dev/sda + reboot + + +## Clang + + http://llvm.org/releases/3.7.0/docs/CMake.html + http://clang.llvm.org/get_started.html + put MAKEFLAGS="-j8" or similar in front of your CMake invocations. + + extracted llvm to ~/temp/clang/llvm-3.7.0.src/ + extracted clang to ~/temp/clang/llvm-3.7.0.src/tools/clang/ + extracted compiler-rt to ~/temp/clang/llvm-3.7.0.src/projects/compiler-rt + extracted libcxx to ~/temp/clang/llvm-3.7.0.src/projects/libcxx + + $ cd ~/temp/clang/llvm-3.7.0-build + $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/miguel/opt/llvm-3.7.0 ../llvm-3.7.0.src + $ cmake --build . + $ cmake --build . --target install + diff --git a/080_blog/00018_Building/index.md b/080_blog/00018_Building/index.md new file mode 100644 index 0000000..1ee18e7 --- /dev/null +++ b/080_blog/00018_Building/index.md @@ -0,0 +1,3 @@ +# Building + +Some Random Notes about Building Software. diff --git a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/1.png b/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/1.png deleted file mode 100644 index 4a28a5b..0000000 Binary files a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/1.png and /dev/null differ diff --git a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/2.png b/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/2.png deleted file mode 100644 index 980bef5..0000000 Binary files a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/2.png and /dev/null differ diff --git a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/3.png b/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/3.png deleted file mode 100644 index 6deb011..0000000 Binary files a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/3.png and /dev/null differ diff --git a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/4.png b/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/4.png deleted file mode 100644 index 90c2d8a..0000000 Binary files a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/4.png and /dev/null differ diff --git a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/index.md b/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/index.md deleted file mode 100644 index fab8cab..0000000 --- a/080_blog/00020_3D-Art/00035_A-quick-Trumpet-in-Blender/index.md +++ /dev/null @@ -1,25 +0,0 @@ -Hear the Trumpets hear the Pipers -================================= - November 9, 2017 -Today morning I was playing with blender’s cycles “material nodes”, the “sub-surf modifier” and the “depth of field” camera setting. - -I modeled a simple trumpet by extruding some cylinders and used the Diffuse and Glossy shaders for the trumpet, as well as a Wave texture for the marble surface. - -**Extruded** and scaled some basic **cylinders** to get a simple (yet unfinished) trumpet: - -![](1.png){.img-fluid} - -Added **materials**: - -![](2.png){.img-fluid} - -Added the **subsurf** modifier: - -![](3.png){.img-fluid} - -Configured **depth of field**: - -![](4.png){.img-fluid} - -Voila, ... it's alpha and omega's kingdom come. - diff --git a/080_blog/00020_3D-Art/index.md b/080_blog/00020_3D-Art/index.md deleted file mode 100644 index b840fc7..0000000 --- a/080_blog/00020_3D-Art/index.md +++ /dev/null @@ -1,3 +0,0 @@ -3D Art -====== -Some of my three dimensional creations, mostly in Blender. diff --git a/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/1.png b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/1.png new file mode 100644 index 0000000..4a28a5b Binary files /dev/null and b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/1.png differ diff --git a/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/2.png b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/2.png new file mode 100644 index 0000000..980bef5 Binary files /dev/null and b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/2.png differ diff --git a/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/3.png b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/3.png new file mode 100644 index 0000000..6deb011 Binary files /dev/null and b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/3.png differ diff --git a/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/4.png b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/4.png new file mode 100644 index 0000000..90c2d8a Binary files /dev/null and b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/4.png differ diff --git a/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/index.md b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/index.md new file mode 100644 index 0000000..fab8cab --- /dev/null +++ b/080_blog/00020_Visual-Art/00035_A-quick-Trumpet-in-Blender/index.md @@ -0,0 +1,25 @@ +Hear the Trumpets hear the Pipers +================================= + November 9, 2017 +Today morning I was playing with blender’s cycles “material nodes”, the “sub-surf modifier” and the “depth of field” camera setting. + +I modeled a simple trumpet by extruding some cylinders and used the Diffuse and Glossy shaders for the trumpet, as well as a Wave texture for the marble surface. + +**Extruded** and scaled some basic **cylinders** to get a simple (yet unfinished) trumpet: + +![](1.png){.img-fluid} + +Added **materials**: + +![](2.png){.img-fluid} + +Added the **subsurf** modifier: + +![](3.png){.img-fluid} + +Configured **depth of field**: + +![](4.png){.img-fluid} + +Voila, ... it's alpha and omega's kingdom come. + diff --git a/080_blog/00020_Visual-Art/index.md b/080_blog/00020_Visual-Art/index.md new file mode 100644 index 0000000..b840fc7 --- /dev/null +++ b/080_blog/00020_Visual-Art/index.md @@ -0,0 +1,3 @@ +3D Art +====== +Some of my three dimensional creations, mostly in Blender. diff --git a/080_blog/00020_WWW-Projects-and-Apps/index.md b/080_blog/00020_WWW-Projects-and-Apps/index.md index fff14bc..75069b5 100644 --- a/080_blog/00020_WWW-Projects-and-Apps/index.md +++ b/080_blog/00020_WWW-Projects-and-Apps/index.md @@ -4,11 +4,12 @@ WWW and Apps A random selection of Web-sites, Web-shops, Web-portals and Mobile Apps. Most of this constitute contracted work. + - - - - False - - - True - False - vertical - True - - - True - False - vertical - - - True - True - in - - - True - True - - - - - True - True - 0 - - - - - True - True - False - False - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - True - True - - - 1 - True - True - True - - - 0 - 2 - - - - - 2 - True - True - True - - - 1 - 2 - - - - - 3 - True - True - True - - - 2 - 2 - - - - - 4 - True - True - True - - - 0 - 1 - - - - - 5 - True - True - True - - - 1 - 1 - - - - - 6 - True - True - True - - - 2 - 1 - - - - - 7 - True - True - True - - - 0 - 0 - - - - - 8 - True - True - True - - - 1 - 0 - - - - - 9 - True - True - True - - - 2 - 0 - - - - - 0 - True - True - True - - - 0 - 3 - - - - - . - True - True - True - - - 1 - 3 - - - - - = - True - True - True - - - 3 - 0 - - - - - ( - True - True - True - - - 2 - 3 - - - - - + - True - True - True - - - 0 - 4 - - - - - - - True - True - True - - - 1 - 4 - - - - - * - True - True - True - - - 2 - 4 - - - - - / - True - True - True - - - 3 - 4 - - - - - CLR - True - True - True - - - 3 - 1 - - - - - DEL - True - True - True - - - 3 - 2 - - - - - ) - True - True - True - - - 3 - 3 - - - - - True - True - 1 - - - - - - diff --git a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.hs b/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.hs deleted file mode 100644 index ec47e05..0000000 --- a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.hs +++ /dev/null @@ -1,74 +0,0 @@ --- Simple Stupid Calculator demonstrating basic gtk/glade and parsec parser usage -- --- Hacked togeter by Miguel on May 3, 2018 - -{-# LANGUAGE PackageImports #-} -import "gtk3" Graphics.UI.Gtk -import Control.Monad.IO.Class -import Data.ByteString.Char8 (pack,unpack) -import Numeric -import Text.Parsec -import Text.Parsec.Expr -import Text.Parsec.Language -import Text.Parsec.Number (fractional2) -import Text.Parsec.Token - --- parse calculation -- -calc s = case parse expr "" s of Right x -> showFFloat Nothing x "" - _ -> "?" - -table = [ [binary "*" (*) AssocLeft, binary "/" (/) AssocLeft ] - , [binary "+" (+) AssocLeft, binary "-" (-) AssocLeft ] ] - -lexer = makeTokenParser haskellDef -expr = buildExpressionParser table term "expression" -term = parens lexer expr <|> fractional2 False "simple expression" - -binary name fun assoc = Infix (do{ reservedOp lexer name; return fun }) assoc - --- gui for the calculator -- -main = do initGUI - builder <- builderNew - builderAddFromFile builder "calc.glade" - window <- builderGetObject builder castToWindow "mainWindow" - output <- builderGetObject builder castToTextView "output" - outputBuff <- textViewGetBuffer output - hist <- builderGetObject builder castToTextView "hist" - histBuff <- textViewGetBuffer hist - end<-textBufferGetEndIter histBuff - histMark <- textBufferCreateMark histBuff Nothing end True - - let conn = connBtn builder outputBuff - connA = connBtnAct builder outputBuff - - -- connecting buttons -- - sequence_ $ conn <$> map show [0..9] ++ ["+","-","/","*","(",")","."] - - connA "CLR" $ textBufferSetByteString outputBuff (pack "") - connA "DEL" $ manipTextBuff outputBuff (\x -> case x of [] -> []; xs -> init xs) - connA "=" $ do txt<-getTextBuff outputBuff - manipTextBuff outputBuff calc - res<-getTextBuff outputBuff - manipTextBuff histBuff (\x -> x++txt++" = "++res++"\n") - end<-textBufferGetEndIter histBuff - textBufferMoveMark histBuff histMark end - textViewScrollToMark hist histMark 0 $ Just (0,1) - return () - - -- handler to run on window destruction - window `on` deleteEvent $ do liftIO mainQuit - return False - widgetShowAll window - mainGUI - -getTextBuff outputBuff = do start<-textBufferGetStartIter outputBuff - end<-textBufferGetEndIter outputBuff - unpack <$> textBufferGetByteString outputBuff start end True - -manipTextBuff outputBuff action = do txt<-getTextBuff outputBuff - textBufferSetByteString outputBuff (pack $ action $ txt) - -connBtn builder buff label = connBtnAct builder buff label $ - textBufferInsertByteStringAtCursor buff (pack label) - -connBtnAct builder buff label act = do btn <- builderGetObject builder castToButton label - btn `on` buttonActivated $ act diff --git a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.png b/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.png deleted file mode 100644 index 7cb35c3..0000000 Binary files a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.png and /dev/null differ diff --git a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/index.md b/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/index.md deleted file mode 100644 index 381b017..0000000 --- a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/index.md +++ /dev/null @@ -1,23 +0,0 @@ -Simple Calculator on Parsec and GTK -=================================== - - May 3, 2018 - -![](calc.png){.img-fluid .border} - -Today I implemented this simple stupid calulator as a side effect of playing -around with parsec [1] and haskells gtk3 [2] bindings, as well as glade [3] - -an interactive user interface designer. - -Source Files ------------- - -* [calc.hs](calc.hs) -* [calc.glade](calc.glade) - -Ref ---- - - [1] https://hackage.haskell.org/package/parsec - [2] https://hackage.haskell.org/package/gtk3 - [3] https://glade.gnome.org/ diff --git a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/SimpleSvg.hs b/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/SimpleSvg.hs deleted file mode 100644 index 7b44557..0000000 --- a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/SimpleSvg.hs +++ /dev/null @@ -1,179 +0,0 @@ --- --- Miguel's Simple SVG Generator --- --- Author: Michal Idziorek --- Last Update: May 11th, 2018 --- - -{-# LANGUAGE ExistentialQuantification #-} - -module SimpleSvg ( - - svgExample1 -- predefined example canvas - -- you can generate the output string via: - -- putStr $ svgGenerate svgExample1 - - ,svgGenerate -- canvas to svg - - ,svgEmpty -- empty canvas - ,svgAdd -- add to canvas (single) - ,svgAddList -- add to canvas (list) - - ,svgCircle -- circle - ,svgLine -- line - ,svgTriangle -- trianvle - - ,svgFilledCircle -- filled circle - ,svgFilledLine -- filled line - ,svgFilledTriangle -- filled trianvle - - ,svgColor -- colors and shades of gray - ,svgRed - ,svgGreen - ,svgBlue - ,svgWhite - ,svgBlack - ,svgShGray - - - ,svgRedLine -- red line - ,svgBluePoint -- small blue circle - ,svgGreenTriangle -- green triangle - - - ) where - --- CONFIG -- - -svgStrokeWidth = 2 - --- EXAMPLE CANVAS -- - --- Demonstrating how to add a few objects to a light gray 300x200 canvas - -svgExample1 = svgAddList (svgEmpty (svgShGray 200) 300 200) $ - [ svgRedLine (0,0) (200,200) - ,svgRedLine (300,0) (100,200) - ,svgBluePoint (33,133) - ,svgBluePoint (33,22) - ,svgBluePoint (66,25) - ,svgFilledTriangle svgBlack svgWhite (20,20) (100,100) (10,90) - ,svgFilledCircle svgWhite svgGreen (150,120) 30 - ]++ - map (svgBluePoint . (,) 250) [50,60..150] - - --- SHAPES -- - --- A few predefined shapes easing a quickstart as well as serving as an --- example, for how to define them in your own code. - -svgRedLine = svgLine svgRed -svgBluePoint pos = svgCircle svgBlue pos 2 -svgGreenTriangle = svgTriangle svgGreen - - --- Shape construction - -svgLine c (x1,y1) (x2,y2) = - svgShape c (SvgLine (svgCoord x1 y1) (svgCoord x2 y2)) - -svgCircle c (x,y) r = - svgShape c (SvgCircle (svgCoord x y) r) - -svgTriangle c (x1,y1) (x2,y2) (x3,y3)= - svgShape c (SvgTriangle (svgCoord x1 y1) (svgCoord x2 y2) (svgCoord x3 y3)) - -svgFilledLine c1 c2 (x1,y1) (x2,y2) = - svgFilledShape c1 c2 (SvgLine (svgCoord x1 y1) (svgCoord x2 y2)) - -svgFilledCircle c1 c2 (x,y) r = - svgFilledShape c1 c2 (SvgCircle (svgCoord x y) r) - -svgFilledTriangle c1 c2 (x1,y1) (x2,y2) (x3,y3)= - svgFilledShape c1 c2 (SvgTriangle (svgCoord x1 y1) (svgCoord x2 y2) (svgCoord x3 y3)) - -svgShape c1 = SvgPrim c1 (svgNoFill) -svgFilledShape c1 c2 = SvgPrim c1 (svgFill c2) - --- CANVAS -- - -data SvgCanvas = SvgCanvas SvgColor Int Int [SvgPrim] - -svgEmpty c w h = SvgCanvas c w h [] -svgAdd (SvgCanvas c w h xs) x = SvgCanvas c w h (x:xs) -svgAddList (SvgCanvas c w h xs) ys = SvgCanvas c w h (reverse ys++xs) - -svgGenerate (SvgCanvas col width height prims) = - xml_enc "svg" [("height",show height),("width", show width), - ("style","background-color:"++svgGenColor col)] - body - where body = foldl f "" prims - f a x = primToSvg x++a - --- COLORS -- - --- color type along with a few predefined colors to work with - -newtype SvgColor = SvgColor (Int,Int,Int) -svgColor r g b = SvgColor (r,g,b) -svgRed = svgColor 255 0 0 -svgBlue = svgColor 0 0 255 -svgGreen = svgColor 0 255 0 -svgShGray v = svgColor v v v -svgBlack = svgShGray 0 -svgWhite = svgShGray 255 - -svgGenColor (SvgColor (r,g,b)) = "rgb("++show r++","++show g++","++show b++")" - --- the fill color is wrapped inside a Maybe type, since it is optional - -newtype SvgFill = SvgFill (Maybe SvgColor) -svgFill col = SvgFill (Just col) -svgNoFill = SvgFill Nothing - --- SHAPES -- - --- A class for shapes that we want to transform into SVG --- We define instances for circle, line and triangle --- The 2D coordinates are wrapped inside a newtype SvgCoord - -newtype SvgCoord = SvgCoord (Double,Double) -svgCoord x y = SvgCoord (x,y) - -data SvgPrim = forall a.SvgPrimClass a => SvgPrim SvgColor SvgFill a - -class SvgPrimClass a where - getSvg :: a->(String,[(String,String)]) - -data SvgCircle = SvgCircle SvgCoord Double -instance SvgPrimClass SvgCircle where - getSvg (SvgCircle (SvgCoord (x,y)) r) = - ("circle", [("cx",show x),("cy",show y),("r",show r)]) - -data SvgLine = SvgLine SvgCoord SvgCoord -instance SvgPrimClass SvgLine where - getSvg (SvgLine (SvgCoord (x1,y1)) (SvgCoord (x2,y2))) = - ("line", [("x1",show x1),("y1",show y1), - ("x2",show x2),("y2",show y2)]) - -data SvgTriangle = SvgTriangle SvgCoord SvgCoord SvgCoord -instance SvgPrimClass SvgTriangle where - getSvg (SvgTriangle (SvgCoord (x1,y1)) (SvgCoord (x2,y2)) (SvgCoord (x3,y3))) = - ("polygon", [("points",pts)]) - where pts=show x1++","++show y1++" "++ - show x2++","++show y2++" "++ - show x3++","++show y3 - --- transform single primitve to SVG -primToSvg (SvgPrim col (SvgFill fill) prim) = xml_enc tag (attrs++attrs2) "" - where (tag, attrs)=getSvg prim - attrs2=[ ("fill",maybe "none" svgGenColor fill) - ,("stroke",svgGenColor col) - ,("stroke-width",show svgStrokeWidth)] - --- XML ENCODER -- - -xml_enc tag attrs body = "<"++tag++" "++xml_attrs++">"++body++"" - where xml_attrs = unlines $ map xml_attr attrs - xml_attr (a,v) = a++"=\""++v++"\" " diff --git a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/index.md b/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/index.md deleted file mode 100644 index 8211ba2..0000000 --- a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/index.md +++ /dev/null @@ -1,31 +0,0 @@ -A Minimalistic SVG Generator -============================ - - May 11, 2018 - - -A minimalistic SVG generator for my humble requirements. -They might grow someday however... - -The SVG in the following screenshot was generated from the following code -to demonstrate a simple use case. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -svgExample1 = svgAddList (svgEmpty (svgShGray 200) 300 200) $ - [ svgRedLine (0,0) (200,200) - ,svgRedLine (300,0) (100,200) - ,svgBluePoint (33,133) - ,svgBluePoint (33,22) - ,svgBluePoint (66,25) - ,svgFilledTriangle svgBlack svgWhite (20,20) (100,100) (10,90) - ,svgFilledCircle svgWhite svgGreen (150,120) 30 - ]++ - map (svgBluePoint . (,) 250) [50,60..150] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -![](svg.png){.img-fluid .border} - -Source Files ------------- - -* [SimpleSvg.hs](SimpleSvg.hs) diff --git a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/svg.png b/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/svg.png deleted file mode 100644 index d679fad..0000000 Binary files a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/svg.png and /dev/null differ diff --git a/080_blog/00040_Haskell-Projects/00200_Estatico-Page-Maker/index.md b/080_blog/00040_Haskell-Projects/00200_Estatico-Page-Maker/index.md deleted file mode 100644 index 04bb46a..0000000 --- a/080_blog/00040_Haskell-Projects/00200_Estatico-Page-Maker/index.md +++ /dev/null @@ -1,35 +0,0 @@ -# Estático - A Static Website Genertor coded in Haskell - - April 12, 2018 - -About two weeks ago, for personal reasons, I decided to switch my website -from a well known PHP driven CMS solution, to a light and static set -of html pages. - -I used this fact to write my own simple static website generator. -And, Yes... I know there are already hundereds of such genertors -out there, but I wanted to practice Haskell and my masturbatory solution -fits in about 200 lines of code, including comments and type signatures. - -I use pandoc for all the heavy work, as syntax highlighting and parsing -of the markdown files, anyway. - -## Features - -* No Database -* Static Content -* Sitemap derived from Directory Tree -* Simple Markdown Files - -## Try It -You can find the most recent version here and build it with _stack_. - -* [https://gitweb.softwarefools.com/?p=miguel/staticuswww.git](https://gitweb.softwarefools.com/?p=miguel/staticuswww.git) - -__Do not forget to adapt the Makefile to your requirements__ - -## Examples -The only example I know of, is this very page: _idziorek.net_ -You can find it's sources here: - -* [https://gitweb.softwarefools.com/?p=miguel/idziorek\_net.git](https://gitweb.softwarefools.com/?p=miguel/idziorek_net.git) diff --git a/080_blog/00040_Haskell-Projects/index.md b/080_blog/00040_Haskell-Projects/index.md deleted file mode 100644 index 5a0766d..0000000 --- a/080_blog/00040_Haskell-Projects/index.md +++ /dev/null @@ -1,4 +0,0 @@ -Haskell -======= - -Some of my small and tiny Haskell creations and notes. diff --git a/080_blog/00040_Haskell/00010_Links-and-Notes-and-Literature/index.md b/080_blog/00040_Haskell/00010_Links-and-Notes-and-Literature/index.md new file mode 100644 index 0000000..6e82b3b --- /dev/null +++ b/080_blog/00040_Haskell/00010_Links-and-Notes-and-Literature/index.md @@ -0,0 +1,36 @@ +# Haskell + +## Books, Links and Papers + +* **Learn You a Haskell** for Great Good by Marian Lipovaca +* **Real World Haskell** by Bryan O'Sullivan, Don Stewart, and John Goerzen +* **Parallel and Concurrent Programming in Haskell** by Simon Marlow + +* **Haskell Wiki** https://wiki.haskell.org +* **UPENN CIS 194** https://www.seas.upenn.edu/~cis194/spring13/ +* **What I Wish I Knew When Learning Haskell** by Stephen Diehl +* **Data61 Course** https://github.com/data61/fp-course + +* **Monads for functional programming (paper)** by Philip Wadler +* **Functional Pearl (paper)** +* **Why Functional Programming Matters (paper)** + +* **Mailing Lists** https://www.haskell.org/mailing-lists/ +* **IRC** #haskell at chat.freenode.at +* **Monadic Warsaw** + + +## Xmonad + +My little contribution to xmonad-contrib: + +* Added pretty printer for empty visible workspaces (wrapped in Maybe) + https://github.com/xmonad/xmonad-contrib/pull/241 + +## GHC Flags (TODO: put here all the other flags I have documentend in this Makefile somweher :P ) + -gq ? + +## monad transformers in action + + Main Control.Monad.Writer Control.Monad.State> runState (runWriterT (get >>= \a -> tell ["foo"] >> put (a*a) >> tell ["bar"] >> tell [show a])) 5 + diff --git a/080_blog/00040_Haskell/00040_Graham-Scan/index.md b/080_blog/00040_Haskell/00040_Graham-Scan/index.md new file mode 100644 index 0000000..195dbe1 --- /dev/null +++ b/080_blog/00040_Haskell/00040_Graham-Scan/index.md @@ -0,0 +1,128 @@ +Haskell – Convex Hull – Graham Scan +=================================== + +December 16, 2017 + +Playing with Convex Hulls (via Graham Scan) and SVG Export in Haskell: + +This is an embedded SVG generated by the Haskell programm below: + + + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} +--------------------------------------------------------------------------------------------- +-- +-- GRAHAM SCAN IMPLEMENTATION +-- +-- This little haskell programm calulates the Convex Hull for a set of 2D points. +-- It ships wit a main function that feeds the Graham Scan algorithm with some +-- random points and generates a simple SVG of the input points and resulting envelope. +-- A simple SVG encoder is included. +-- +-- Alogrithm used: https://en.wikipedia.org/wiki/Graham_scan +-- +-- CREDITS -- +-- +-- Michal Idziorek +-- 16 December 2017 +-- +--------------------------------------------------------------------------------------------- + +import Data.List +import System.Random + +--------------------------------------------------------------------------------------------- + +-- GRAHAM SCAN -- + +-- Three points are clockwise if ccw < 0. +ccw (p1x,p1y) (p2x,p2y) (p3x,p3y) = (p2x - p1x)*(p3y - p1y) - (p2y - p1y)*(p3x - p1x) + +-- Calculate the slope defined by 2 points. (return Infinity, if points are identical). +slope (ax,ay) (bx,by) | (ax,ay ) == (bx,by) = 1/0 -- Infinity + | otherwise = (bx-ax)/(by-ay) + +-- Comparison function to sort points counterclockwise (given a reference point). +slope_cmp a b c = compare (slope a c) (slope a b) + +-- Comparison function using the y and x coordinates for ordering. +graham_cmp (ax,ay) (bx,by) | ay /= by = compare ay by + | otherwise = compare ax bx + +-- Graham scan on prepared data. this will calculate the convex hull. +graham_calc [] hs = hs +graham_calc (x1:xs) hh | length(hh) < 2 = graham_calc xs (x1:hh) +graham_calc xx@(x1:xs) hh@(h1:h2:hs) | ccw x1 h1 h2 < 0 = graham_calc xs (x1:hh) + | otherwise = graham_calc xx (h2:hs) + +-- Find the starting point, sort all points counterclockwise and perform the graham scan. +graham xs = graham_calc sortedPoints [] + where minPoint = minimumBy graham_cmp xs + sortedPoints = sortBy (slope_cmp minPoint) xs + +--------------------------------------------------------------------------------------------- + +-- XML ENCODING-- + +xml_attr (x:xs) = x++"=\""++(head xs)++"\" " +xml_enc tag attrs body = "<"++tag++" "++xml_attrs++">"++body++"" + where xml_attrs = unlines $ map xml_attr attrs + +-- SVG ENCODING -- + +-- hardcoded scaling and panning function +svg_transf x = x*30+5 + +line_to_svg ((x1,y1),(x2,y2)) = xml_enc "line" [["x1",show lx1],["y1",show ly1], + ["x2",show lx2],["y2",show ly2], + ["style", "stroke:rgb(255,0,0);stroke-width:2"]] "" + where lx1=svg_transf x1 + lx2=svg_transf x2 + ly1=svg_transf y1 + ly2=svg_transf y2 + +point_to_svg (x,y) = xml_enc "circle" [["cx",show cx],["cy",show cy],["r","5"], + ["fill","rgb(30,150,"++(show (floor dist))++")"]] "" + where cx=svg_transf x + cy=svg_transf y + dist= (sqrt ((x-5)*(x-5) + (y-5)*(y-5)))*255/8 + + + +-- draws SVG points and lines (in hardcoded sizes and colors) +svg_draw p l = xml_enc "svg" [style,["width","330"],["height","330"]] body + where style = ["style", + "background-color:black;border:3px solid green;margin:2px;"] + body = (unlines (map point_to_svg p )) ++ + (unlines (map line_to_svg l )) + +-- calculate convex hull and generate svg +svg_graham xs = svg_draw xs (zip hull hull_open) + where hull_open = graham xs + hull = (last hull_open) : hull_open + +-- RANDOMIZING -- + +randomPoints g cnt = take cnt (zip r10a r10b) + where r5 = randomRs (0,5) g :: [Double] + r10a =zipWith (+) r5 (drop cnt r5) + r10b =zipWith (+) (drop (2*cnt) r5) (drop (3*cnt) r5) + +--------------------------------------------------------------------------------------------- + +-- MAIN -- + +-- Note that this is the only place of impurity in this source-file. +-- Is is subject to side effects due to I/O (we are writng to stdout) +-- and the random number generator. +main = do + g <- newStdGen + putStr (svg_graham (randomPoints g 25)) + putStr (svg_graham (randomPoints g 50)) + putStr (svg_graham (randomPoints g 100)) + putStr (svg_graham (randomPoints g 250)) + putStr (svg_graham (randomPoints g 500)) + putStr (svg_graham (randomPoints g 1500)) + +--------------------------------------------------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/080_blog/00040_Haskell/00065_Base64-Encoder/base64.cast b/080_blog/00040_Haskell/00065_Base64-Encoder/base64.cast new file mode 100644 index 0000000..63fece1 --- /dev/null +++ b/080_blog/00040_Haskell/00065_Base64-Encoder/base64.cast @@ -0,0 +1,322 @@ +{ + "duration": 14.820928, + "title": null, + "env": { + "SHELL": "/bin/bash", + "TERM": "screen-256color" + }, + "width": 106, + "stdout": [ + [ + 0.019966, + "miguel@megaloman:~$ " + ], + [ + 1.524665, + "t" + ], + [ + 0.08111, + "h" + ], + [ + 0.095838, + "i" + ], + [ + 0.118019, + "s" + ], + [ + 0.086883, + " " + ], + [ + 0.089573, + "i" + ], + [ + 0.134283, + "s" + ], + [ + 0.096031, + " " + ], + [ + 0.114016, + "a" + ], + [ + 0.166151, + " " + ], + [ + 0.319094, + "l" + ], + [ + 0.195916, + "o" + ], + [ + 0.142042, + "c" + ], + [ + 0.139961, + "a" + ], + [ + 0.07801, + "l" + ], + [ + 0.081012, + " " + ], + [ + 0.094941, + "a" + ], + [ + 0.120898, + "s" + ], + [ + 0.107959, + "c" + ], + [ + 0.115993, + "i" + ], + [ + 0.137871, + "i" + ], + [ + 0.205335, + "n" + ], + [ + 0.108673, + "e" + ], + [ + 0.127436, + "m" + ], + [ + 0.123916, + "a" + ], + [ + 0.244565, + "\r\n" + ], + [ + 0.000482, + "bash: this: command not found\r\n" + ], + [ + 0.000346, + "miguel@megaloman:~$ " + ], + [ + 1.012884, + "this is a local asciinema" + ], + [ + 0.230737, + "\r\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C" + ], + [ + 0.140235, + "\u001b[1@e" + ], + [ + 0.097927, + "\u001b[1@c" + ], + [ + 0.188824, + "\u001b[1@j" + ], + [ + 0.000974, + "\u001b[1@o" + ], + [ + 0.421424, + "\b\u001b[1P" + ], + [ + 0.117902, + "\b\u001b[1P" + ], + [ + 0.208192, + "\u001b[1@h" + ], + [ + 0.115112, + "\u001b[1@ " + ], + [ + 0.012814, + "\u001b[1@o" + ], + [ + 0.295287, + "\r\n" + ], + [ + 0.000755, + "bash: ech: command not found\r\n" + ], + [ + 0.000509, + "miguel@megaloman:~$ " + ], + [ + 0.480858, + "ech othis is a local asciinema" + ], + [ + 0.192018, + "\r\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C" + ], + [ + 0.237975, + "\u001b[C" + ], + [ + 0.118994, + "\u001b[C" + ], + [ + 0.146091, + "\u001b[1P" + ], + [ + 0.348015, + "\u001b[1P" + ], + [ + 0.562446, + "\u001b[1@h" + ], + [ + 0.437804, + "\u001b[C" + ], + [ + 0.219332, + "\u001b[1@ " + ], + [ + 0.220637, + "\r\n" + ], + [ + 0.000486, + "this is a local asciinema\r\n" + ], + [ + 0.000206, + "miguel@megaloman:~$ " + ], + [ + 1.218406, + "m" + ], + [ + 0.079499, + "c" + ], + [ + 0.170894, + "\r\n" + ], + [ + 0.00735, + "\u001b[?1049h\u001b[?1h\u001b=" + ], + [ + 0.000586, + "\u001b[1;9r\u001b[4l\u001b(B\u001b)0\u001b[9;1H\u001b[m\u000f\u001b[37m\u001b[40m\u001b[m\u000f\u001b[39;49m\r \r\u001b[?1l\u001b>\u001b[?1049l\u001b[?1049h\u001b[?1h\u001b=" + ], + [ + 0.021657, + "\u001b[?1001s\u001b[?1002h\u001b[?1006h\u001b[?2004h" + ], + [ + 0.000429, + "\u001b[1;9r\u001b[4l\u001b(B\u001b)0\u001b[?1h\u001b=\u001b[m\u000f\u001b[39m\u001b[49m\u001b[1;9r\u001b[H\u001b[J\u001b[2;105H\u001b[1K \u001b[37m\u001b[40m|\u001b[2;106H" + ], + [ + 0.000193, + "\b\u001b[39m\u001b[49m\u001b[1K \u001b[37m\u001b[40m╗\u001b[2;106H" + ], + [ + 0.000114, + "\b\u001b[39m\u001b[49m\u001b[1K \u001b[37m\u001b[40m/\u001b[2;106H" + ], + [ + 0.000129, + "\b\u001b[39m\u001b[49m\u001b[1K \u001b[37m\u001b[40m╗\u001b[2;106H" + ], + [ + 0.000156, + "\u001b]0;mc [miguel@megaloman]:~\u0007\u001b>" + ], + [ + 0.000337, + "\u001b[7;1H\u001b[39m\u001b[49mHint: Want your plain shell? Press C-o, and get back to MC with C-o again.\u001b[7;106H" + ], + [ + 0.000251, + "\u001b]0;mc [miguel@megaloman]:~\u0007\u001b>" + ], + [ + 0.000102, + "\u001b[1;1H\u001b[30m\u001b[47m Left File Command Options Right \u001b[2;1H\u001b[37m\u001b[40m╔«═\u001b[97m\u001b[105m ~ \u001b[37m\u001b[40m═════════════════════════════════════════⋅[^]»╗╔«═ ~ ═════════════════════════════════════════⋅[^]»\r\n║\u001b[97m↑n Name \u001b[37m│\u001b[97m Size \u001b[37m│\u001b[97mModify time \u001b[37m║║\u001b[97m↑n Name \u001b[37m│\u001b[97m Size \u001b[37m│\u001b[97mModify time \u001b[37m║\u001b[4;1H╟───────────────────────────────────────────────────╢╟───────────────────────────────────────────────────╢\u001b[5;1H║UP--DIR ║║" + ], + [ + 1e-05, + "UP--DIR ║\u001b[6;1H╚═════════════════════════════════ 158G/234G (67%) ═╝╚═════════════════════════════════ 158G/234G (67%) ═╝\u001b[8;1H\u001b[39m\u001b[49mmiguel@megaloman:~$\u001b[84C\u001b[31m[^]\u001b[9;1H 1\u001b[97mHelp \u001b[31m 2\u001b[97mMenu \u001b[31m 3\u001b[97mView \u001b[31m 4\u001b[97mEdit \u001b[31m 5\u001b[97mCopy \u001b[31m 6\u001b[97mRenMov \u001b[31m 7\u001b[97mMkdir \u001b[31m 8\u001b[97mDelete \u001b[31m 9\u001b[97mPullDn \u001b[31m10\u001b[97mQuit \u001b[9;105H \b\u001b[4h \u001b[4l\u001b[8;21H" + ], + [ + 1.221371, + "\u001b[1;1H\u001b[39m \u001b[2;1H \u001b[3;1H \u001b[4;1H \u001b[5;1H \u001b[6;1H \u001b[7;1H \u001b[8;1H \u001b[9;1H \u001b[1;106H\u001b[?2" + ], + [ + 4.5e-05, + "004l\u001b[?1006l\u001b[?1002l\u001b[?1001r" + ], + [ + 0.000416, + "\u001b[?1l\u001b>\u001b[9;1H\u001b[m\u000f\u001b[39;49m\r \r\u001b[?1l\u001b>\u001b[?1049l\u001b[39;49m" + ], + [ + 0.000319, + "\r\n" + ], + [ + 0.001118, + "miguel@megaloman:~$ " + ], + [ + 0.791031, + "e" + ], + [ + 0.62602, + "\b\u001b[K" + ] + ], + "height": 9, + "command": null, + "version": 1 +} \ No newline at end of file diff --git a/080_blog/00040_Haskell/00065_Base64-Encoder/index.md b/080_blog/00040_Haskell/00065_Base64-Encoder/index.md new file mode 100644 index 0000000..0ede6cf --- /dev/null +++ b/080_blog/00040_Haskell/00065_Base64-Encoder/index.md @@ -0,0 +1,19 @@ +Miguel's Base64 Encoder +======================= + February 19, 2018 + +Coded on a winter afternoon to fully understand **base64 encoding** and play with +**Haskell**, which is always an indisputable pleasure. + +Coded in _big anger_, due to Nick's fairy tales about saving his encrypted binary +data in plain ASCII configuration files, featuring strange letters and +non-printable characters. :P + + + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} +{BEGIN:EMBED} +https://gitweb.softwarefools.com/?p=miguel/haskell.git;a=blob_plain;f=base64/base64.hs +{END:EMBED} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The above code was auto-fetched from: diff --git a/080_blog/00040_Haskell/00120_Lambda-Calculus/index.md b/080_blog/00040_Haskell/00120_Lambda-Calculus/index.md new file mode 100644 index 0000000..25c6b83 --- /dev/null +++ b/080_blog/00040_Haskell/00120_Lambda-Calculus/index.md @@ -0,0 +1,38 @@ +Lambda Calculus +=============== + + May 2, 2018 + +Playing with Type Quantifiers and Haskell's Rank 2 Type Polymorphsim, +implementing Boolean logic from scratch. We use the conventional +definitions for `True` an `False` also known as Church booleans, after Alonzo Church, who +intruced them along Lambda Calculus in the 1930s [1]. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} +{-# LANGUAGE Rank2Types #-} + +fTrue :: forall a. a->a->a +fTrue x y = x + +fFalse :: forall a. a->a->a +fFalse x y = y + +fAnd :: (forall a. a->a->a)->(forall a. a->a->a)->(forall a. a->a->a) +fAnd p q = p q p + +fOr :: (forall a. a->a->a)->(forall a. a->a->a)->(forall a. a->a->a) +fOr p q = p p q + +fNot :: (forall a. a->a->a)->(forall a. a->a->a) +fNot p = p fFalse fTrue + +ifThenElse :: (forall a. a->a->a)->(forall a. a->a->a) + ->(forall a. a->a->a)->(forall a. a->a->a) +ifThenElse p a b = p a b + +-- Example -- + +main = print $ (ifThenElse fFalse fFalse $ fAnd fTrue $ fNot fFalse) "T" "F" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + [1] https://en.wikipedia.org/wiki/Lambda_calculus diff --git a/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/index.md b/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/index.md new file mode 100644 index 0000000..381b017 --- /dev/null +++ b/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/index.md @@ -0,0 +1,23 @@ +Simple Calculator on Parsec and GTK +=================================== + + May 3, 2018 + +![](calc.png){.img-fluid .border} + +Today I implemented this simple stupid calulator as a side effect of playing +around with parsec [1] and haskells gtk3 [2] bindings, as well as glade [3] - +an interactive user interface designer. + +Source Files +------------ + +* [calc.hs](calc.hs) +* [calc.glade](calc.glade) + +Ref +--- + + [1] https://hackage.haskell.org/package/parsec + [2] https://hackage.haskell.org/package/gtk3 + [3] https://glade.gnome.org/ diff --git a/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/index.md b/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/index.md new file mode 100644 index 0000000..8211ba2 --- /dev/null +++ b/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/index.md @@ -0,0 +1,31 @@ +A Minimalistic SVG Generator +============================ + + May 11, 2018 + + +A minimalistic SVG generator for my humble requirements. +They might grow someday however... + +The SVG in the following screenshot was generated from the following code +to demonstrate a simple use case. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} +svgExample1 = svgAddList (svgEmpty (svgShGray 200) 300 200) $ + [ svgRedLine (0,0) (200,200) + ,svgRedLine (300,0) (100,200) + ,svgBluePoint (33,133) + ,svgBluePoint (33,22) + ,svgBluePoint (66,25) + ,svgFilledTriangle svgBlack svgWhite (20,20) (100,100) (10,90) + ,svgFilledCircle svgWhite svgGreen (150,120) 30 + ]++ + map (svgBluePoint . (,) 250) [50,60..150] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +![](svg.png){.img-fluid .border} + +Source Files +------------ + +* [SimpleSvg.hs](SimpleSvg.hs) diff --git a/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/svg.png b/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/svg.png new file mode 100644 index 0000000..d679fad Binary files /dev/null and b/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/svg.png differ diff --git a/080_blog/00040_Haskell/00150_Applicative-vs-Monadic-Parsing/index.md b/080_blog/00040_Haskell/00150_Applicative-vs-Monadic-Parsing/index.md new file mode 100644 index 0000000..f9b3a4e --- /dev/null +++ b/080_blog/00040_Haskell/00150_Applicative-vs-Monadic-Parsing/index.md @@ -0,0 +1 @@ +Coming sooner... or later. diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/index.md b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/index.md new file mode 100644 index 0000000..63f9816 --- /dev/null +++ b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/index.md @@ -0,0 +1,55 @@ +# estático - static website generator + + April 12, 2018 + +Two weeks ago I decided to switch my website from a well known PHP +driven CMS solution, to a light and static set of HTML pages. + +And so I wrote a simple static website generator in +**Haskell**. Of course I know that there are already hundreds out there, +but I wanted my own masturbatory solution. + +I use **pandoc** et al. for most of the work anyway. + +## Features + +* **No** Database +* Input with Simple **Markdown** Files +* Generates **Static HTML** Content +* Embedding data **fetched** via **http/https** +* Embedding self-hosted **asciinema** casts +* Embedding Latex formulas via **MathJx** +* Image Scaling with **ImageMagick** +* Syntax **Highlighting** + +## Try It +You can find the most recent version following the links below. +Build it with _stack_ or use the docker images. + +* +* +* + +## Example Usage +__NOTE: make sure DIR\_OUT exists and is a free directory__ + +You can use the example websites inside the examples/ directory for a start. + +Inside the input directory (e.g. ./examples/example01/) run something along this lines: + + DIR_IN=`pwd` + DIR_OUT=/mnt/yourwebsiteroot + HTML_ROOT=https://www.example.com + SUDO=sudo + IMAGE=migueldirty/estatico + ${SUDO} docker run --rm -v${DIR_IN}:/in:ro -v${DIR_OUT}:/out:rw ${IMAGE} /in /out ${HTML_ROOT} + +Or if you want to test it locally use some local DIR\_OUT and HTML\_ROOT instead: + + DIR_OUT=/home/miguel/testpage + HTML_ROOT=/home/miguel/testpage + +The only real life example I know of, is this very page: _idziorek.net_ +You can find it's sources here: + +* diff --git a/080_blog/00040_Haskell/index.md b/080_blog/00040_Haskell/index.md new file mode 100644 index 0000000..2c02a65 --- /dev/null +++ b/080_blog/00040_Haskell/index.md @@ -0,0 +1,8 @@ +Haskell +======= + +Originally coming from structured and object-oriented programming, I fell +in love with Haskell a couple of years ago. I appreciate it's purity +and laziness and the powerful, static type system. + +You can find here my notes and tiny toy projects related to Haskell. diff --git a/080_blog/00110_Fool-Operating-System/index.md b/080_blog/00110_Fool-Operating-System/index.md new file mode 100644 index 0000000..23e18d4 --- /dev/null +++ b/080_blog/00110_Fool-Operating-System/index.md @@ -0,0 +1,9 @@ +Fool OS +======= + +My little buggy toy operating system is a never ending work in progres... + +* [reference](https://www.idziorek.net/~miguel/fool-os-ref/) +* [git](https://gitweb.softwarefools.com/?p=miguel/fool-os.git) + +The ref is outdates as far as I saw last time.. -- cgit v1.2.3