Skip to content

Instantly share code, notes, and snippets.

View codingtony's full-sized avatar

Tony Bussières codingtony

View GitHub Profile
@codingtony
codingtony / speedtest.sh
Created October 18, 2012 09:18
Simple script to test hard disk speed with dd
#!/bin/bash
# by TB : 2012-10-12
if [ "$USER" != "root" ]
then
echo "You must be root to execute this script (in order to instruct the kernel to drop the cache)!"
exit 1
fi
if [ -z "$1" ]
@codingtony
codingtony / fixToolTipTheme.sh
Created November 23, 2012 02:43
Script that adjust the theme in Ubuntu Unity for better tooltip visibility
#!/bin/bash
# Tooltip fix
# A script to fix themes files in Ubuntu 11.10
# to have readable tooltips in applications such
# as eclipse.
# The script edits the gtk.css, settings.ini and gtkrc files
# Author: Victor Pillac
# http://victorpillac.wordpress.com
if [ $EUID -ne 0 ]; then
@codingtony
codingtony / serialNumber.sh
Last active February 28, 2024 01:18
Bash script to print the serial number of hard disk
#!/bin/sh
# Print the serial number of your disks with this script
ls /dev/disk/by-id/ata* | awk -F- '{ if (NF==4) { print $NF} }' | while read SERIAL;
do
DEVICE=$(readlink -f /dev/disk/by-id/*$SERIAL);
echo $DEVICE" "$SERIAL;
done | sort;
@codingtony
codingtony / transferMeter.sh
Last active December 11, 2015 10:48
Little program that measure the speed in megabytes per second of a file transfer occurring in the current directory
#!/bin/bash -e
# Little program that measure the speed in MBps of a file transfer occuring in the current directory
LASTTIME=$(date +%s)
LASTSIZE=$(du -bs . 2> /dev/null | awk '{ print $1 }')
TOTALSIZE=0
TOTALTIME=0
while true
@codingtony
codingtony / addlookup.sh
Last active December 14, 2015 01:28
Little bash script to quickly add lookup and reverse lookup to dnsmasq.
#!/bin/bash -e
# USAGE :
# $0 IP NAME DOMAIN
if [ "$#" != "3" ]
then
echo "Usage:"
echo $0 IP HOSTNAME DOMAIN
@codingtony
codingtony / ChunkOutputStream.java
Last active December 21, 2017 04:37
An handy, yet simple ChunkedOutputSteam for HTTP chunked response with Netty 4.0 Useful when you have an application that writes to an OutputStream and you don't want (or cannot) rewrite it. Released under APL 2.0 Any bugs? let me know!
/************************************************************************
Copyright 2013 Tony Bussieres
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@codingtony
codingtony / ChunkedBuffer.java
Last active December 23, 2015 02:29
Trying to output 1GB of zero bytes in chunks. Seems to have a memory leak....
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.stream.ChunkedInput;
import io.netty.util.CharsetUtil;
public abstract class ChunkedBuffer implements ChunkedInput<ByteBuf> {
int offset = -1;
boolean closed = false;
protected byte[] buffer = null;
@codingtony
codingtony / BindExceptionFutureExample.java
Created September 24, 2013 21:10
Example to add a ChannelFutureListener to trap the BindException in Netty
//...
final int port=8888;
ServerBootstrap b = new ServerBootstrap();
//...
b.bind(port).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (!future.isSuccess()) {
if (future.cause() instanceof BindException) {
@codingtony
codingtony / disableScreenSaver.sh
Last active January 15, 2024 17:53
Temporary disable Screensaver (tested with KDE) by simulating fake user activity
#!/bin/bash
# credits goes to http://silviumc.wordpress.com/2011/12/05/how-to-stop-the-screen-saver-in-kde-while-watching-long-flash-clips-in-a-web-browser/
while /bin/true
do
qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity > /dev/null;
sleep 1m;
done
#!/bin/bash
WAV="$1"
if [ -z "$WAV" ]; then
echo "Usage: $0 OUTPUT.WAV" >&2
exit 1
fi
rm -f "$WAV"
# Get sink monitor:
MONITOR=$(pactl list | egrep -A2 '^(\*\*\* )?Source #' | \