Posts from 2014-06

Chrome without cache

posted on 2014-06-30 14:50:41

While testing websites / webserver configurations, it can be helpful to disable the browser cache.

In Chrome this is done like this:




Then the developer console pops up.

Open the dev console settings menu (the little gearwheel on the lower right, in the dev console menu bar).


Disable Cache (while DevTools is open)

linux shell calculator

posted on 2014-06-30 13:25:39

Often a calculator is needed, fast, you are in the terminal anyway, so what to do?

Try this function:

calc () { 
    echo "scale=4;$*" | bc -l

Only downside is, you have to escape *, else the shell will use it for file expansion. No quotation marks needed.


calc 1 + 2
calc 3 - 4
calc 44 \* 88
calc 77 / 234

This should do for most cases where you need a calculator fast.

A better 'find'

posted on 2014-06-30 12:52:15

Linux's find syntax is kind of strange and rather unfriendly to type.

A helpful 'alias' (which is actually a function, not an alias) is this:

ff () {
        find . -iname "*$**"


ff <searchterm>

No quotation marks needed, case insensitive.

Apache redirect http traffic to https

posted on 2014-06-30 10:30:09

There are two approaches to this. Either use a redirect or a rewrite rule.

Rewrite, the officially recommended method

NameVirtualHost *:80
<VirtualHost *:80>
   DocumentRoot /usr/local/apache2/htdocs 
   Redirect permanent /

<VirtualHost _default_:443>
  DocumentRoot /usr/local/apache2/htdocs
  SSLEngine On
 # etc...

It's a little faster than a rewrite plus it is officially recommended. However behind a SSL offloader its said not to work, I read on stackoverflow. My guess would be this case could be fixed through the use of HTTP headers, but I currently have no setup where I can verify that without breaking things and wreaking havoc.

Rewrite, for completeness sake (and in case #1 did not work)

Use this in your vhost configuration:

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1  [R=301,L,QSA]

To redirect just specific http traffic concerning a specific folder, use a different rewrite rule:

RewriteRule ^/?name-of-your-folder/(.*) https://%{SERVER_NAME}/name-of-your-folder/$1 [R=301,L,QSA]

Wireshark: Filter packets by number / selection

posted on 2014-06-29 10:17:04

To filter wireshark packets from a certain interval, there are two approaches:

  1. Mark the frames you want to display with Ctrl-M and use display filter frame.marked == 1 (Or use 0 for that matter, if you want to hide the marked ones)
  2. Use less-than/greater-than options with frame.number as a display filter: frame.number > 14000 && frame.number < 15000 will show only the packets with id's 14k to 15k.

emacs shortcuts in xterm

posted on 2014-06-26 19:21:35

To have proper working keycodes (alt is alt key and not meta, like it is the default in xterm), do this:

$ cd ~
$ vi .Xresources

and add the following line:

xterm*metaSendsEscape: true

Hit escape key several times, in case you do not know vi/vim. :wq, Enter, done.

R grammar

posted on 2014-06-26 07:47:56

R is a statistical language, open source and fast. It's nice.

Just for the record, here are the base grammar elements for its' ggplot2 lib:

data    data values
aes     short for 'aesthetic attributes', describe how data is mapped to graphical attributes
geom    geometric object, like dot or line, which can be drawn into output
stat    statistical transformation like 'add', 'count' or classifying
scale   scales values, axes, legends
coord   describes mapping of the data values to the drawing
facet   splits data into subsets for presenting it in different plots

Apache webserver redirect to subfolder

posted on 2014-06-24 11:21:17

Put into an .htaccess which resides in your web root folder:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /name-of-subfolder-to-redirect-to/ [L,R=301]

When omitting the R=301 flag, the URL will not be rewritten in the browser's address bar.

ip commands in linux

posted on 2014-06-23 17:28:11

The currently usually used tools and which ones will succeed these:

Purpose                        | Legacy net-tools | iproute2
Address and link configuration | ifconfig         | ip addr, ip link
Routing tables                 | route            | ip route
Neighbors                      | arp              | ip neigh
VLAN                           | vconfig          | ip link
Tunnels                        | iptunnel         | ip tunnel
Multicast                      | ipmaddr          | ip maddr
Statistics                     | netstat          | ss

vim: jump to column

posted on 2014-06-22 21:52:47

To jump to a special column, i.e. the 71st, do this:

71 Ctrl-|

A good looking xterminal

posted on 2014-06-19 18:55:25

xterm in its basic form is black on white, has a less comfy font, and no blinking cursor.

To fix these complaints as well as have some other goodies, try:

uxterm -fg white -bg black -bc -j -vb -maximized -fn 9x15

-bc is for proper scrolling behaviour (so not every single line needs an update). -j is a blinking cursor. \ o / -vb is visual bell, so you don't get to hear sounds when reaching the end of a file in less.

xterm is a nice terminal choice, once you realize it is pure speed. uxterm is also provided by the xterm package, but it is also utf8 capable. To enable utf8 in xterm, use the -u8 flag.

Depending on your distribution you use, flags may be missing. On Debian I do miss the -maximized flag, for example.

Scripting in Common Lisp

posted on 2014-06-15 16:41:05

To use Common Lisp for scripts, there exist two approaches, depending on the common lisp implementation you use. The approaches for SBCL and CCL will be shown here, as these seem to be the most widely used ones.

  1. Either create an executable file just like you would for a bash script, and set to the shebang accordingly.
  2. Or create a sh script with an exec line, which in turn will call your lisp file, as a wrapper.
  3. You could as well just create a compiled executable.

on approach 1: SBCL / Steel Bank Common Lisp

The first one will work with SBCL / Steel Bank Common Lisp and some others, but not all implementations:

#!/usr/local/bin/sbcl --script

It's just the path to the executable binary, followed by the --script parameter. This line is put at the top of the executable file containing your common lisp code.

on approach 2: CCL / Clozure Common Lisp

touch run-lisp
chmod a+x run-lisp
vim run-lisp

Wrapper file content:

ccl64 --no-init --terminal-encoding utf-8 --load $1.lisp --eval '(ccl:quit)'

Save, quit.

Put the wrapper somewhere where it will be referenced via the $PATH variable, so you can call it from everywhere.

The wrapper will then be called for running the lisp file in question via run-lisp </path/to/script>/<scriptname>.<ext>.

I.e. run-lisp ./helloworld.lisp.

on approach 3: create an self-sustained executable in SBCL

;; Make an executable Lisp image.  Execute with ./lisp-image
(save-lisp-and-die #p"lisp-image" :executable t)

More on this can be found here.

Linux battery status from shell

posted on 2014-06-08 16:47:39

To get the percentage of remaining battery under Fedora 19, use:

$ cat /sys/class/power_supply/BAT0/capacity

This will however only show the accurate percentage when no power chord is attached.

If you want the accurate percentage, calculate it yourself, other files in the BAT0 folder will tell you the values to use.

Emacs tutorial commands

posted on 2014-06-08 16:44:16

Since the emacs tutorial is kind of annoying, here are all commands listed that are introduced there:

page forward                    c-v
page backward                   m-v

clear screen and redisplay text c-l

next line                       c-n
prev line                       c-p
next char                       c-f
prev char                       c-b

next word                       m-f
prev word                       m-b

start of line                   c-a
end of line c-e
start of sentence               m-a
end of sentence                 m-e

prefix-argument for repetition  c-u

cancel on current level         c-g

maximize active window          c-x 1

delete prev char                DEL
delete next char                c-d
kill prev word                  m-DEL
kill next word                  m-d

kill rest of line               c-k
kill rest of sentence           m-k

set start mark                  c-SPACE
set end mark                    c-SPACE

yank/paste                      c-y
change yanked text              m-y

undo                            c-/
undo                            c-x u
undo                            c-_

find file                       c-x c-f
save current file               c-x c-s

list buffers                    c-x c-b
change to buffer                c-x b <buffername>

save all files                  c-x s

character extend                c-x
named command extend            m-x

exit emacs                      c-x c-c
suspend shell emacs             c-z

show major mode documentation   c-h m

alter cursor position (H M L)   c-l

set column size                 c-x f <column number>

forward search                  c-s
reverse search                  c-r

horizontal split                c-x 2
scroll NEXT window              c-m-v
goto next window                c-x o

find file in other window       c-x 4 c-f <file>

create frame                    m-x make-frame
kill frame                      m-x delete-frame

cancel on all levels            ESC

help on command                 c-h c <command>
verbose help on command         c-h k <command>
help on function                c-h f <function>
apropos help                    c-h a <keyword>
read included manual            c-h i

PFSense log access

posted on 2014-06-03 14:30:08

To access the logs on a PFSense firewall, you have two options:


Status >> System Logs

Usually only the last 200 log entries are shown, but this can be set to a maximum of 2000. In the Settings tab change 'GUI Log Entries to Display'.

Shell access

  • ssh into the machine (of course SSH has to be enabled and set up)
  • cd /var/log
  • view the logs via clog <logname>

Piping the clog output into less may be a good idea ;)

tail -f?

Use clog -f <filename>. :)

grep 'or' syntax

posted on 2014-06-03 14:19:34

To search for several matches at once, try one of the following:

$ grep -e '<first_search_term>' -e '<second_search_term>' <filename>


$ egrep '<first_search_term> | <second_search_term>' <filename>

Lastly, there are the several regexp specifiers.

$ grep -E '<first_search_term> | <second_search_term>' <filename>

-E flags the search terms to be interpreted as POSIX regular expressions. There's also -P for perl-regexp's, and -F and -B. -B is the default, if omitted, you can just use:

$ grep '<first_search_term> \| <second_search_term>' <filename>

Choose wisely! ;)

Compiling git from source on debian

posted on 2014-06-02 19:58:58

Compiling git from source may not be the what first comes into your mind when using git. But when working with large repositories you should consider this, especially with the profiling option. The speed improvement I got was pretty impressive. (Ok this may also be related to the upgrade from 1.7.x to 2.0.0.)

Anyway, do this for a full, profiled (= speed optimized) build: ('$' here indicates running the command as a regular user, '#' indicates root.)

$ git clone --progress -v
$ cd git
$ make configure
$ ./configure --prefix=/usr
$ make prefix=/usr PROFILE=BUILD all
# make prefix=/usr PROFILE=BUILD install

Afterwards check git --version output if you are running the correct version and be amazed by the new speedyness.

This blog covers .csv, .htaccess, .pfx, .vmx, /etc/crypttab, /etc/network/interfaces, /etc/sudoers, /proc, 10.04, 14.04, 16.04, AS, ASA, ControlPanel, DS1054Z, GPT, HWR, Hyper-V, IPSEC, KVM, LSI, LVM, LXC, MBR, MTU, MegaCli, PHP, PKI, PS1, R, RAID, S.M.A.R.T., SNMP, SSD, SSL, TLS, TRIM, VEEAM, VMware, VServer, VirtualBox, Virtuozzo, XenServer, acpi, adaptec, algorithm, ansible, apache, apache2.4, apachebench, apple, applet, arcconf, arch, architecture, areca, arping, asa, asdm, autoconf, awk, backup, bandit, bar, bash, benchmarking, binding, bitrate, blackarmor, blockdev, blowfish, bochs, bond, bonding, booknotes, bootable, bsd, btrfs, buffer, c-states, cache, caching, ccl, centos, certificate, certtool, cgdisk, cheatsheet, chrome, chroot, cisco, clamav, cli, clp, clush, cluster, cmd, coleslaw, colorscheme, common lisp, configuration management, console, container, containers, controller, cron, cryptsetup, csync2, cu, cups, cygwin, d-states, database, date, db2, dcfldd, dcim, dd, debian, debug, debugger, debugging, decimal, desktop, df, dhclient, dhcp, diff, dig, display manager, dm-crypt, dmesg, dmidecode, dns, docker, dos, drivers, dtrace, dtrace4linux, du, dynamictracing, e2fsck, eBPF, ebook, efi, egrep, emacs, encoding, env, error, ess, esx, esxcli, esxi, ethtool, evil, expect, exportfs, factory reset, factory_reset, factoryreset, fail2ban, fakeroot, fbsd, fdisk, fedora, file, files, filesystem, find, fio, firewall, firmware, fish, flashrom, forensics, free, freebsd, freedos, fritzbox, fsck, fstrim, ftp, ftps, g-states, gentoo, ghostscript, git, git-filter-branch, gitbucket, github, gitolite, global, gnutls, gradle, grep, grml, grub, grub2, guacamole, hardware, haskell, hdd, hdparm, hellowor, hex, hexdump, history, howto, htop, htpasswd, http, httpd, https, i3, icmp, ifenslave, iftop, iis, imagemagick, imap, imaps, init, innoDB, innodb, inodes, intel, ioncube, ios, iostat, ip, iperf, iphone, ipmi, ipmitool, iproute2, ipsec, iptables, ipv6, irc, irssi, iw, iwconfig, iwlist, iwlwifi, jailbreak, jails, java, javascript, javaws, js, juniper, junit, kali, kde, kemp, kernel, keyremap, kill, kpartx, krypton, lacp, lamp, languages, ldap, ldapsearch, less, leviathan, liero, lightning, links, linux, linuxin3months, lisp, list, livedisk, lmctfy, loadbalancing, locale, log, logrotate, looback, loopback, losetup, lsblk, lsi, lsof, lsusb, lsyncd, luks, lvextend, lvm, lvm2, lvreduce, lxc, lxde, macbook, macro, magento, mailclient, mailing, mailq, make-jpkg, manpages, markdown, mbr, mdadm, megacli, micro sd, microsoft, minicom, mkfs, mktemp, mod_pagespeed, mod_proxy, modbus, modprobe, mount, mouse, movement, mpstat, multitasking, myISAM, mysql, mysql 5.7, mysql workbench, mysqlcheck, mysqldump, nagios, nas, nat, nc, netfilter, networking, nfs, nginx, nmap, nocaps, nodejs, numberingsystem, numbers, od, onyx, opcode-cache, openVZ, openlierox, openssl, openvpn, openvswitch, openwrt, oracle linux, org-mode, os, oscilloscope, overview, parallel, parameter expansion, parted, partitioning, passwd, patch, pct, pdf, performance, pfsense, php, php7, phpmyadmin, pi, pidgin, pidstat, pins, pkill, plasma, plesk, plugin, posix, postfix, postfixadmin, postgres, postgresql, poudriere, powershell, preview, profiling, prompt, proxmox, ps, puppet, pv, pveam, pvecm, pvesm, pvresize, python, python3, qemu, qemu-img, qm, qmrestore, quicklisp, quickshare, r, racktables, raid, raspberry pi, raspberrypi, raspbian, rbpi, rdp, redhat, redirect, registry, requirements, resize2fs, rewrite, rewrites, rhel, rigol, roccat, routing, rs0485, rs232, rsync, s-states, s_client, samba, sar, sata, sbcl, scite, scp, screen, scripting, seafile, seagate, security, sed, serial, serial port, setup, sftp, sg300, shell, shopware, shortcuts, showmount, signals, slattach, slip, slow-query-log, smbclient, snmpget, snmpwalk, software RAID, software raid, softwareraid, sophos, spacemacs, spam, specification, speedport, spi, sqlite, squid, ssd, ssh, ssh-add, sshd, ssl, stats, storage, strace, stronswan, su, submodules, subzone, sudo, sudoers, sup, swaks, swap, switch, switching, synaptics, synergy, sysfs, systemd, systemtap, tar, tcpdump, tcsh, tee, telnet, terminal, terminator, testdisk, testing, throughput, tmux, todo, tomcat, top, tput, trafficshaping, ttl, tuning, tunnel, tunneling, typo3, uboot, ubuntu, ubuntu 16.04, ubuntu16.04, udev, uefi, ulimit, uname, unetbootin, unit testing, upstart, uptime, usb, usbstick, utf8, utm, utm 220, ux305, vcs, vgchange, vim, vimdiff, virtualbox, virtualization, visual studio code, vlan, vmstat, vmware, vnc, vncviewer, voltage, vpn, vsphere, vzdump, w, w701, wakeonlan, wargames, web, webdav, weechat, wget, whois, wicd, wifi, windowmanager, windows, wine, wireshark, wpa, wpa_passphrase, wpa_supplicant, x11vnc, x2x, xfce, xfreerdp, xmodem, xterm, xxd, yum, zones, zsh

Unless otherwise credited all material Creative Commons License by sjas