Skip to content

Instantly share code, notes, and snippets.

@jotbe
jotbe / keybase.md
Created October 4, 2015 13:45
Keybase

Keybase proof

I hereby claim:

  • I am jotbe on github.
  • I am jotbe (https://keybase.io/jotbe) on keybase.
  • I have a public key whose fingerprint is 834D DECF 5CCF 7A2B 4899 AC9C 1A7F 81F3 C15E 8D48

To claim this, I am signing this object:

@jotbe
jotbe / 0xC15E8D48-fingerprint.txt
Created February 12, 2014 08:05
PGP fingerprint
834D DECF 5CCF 7A2B 4899 AC9C 1A7F 81F3 C15E 8D48
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@jotbe
jotbe / pwgen-oneliners.sh
Created May 10, 2013 13:37
simple password generator shell commands
# Generate secure passwords
tr -cd '[:print:]' < /dev/urandom | head -c 10 | xargs
# Generate simple passwords
tr -cd '[:alnum:]' < /dev/urandom | head -c 8 | xargs
@jotbe
jotbe / nlp_01.py
Created December 19, 2011 23:32
AI-Class: Optional NLP Programming Task (Part One - Rotation Cipher)
#!/bin/env python
"""
Optional NLP Programming Task - Part One (Rotation Cipher)
==========================================================
"""
__author__ = 'Jan Beilicke <dev +at+ jotbe-fx +dot+ de>'
__date__ = '2011-12-19'
if __name__ == '__main__':
@jotbe
jotbe / linear_filter.py
Created December 3, 2011 23:37
Computer Vision: Linear filter
#!/bin/env python
"""Chapter 16.21 Linear filter
We got the following matrix :math:`I` of a grayscale image from video 16.20::
255 7 3
212 240 4
218 216 230
@jotbe
jotbe / 9_15_value_iteration_3.py
Created November 13, 2011 01:31
AI-Class: 9.15 Value Iteration 3
#!/bin/env python
"""
9.15 Value Iteration 3
==============================
We got the following world::
+--+-----+-----+-----+-----+
| | 1 | 2 | 3 | 4 |
+--+-----+-----+-----+-----+
@jotbe
jotbe / w2p_archive_record.py
Created October 1, 2011 19:45
web2py: Write a record to an archive table without using forms and auth.archive
# Model:
#
#db.define_table('page',
# Field('name', unique=True),
# Field('title'),
# Field('body', 'text'),
# Field('created_on', 'datetime', default=request.now, update=request.now),
# Field('created_by', db.auth_user, default=auth.user_id),
# Field('change_note', length=200),
# format='%(title)s')
@jotbe
jotbe / w2p_dal_get_id.py
Created September 30, 2011 23:01
web2py: DAL dict with specific fields including id
>>> # Will only return the two requested fields
>>> db(db.page.name=='delft').select(db.page.name, db.page.title).first()
<Row {'name': 'delft', 'title': 'Delft'}>
>>> # Adding the primary key 'id' will return the requested fields BUT all objects and functions too
>>> db(db.page.name=='delft').select(db.page.id, db.page.name, db.page.title).first()
<Row {'comment': <gluon.dal.Set object at 0x102ca8d50>, 'name': 'delft', 'title': 'Delft', 'update_record': <function <lambda> at 0x102cbc488>, 'page_archive': <gluon.dal.Set object at 0x102ca8c90>, 'document': <gluon.dal.Set object at 0x102cba4d0>, 'id': 3, 'delete_record': <function <lambda> at 0x102cbc578>}>
>>> # Using as_dict() will only return the requested fields
>>> db(db.page.name=='delft').select(db.page.id, db.page.name, db.page.title).first().as_dict()
@jotbe
jotbe / calc_totals.awk
Created September 16, 2011 20:36
CSV: Calculate totals of specific columns using awk
# Sample usage:
# $ gawk -F, -v coli=9 -v colc=10 -f calc_totals.awk < file.csv
BEGIN{
# Separator for the output
sep = ","
# coli is the position of the imps column.
# It is passed as an arg, eg. -v coli=9
if (coli > 0) {