Posts with the category Useful Hints and Scripts

USB Capturing on Windows

Capturing or "sniffing" USB packets on Windows is quite easy, if you know how. All you need is Wireshark and the packet capture driver usbpcap. Here are the steps to get you going:

Install Open Source USB Packet capture for Windows.

Start an admin command prompt cmd.exe.

Run USBPcapCMD.exe to get a...

Read on

Fixing time offsets in iCalendar / .ics files

Description of the Problem

Wanting to add a iCalendar (.ics) file to your calendar can become a nightmare if the times are incorrectly stated for a different time zones. I recently encountered this problem with a timetable calendar file of a conference. It contained 160 calendar events, all stated in an...

Read on

Read and Write Google Spreadsheets with Python

Using gspread:

import gspread

# Login with your Google account
gc = gspread.authorize(OAuth2Credentials)
# OAuth2Credentials must be an object with a valid access_token attribute,
# such as one created with the oauth2client library:
# http://gspread.readthedocs.org/en/latest/oauth2.html

# Open a worksheet...

Read on

Enhancing and Enlarging the Bash History

Commands you enter on the Linux command line are valuable. They are part of your computer knowledge, you should remember them. If you don't, [Ctrl]-[r] will come to your rescue to search your Bash history for commands you entered in the past. But your Bash is forgetful by default. Only the very...

Read on

HDD Spindown on Arch Linux

From hdparm's man page on the CLI parameter -S:

Put the drive into idle (low-power) mode, and also set the standby (spindown) timeout for the drive. This timeout value is used by the drive to determine how long to wait (with no disk activity) before turning off the spindle motor to...

Read on

Connecting to Samba shares on Linux / One-way Sync

Using Samba (or SMB) shares on Linux is not difficult but you should know some tricks. First of all, you can use smbclient to probe your Samba-Server and try to connect to it. You can then mount an SMB-share locally.
In addition, I wrote a tool to synchronize a local directory with...

Read on

Generating Sound with Python

With Python Standard Library Methods

http://www.swharden.com/blog/2011-07-08-create-mono-and-stereo-wave-files-with-python/

from struct import pack
from math import sin, pi
import wave
import random

RATE=44100

## GENERATE MONO FILE ##
wv = wave.open('test_mono.wav', 

Read on

Changing the Framerate / FPS of an x264 .mp4 movie file without re-encoding

Alain Kelder mentioned this command employing mencoder in his blog post (see resources section):

MOVIE=your-movie.mp4
mencoder -fps 60 -nosound -ovc copy $MOVIE -o $(basename -s .mp4 $MOVIE)_60p_no-re-enc.mp4

Alternatives

Or use MP4Box if it's available for your platform:

# http://askubuntu.com/a/370826/6326
MP4Box -add source.mp4#video -raw 1 -new test
# Then save it as an...

Read on

Druck-Vorlage "Arbeitsblatt für die Tagesplanung"

Kann direkt aus dem Browser gedruckt werden (bei 100%):

"Arbeitsblatt für die Tagesplanung"

(Nicht vergessen, beim Drucken einzustellen, dass keine URL, Datum etc. auf den Ausdruck kommen soll.)

Referenzen

Einige gedankliche Anstöße für die Art, das Blatt in HTML und CSS umzusetzen, habe ich aus dieser Vorlage für eine Rechnungserstellung in HTML entnommen:...

Read on

Using ffmpeg to cut and crop a movie file

Here are the commands to issue in order to crop and/or cut a movie file with ffmpeg:

# cutting:
ffmpeg -i [input_file] -qscale 0 -ss [start_seconds] -t [duration_seconds] [output_file]
# so for example:
ffmpeg -i BSX234.avi -qscale 0 -ss 

Read on

Creating a Video from JPEGs and vice versa

Creating a video from JPEGs

I wrote a Bash script for this purpose:

It first renames the images from something like IMG_9999.JPG, IMG_10000, ... to IMG_00001.JPG, IMG_00002.JPG. Then it reduces the image resolution down to FullHD (1920x1080). The last and most important step: Create a video from the images.

Alternative Approaches

With avconv from...

Read on

Cleaning leftover RAW images after selecting images based on JPEGs

You probably know this problem, if you own a DSLR yourself. You take a lot of images in combined RAW+JPEG mode, then trash bad shots by checking the JPEGs on your computer. In the end, the RAW images (*.CR2 for my Canon EOS DSLR) are left over in the same...

Read on

Rotating Videos on the Command Line

Rotating videos is a task that's not that uncommon if you're filming with your camera in upright position. You can easily do this with ffmpeg:

ffmpeg -i in.mov -vf "transpose=1" out.mov

The command line tool ffmpeg is available for all major operating systems (I'm using it on Mac OS...

Read on

Installing `pip` on Windows

I found this solution on StackOverflow which worked for me on Windows 7:

  • Install Python (currently I'd use Python 2.7).
  • Add C:\Python27\Scripts to your %PATH% environment variable in order to be able to use Python and the the programs without naming the full path.
    Read more about this here
  • Install...

Read on

Add a Directory to your %PATH% in Windows as an Underprivileged User

To temporarily add C:\Python34\Scripts to your %PATH% in a command line prompt in Windows, run

set PATH=C:\Python34\Scripts;%PATH%

Resources

...

Read on

Elegant Way to Display Bytes as Hex Values in Python

Elegant code to print a hex string in python:

toHex = lambda x: "".join("{:02X}".format(ord(c)) for c in x)
print(toHex(b'\x03\xac23\n

Read on

New Focus Picomotor Ethernet Controller 8752 – TCP/IP Control

We use the modules 8752 and 8753.

List of commands

Common Commands

Syntax Command Manual Page
AIN <device> <channel> Read/Display Analog Input 61
DEF Load Default Parameters 62
DIAG <driver> Display Diagnostics Byte from Device 62
IN <device> <channel> Query State of Digital Inputs 89
LOCK Lock Out Other Input Devices 63
MAP <joystick-device>=<driver> Set/Display Device-to-Joystick Mappings 64
OUT <device> <channel>=<value> Set Digital Output 65
SAV Save Parameters 65
UNLOCK Unlock Other Input Devices 66
VER Query Firmware Version 66

Picomotor Control Commands

Read on

Convert Wikidot style syntax to Markdown style syntax

I wrote a converter for Wikidot syntax that outputs Markdown syntax. You can use it to move from Wikidot.com to any Markdown based wiki / blog / note collection.

I set up an online converter that you can use to convert your Wikidot syntax files to Markdown.

The converter itself...

Read on

Scanning A Leaflet And Automizing The Page Splitting And Renumbering

What you have to do:

  1. Remove the staples of your leaflet.
  2. Create a new folder for your images to scan.
  3. Scan the batch of leaflet pages as PNG image files.
  4. First scan the outer pages starting with the cover.
  5. Then scan the inner pages starting with the cover.
  6. Run the script convert.sh (see above) in the...

Read on

Automatic Line Breaks With vim

First set the textwidth:

:set textwidth=76

Reformatting

If you want to reformat a block of text, format it and press gq. For example to format the following 4 lines from the current cursor position, press v4jgq (v4j to enter markup mode and mark the following 4 lines).

References

...

Read on

MS-DOS Startup Disk on USB Stick

This worked great: http://files.extremeoverclocking.com/file.php?f=197 (SP27608.exe and win98boot.zip)

With the thus created USB startup MS DOS stick, I was able to flash the bios on an older netbook (no optical device / no Floppy obviously).

...

Read on

Install git on Scientific Linux SL 5.4

If you want to install the latest version of git (from source), run:

yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel
cd /usr/local/src
wget http://git-core.googlecode.com/files/git-1.7.9.2.tar.gz
tar xzvf git-1.7.9.2.tar.gz
cd git-1.7.9.2
make prefix=/usr/local all
make prefix=/usr/local install

resources

...

Read on

Monitor Your Room Temperature – With An AVR-NET-IO

I was using an AVR-NET-IO with the Ethersex firmware to log temperatures. I used an NTC and measured the the voltage drop across to get the temperature. The logging was done with (a previous version of) this script.

Real Time Plotting

This can be done with plotTemperaturesRealtime.py.

Analysis Using R

With...

Read on

Philips Streamium MC-i200

Description of the PC-Link protocol (this is the network protocol used by the MC-i200 to share music across the network): http://www.siteswap.org/streamium/protocol.html. I made a backup and published it here.

streamiumd - a great pearl software by David Witt and Nathan Peterson

streamiumd is a streaming software that can be...

Read on