# Mathematical Notation with KaTeX

This is a follow up on the previous article Mathematical Notation with MathJax. Be forewarned that the implementation of mathematical notation with KaTeX, which is a JavaScript display engine for mathematics, is still in its infancy. kramdown natively supports mathematical formulas of the TeX/LaTeX syntax in Markdown for display with MathJax, but not for KaTex. For these reasons you'll probably run into some compatibility issues and you need to fix the kramdown markup yourself. Nevertheless, it's the fastest math typesetting library for the web. It's performance is indeed impressive and issues are being worked on at a fast pace by a bunch of great open source developers.

# How to Properly Deploy a Rails App

Deploying a production ready Ruby on Rails app on a Linux Server should be the easiest thing in the world. Nevertheless, information on this subject is scarse, outdated or stunningly confusing. Even more so when using a ruby version management system like rbenv or rvm who demand for a user to have a certain environment via the shells startup script.

Puma, the built-in Ruby/Rack web server in Rails 5 is solid and describes itself as "simple, fast, threaded, and highly concurrent". We can safely...

# SSH Issues on macOS Sierra and Higher

The following enables you once more to only use ssh user@domain.com without ever having to enter a password or passphrase again in macOS 10.12+ .

# Normal Command
ssh user@domain.com

# Command for Debugging
ssh user@domain.com -vvv


## SSH Key Creation

# Command
ssh-keygen -t ed25519 -o -a 100

# Output
Generating public/private ed25519 key pair.
Enter file in which to save the key (/Users/crstin/.ssh/id_ed25519):
Created directory '/Users/crstin/.ssh'.


Use a secure passphrase like 6R9vcrxn1z17gDn2pUSoXUSHSa2UIK

# How to Self-Host your own git repository

You can self-host your own git repository, thus avoiding services like github, gitlab, bitbucket. This gives you full control over the repositories. Make as many as you want and make them private or public as you please. Serve it under you own domain. Allow and use whatever licenses you prefer.

## Gitea

Gitea, which describes itself as a painless self-hosted Git service, is written in the go language (utilising the hugo generator) and is therefore highly efficient and super fast.

# Extracting the Current Webview

wget wget --recursive --no-clobber --page-requisites --convert-links --no-parent https://example.com/subfolder/


## Options

• no-clobber: don't overwrite any existing files (used in case the download is interrupted and resumed).
• page-requisites: get all the elements that compose the page (images, CSS and so on).

# Learn Regex - The Easy Way

## What is Regular Expression?

Regular expression is a group of characters or symbols which is used to find a specific pattern from a text.

A regular expression is a pattern that is matched against a subject string from left to right. The word "Regular expression" is a mouthful, you will usually find the term abbreviated as "regex" or "regexp". Regular expression is used for replacing a text within a string, validating form, extract a substring from a string based upon a pattern match, and so much more.

Imagine you are writing an application and you want to set the rules when user choosing their username. We want the username can contains letter, number, underscore and hyphen. We also want to limit the number of characters in username so it does not look ugly. We use the following regular expression to validate a username:

#  Start of the line
#          |   3 to 15 characters long
#          |             |
#          |             |
^[a-z0-9_-]{3,15}$# | | # | | # | End of the line # letters, numbers, underscores, hyphens  Above regular expression can accept the strings john_doe, jo-hn_doe and john12_as. It does not match Jo because that string contains uppercase letter and also it is too short. # Is it possible to parse HTML with Regex? You cannot parse [X]HTML by using Regex. Because the HTML language cannot be parsed by Regex. Regex is not a tool that can be used to parse HTML correctly. As I replied in HTML and regex questions here so many times before, using Regex will not allow you to consume HTML. Regular expressions are a poorly developed tool for understanding the constructions used by HTML. HTML is not a normal language and cannot be parsed by regular expressions. Regex queries are not equipped to divide the HTML code into its significant parts. So often, but it's not always for me. Even the irregular extended regular expressions used by Perl are not the task of HTML parsing. You're never going to let me crack. HTML is a language with sufficient complexity that cannot be parsed by regular expressions. Even Jon Pigeon cannot parse the HTML with regular expressions. Every time you try to parse the HTML code with regular expressions, the child cries the blood of the virgins, and the Russian pirates have their webapp. Parsing HTML with Regex gets the corrupted soul in the Kingdom of the living. HTML and Regex go together like love, marriage and killing of ritual children. The <center> cannot hold, it's too late. The power of Regex and HTML together in the same conceptual space will destroy your mind, like so many putty water. If you analyze the HTML code with Regex, give it to you and your blasphemous possibilities, that all of us to inhuman problems for those whose name cannot be expressed in the basic multilingual plan, it is. HTML Plus-RegExp You melt the erves of the while you observe your psyche in the onslaught of terror. Rege̿̔̉X-based HTML parser are cancer that kills StackOverflow is too late, it is too late, we can not be saved the trangession of a guaranteed Chi͡LD Regex will consume all living tissues (except HTML,) that can not, as already prophesied, dear Sir, help us, how can anyone survive this plague with HTML regex analysis, mankind has become an eternity of torture and dreadlocks with regex as a tool for HTML processing becomes a pause between this world and the frightening realm of entities C͒ͪo͛ͫrrupt (as the SGML entities, but more corrupted) a simple glimpse of the world of the ex reg parser for HTML goes to the auntyly carrying a programmer consciousness in a world of endless cries, it is, the stench Alacridi infection Regex Wil L devour the HT-ML parser, the application and the existence of all the time that Visual Basic gets only worse does not come with it com̡e̶s , ̕h̵i s un̨ho͞ly radiańcé destro҉Ying all ENLI̍̈́̂̈́ghtenment, tags HTML Lea͠Ki̧n͘g FR̶ǫm ̡yo ͟ur Eye͢s̸u ̛l̕IK͏e FL UID Pain, the song of Re̸gular exp resion analysis will fire nguish the voices of the man Mor Tal of the SP here can see that he can see you ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ is quite t he finally turn off the man lies everything is LOŚ͖̩͇̗̪̏̈́T all that I lost the pon̷y it is , you C̶̮OMES it is I or penetrates all my face my face or H god no no noo̼O or Nato stop A * ̶͑̾̾ ̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ za̡͊͠͝LGΌ isͮ̂҉̯͈͕̹̘̱ to͇̹̺ͅɲ̴ȳ̳ TH̘Ë͖́̉a ͠P̯͍̭O̚ N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎ȩ̬̩̾͛ͪ̈́̀́͘ Have you tried using an XML parser instead? bobince # Photoswipe # Effectively Remove all Folders With this command you can recursively remove all node_modules folders within a path. find . -type d -name "node_modules" -prune -exec rm -rf '{}' +  # Mathematical Notation with MathJax The implementation of mathematical notation with MathJax, which is a JavaScript display engine for mathematics, works in all browsers. kramdown natively supports mathematical formulas of the TeX/LaTeX syntax in Markdown. # Disable SIP & Gatekeeper ## SIP csrutil status System Integrity Protection status: enabled.  To disable the System Integrity Protection (SIP) you need to boot your Mac into Recovery Mode (CMD + R) and enter the following into the terminal. csrutil disable Successfully disabled System Integrity Protection. Please restart the machine for the changes to take effect.  ### SIP Restrictions # Enable SIP and allow installation of unsigned kernel extensions csrutil enable --without kext # Enable SIP and disable filesystem protections csrutil enable --without fs # Enable SIP and disable debugging restrictions csrutil enable --without debug # Enable SIP and disable DTrace restrictions csrutil enable --without dtrace # Enable SIP and disable restrictions on writing to NVRAM csrutil enable --without nvram  System Integrity Protection – Adding another layer to Apple’s security model ## Gatekeeper # Per Application: sudo xattr -rd com.apple.quarantine /Applications/SelectApp.app # Globally: sudo spctl --master-disable  # Letsencrypt Certificate for each Domain Letsencrypt offers you to combine multiple domains into a single certificate or to separate them for each domain. When doing the latter you should mind the rate limits. cli.ini rsa-key-size = 4096 #server = https://acme-v01.api.letsencrypt.org/directory authenticator = webroot webroot-path = /var/www email = youremail@domain.tld renew-by-default = True agree-tos = True  certbot --config /etc/letsencrypt/cli.ini certonly -d sub.domain.tld  You can also combine a group of domains to share a single certificate. certbot --config /etc/letsencrypt/cli.ini certonly -d domain.tld -d www.domain.tld -d sub.domain.tld  httpd.conf SSLCertificateFile /etc/letsencrypt/live/$servername/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$servername/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/$servername/chain.pem


List apache vhosts

## Renewal

certbot --config /etc/letsencrypt/cli.ini renew


# List Apache Vhosts

You can list all of your apache/httpd vhosts with this command.

# normal
httpd -S | rg '^.*namevhost (\S+) $$.*' --replace '1' | sort -u # with counter httpd -S | rg '^.*namevhost (\S+) \(.*' --replace '1' | sort | uniq -c  You need to install ripgrep or substitute it with sed. ## Other useful httpd commands Show all included configuration files. httpd -t -D DUMP_INCLUDES  Show all loaded modules. httpd -M  Run syntax check for config files. httpd -t Syntax OK  # Export Man Pages To get a plain text version of a man page, without backspaces and underscores, try: man foo | col -bx > foo.txt  Or copy it instead. man foo | col -bx | pbcopy  For a clipboard in Linux you might need to add: # with xsel alias pbcopy='xsel --clipboard --input' alias pbpaste='xsel --clipboard --output' # or with xclip: alias pbcopy='xclip -selection clipboard' alias pbpaste='xclip -selection clipboard -o'  ## Ability to escape HTML Characters Put this function in your .zshrc/.bashrc/etc. escape_html... # Git - Rewriting History When there are (large or unnecessary) files in your git repository that you want to remove from history you can use the follwing methods. Typical repos shrink from about 20 MB to less than 1 MB. 1 Use git-filter-branch or install BFG. brew install bfg # Show sizes of files and folders du -sh {.*,*}  # Find 10 biggest Files in Repo # https://stackoverflow.com/questions/10622179/how-to-find-identify-large-files-commits-in-git-history#20609719 git gc git rev-list --objects --all | grep "( # CSS nth ## nth of single type 1234567891011nth-child (8) (n+6) (-n+9) (n+4)(-n+8) (n+2)(odd) (3n+1)(even) .e:nth-child(8) { ... } .e:nth-child(n+6) { ... } .e:nth-child(-n+9) { ... } .e:nth-child(n+4):nth-child(-n+8) { ... } .e:nth-child(n+2):nth-child(odd):nth-child(-n+9) { ... } .e:nth-child(3n+1):nth-child(even) { ... }  # JavaScript Key Codes Press any key to get corresponding code:  Key Shift Code 16 This prints the JavaScript codes for any key on your keyboard. You can use the code number to assign an event to the key. window.addEventListener('keydown', funcname, false); function funcname(e) { /* up */ if (e.keyCode === 38 ) { exec_if_pressed() } /* dn */ if (e.keyCode === 40 ) { exec_if_pressed() } /*  */ if (e.keyCode === 220 ) { exec_if_pressed() } // etc. }  # How To Pass Options With Gulp You can pass options to your gulp task via the { key0: value, key1: value, key2: value, ... } syntax. ## Example for gulp-purifycss The task gulp-purifycss uses purifycss. .pipe(purify(['./public/app/**/*.js', './public/**/*.html']))  becomes .pipe(purify(['./public/app/**/*.js', './public/**/*.html'], { minify: true, info: true, rejected: false }))  ## Example for gulp-rsync The task gulp-rsync uses rsync. gulp.task('deploy', function() { return gulp.src('build') .pipe(rsync({ root # Where to get Good Weather Information # How To Run A Custom Ruby Gem From Any Path You can run custom ruby gems from any path, for instance local machine, LAN or remotely, without the necessity to go over the official ruby gem index. Specifying a :path attribute will install the gem from that path on your local machine. gem "foreman", :path => "/Users/pje/my_foreman_fork"  Alternately, specifying a :git attribute will install the gem from a remote git repository. gem "foreman", :git => "git://github.com/pje/foreman.git" # ...or at a specific SHA-1 ref gem "foreman", :git # Understanding Terminal Colors # How to log your IP Address Have you you ever thought: "Mhmmm… was that me behind that IP address at this particular point in time? I wish I'd know that because THAT WOULD HELP ME A LOT TO DETERMINE IF I HAVE AN ISSUE HERE OR NOT!" ## Bash script #!/bin/bash ipcur=(curl -s ipecho.net/plain) if ! tail -n 1 ~/.cronjobs/iplog.csv | grep -q "ipcur"; then { printf '%s;' "(date "+%Y-%m-%d;%H:%M")"; curl -s ipinfo.io/json | jq -r '.ip + ";" + .hostname + ";" + .city + ";" + .region + ";" + .country... # The Power of Opus Compression When you like to listen to a lot of Podcasts, lectures or audio books for instance, and you want to carry with you as much of it as you can then the opus audio codec is something you might be interested in. I rarely use this term but here it can be applied: The results blew my mind. It's astonishing how much audio you can pack on a mobile device with severe capacity limits. I just converted this: 162 Files mp3, 44100 Hz, mono, s16p, 129 kb/s Total Length: 6d 14h 47min 49 Total Size: 9.05 GB... # MAC Address Spoofing on OS X/macOS This can be useful when travelling. ## Function You can put this in your .zshrc/.bashrc/etc. spoof () { CRED='\033[0;31m' CBLUE='\033[0;34m' getmac () { ifconfig "1" | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' } macorig=(networksetup -getmacaddress "1" | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}') macprev=(getmac "1") macrand=(openssl rand -hex 6 | sed 's/\(..$$/\1:/g; s/.\$//')
sudo /System/Library/PrivateFrameworks/Apple80211...

# Execute Only If Device is Attached

Have you ever been in the situation where you needed to open an application but you only want to open this particular application if a specific device is attached? For instance, when there is a symbolic link to a huge dependent library on an external drive. Or the audio interface needs to be attached before opening the DAW.

Executing such applications without meeting these requirements can mess up your settings and you may have to manually readjust preferences, paths, do cleanups, etc. Eventually...

# Rouge Syntax Highlighting

The following examples demonstrate Rouge's syntax highlighting for many different programming languages. Rouge is developed by Jeanine Adkisson. It is is a very good syntax highlighter which operates remarkably precise.

Rouge aims for the highest quality lexing in all its supported languages, even with strange features and odd corner cases.

That's right, I can confirm that rouge rather doesn't highlight at all before highlighting things wrong, which I see all the time happening with Pygments

# kramdown Syntax

This is version 1.14.0 of the syntax documentation.

The kramdown syntax is based on the Markdown syntax and has been enhanced with features that are
found in other Markdown implementations like Maruku, PHP Markdown Extra and Pandoc. However,
it strives to provide a strict syntax with definite rules and therefore isn't completely compatible
with Markdown. Nonetheless, most Markdown documents should work fine when parsed with kramdown. All
places where the kramdown syntax differs from the Markdown syntax are highlighted.

Following is the complete syntax definition for all elements kramdown supports. Together with the
documentation on the available converters, it is clearly specified what you will get when a kramdown
document is converted.

# Hello world - English

## Poe

Once upon a midnight dreary, while I pondered, weak and weary. Over many a quaint and curious volume of forgotten lore. While I nodded, nearly napping, suddenly there came a tapping. As of some one gently rapping, rapping at my chamber door. 'Tis some visiter, I muttered, tapping at my chamber door. Only this, and nothing more. Ah, distinctly I remember it was in the bleak December. And each separate dying ember wrought its ghost upon the floor. Eagerly I wished the morrow;—vainly I had sought...