Programming language cook book

From Review or Discard at Will
Revision as of 18:36, 20 January 2018 by Jeffa (talk | contribs) (Apache: add MediaWiki Short URLs)
Jump to: navigation, search

Mostly just for me to remember stuff

I might use a command once, then not again for years. Hopefully I can jog my memory quickly here.


I wanted a json utc datetime for a MQTT payload. Found the arrow module that is much like moment.js for javascript.

import arrow
print (arrow.get(arrow.utcnow()).for_json()

results in: "2015-08-27T15:03:07.427351+00:00" I'd like to trim it further and replace the +00:00 with Z. ??? and less precision on the seconds.

Documentation for ISO 8601


comment a block

What's a quick way to comment/uncomment lines in Vim? (Stack overflow)

ctl v (at start of block)
down arrow (to end of block)
shift I, #
: s/^/# <- more likely

global search and replace



Redirect site root to wiki

This works to redirect to www.somedomain.tld from www.somedomain.tld/w - basically to point the root to your wiki as home / first page.

<VirtualHost *:80>
     RewriteEngine on
     RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

MediaWiki Short URLs

<VirtualHost *:443>
        DocumentRoot /var/www/
        CustomLog       /var/log/httpd/ combined
        ErrorLog        /var/log/httpd/
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/
        SSLCertificateKeyFile /etc/letsencrypt/live/
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateChainFile /etc/letsencrypt/live/

        RewriteEngine on
        RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
        alias /wiki /var/www/
        # Redirect / to Main Page
        RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]


Display unformated like code snippets

<source lang="text"> code snippet </source>

My Simple Template

{{ blockquote| text here }}

Fedora fc.22

I opened up node.js on port 3000 with this command.

firewall-cmd --permanent --add-port=3000/tcp
# be sure to reload
 firewall-cmd --reload
# tail a log with colored warnings
#> tail -f /var/log/maillog|egrep --ignore-case  --line-buffered --color=auto 'reject|ERROR|WARN|$'


I wanted to create a .zip file for my FDDSE project from the command line. Perhaps in a batch file.

7z a -tzip FDDSE

VS 2015 IISExpress

netsh http show urlacl
netsh http add urlacl url=http://localhost:60262/ user=everyone
netsh http delete urlacl url=http://*:60262/
I 'ended' Microsoft.VsHub.Server.HttpHostx64.exe with TaskManager
// punch a hole in the firewall
// oopps just noticed I'm running public profile at home on nat. Another toDo
C:\Users\jeffa>netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=60262 profile=private remoteip=localsubnet action=allow

C:\Users\jeffa>netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=60262 profile=public remoteip=localsubnet action=allow

CentOS 7

Nifty resources

yum etc...

  • yum list installed
  • repoquery --list php56u
  • yum search all php-imap
  • yum install php56u-imap
  • rpm -qi postfix # show currently installed info


  • bconsole
    • status client

smtp etc...

postfix flush
postmap -q  mysql:/
dovecot -n ; display configuration / check configuration syntax
echo `hostname` `cat /etc/*elease*` "this is some blah blah testing body text" | mail -s "Testing 1 2 3" somebody@somewhere.tld


find ./ -exec ls -l {} + | less
sed -i 's/findstring/replacestring/g' *