This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String humanReadableByteCount(long bytes, boolean si) { | |
int unit = si ? 1000 : 1024; | |
if (bytes < unit) return bytes + " B"; | |
int exp = (int) (Math.log(bytes) / Math.log(unit)); | |
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i"); | |
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo socat tcp-l:54321,reuseaddr,fork file:/dev/ttyUSB0,nonblock,waitlock=/var/run/tty0.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plain_server: | |
driver = plaintext | |
public_name = PLAIN | |
server_condition = "${if crypteq{$auth3}{${extract{1}{:}{${lookup{$auth2}lsearch{CONFDIR/passwd}{$value}{*:*}}}}}{1}{0}}" | |
server_set_id = $auth2 | |
server_prompts = : | |
.ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS | |
server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}} | |
.endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Source dirs or files to be copied | |
SRC="/list/of/dirs/space/separated /another/dir" | |
## Exclude-args, let it be empty if nothing is to be excluded | |
EXCLUDE_FROM="--exclude-from=/path/to/exclude/file" | |
## Destination host (including user if necessary, user@host) | |
DEST_HOST="[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Port to send message to | |
PORT=9999 | |
# IP address of destination machine | |
DESTIP="127.0.0.1" | |
# Use UDP | |
NETCAT_CMD="nc -w 1 -n -u $DESTIP $PORT" | |
# Use TCP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Uses libwww-perl and libcrypt-ssleay-perl | |
# | |
# A little script I made in Perl to update GratisDNS dynamic DNS (www.gratisdns.dk). | |
# | |
# Usage: | |
# ddns.pl -u username -p password -d domain -h hostname [-i IP] | |
use Switch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hardstatus on | |
hardstatus alwayslastline | |
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %y-%m-%d %c " | |
#hardstatus string "%h" | |
startup_message off | |
defscrollback 1000 | |
utf8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This is a nice little script for setting up my vhosts. | |
# I edited it to my needs from the original. Thanks to http://commandlineidiot.com | |
# | |
# ======================= | |
# Siteup Script 0.1 | |
# Written by Command Line Idiot | |
# http://commandlineidiot.com | |
# You may use, modify, and redistribute this script freely |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax on | |
set number | |
set autoindent | |
map - <c-w>w | |
set tabstop=3 | |
set encoding=utf-8 | |
setglobal fileencoding=utf-8 | |
map <F12> <Esc>:%!gpg --encrypt --armor --recipient [email protected]<CR><CR><C-l> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A short script to update all flac-files in subdirs to the best compression, with replay gain added. | |
du -h | |
export IFS=$'\n'; for dir in `find . -type d` ; do cd ${dir} ; flac --verify --best --force --replay-gain *.flac ; cd - ; done | |
du -h |