Skip to content

Instantly share code, notes, and snippets.

View csebille's full-sized avatar

Christophe SEBILLE csebille

View GitHub Profile
function ip_hash() {
# Get a file
FILE=$(ls *_flux_audience.txt)
TEMP=$(mktemp -d)
ORIGINAL_FILE_COPY=$(mktemp -p ${TEMP} ${FILE}_original_XXXXXXXXXXXXX)
# Save the original file, just in case
cp ./${FILE} ${ORIGINAL_FILE_COPY}
#Remove header and extract relevant data
let R=$(wc -l ${FILE} |awk '{print $1}')-1
tail -${R} ${FILE} |cut -d '|' -f 12 |sort -u > $TEMP/ips
@csebille
csebille / desktop_group_handler.sh
Last active September 29, 2016 08:30
when called from a .desktop file, show a list with the programs and execute it. This file must be placed into ~/.local.share/applications folder
#!/bin/bash
group_name=$1
script_location=`dirname $0`
script_name=`basename $0`
COMMANDS=$(grep Exec ${script_location}/group-${group_name}.desktop |grep -v ${script_name}| sed -e 's/Exec\=/FALSE /g ' |xargs)
CHOICE=$(zenity --list --text "Which ?" --radiolist --column "Pick" --column "opinion" ${COMMANDS})
If your Java process is running on Linux behind a firewall and you want to start JConsole / Java VisualVM / Java Mission Control on Windows on your local machine to connect it to the JMX Port of your Java process.
You need access to your linux machine via SSH login. All Communication will be tunneled over the SSH connection.
TIP: This Solution works no matter if there is a firewall or not.
Disadvantage: Everytime you restart your java process, you will need to do all steps from 4 - 9 again.
1. You need the putty-suite for your Windows machine from here:
@csebille
csebille / gist:89cff79b4647e1deca63
Last active November 3, 2015 09:36
[bash] My aliases
# Override cd comamnd to print current git branch in the prompt
cd () {
builtin cd $1
current_git_branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')
PS1="${debian_chroot:+($debian_chroot)}\[\033[01;34m\]\u\[\033[00m\]:\w \[\033[01;32m\]${current_git_branch}\[\033[00m\]> "
}
alias rtl='ls -rtl'
alias gds='gsutil ls -l '
@csebille
csebille / gist:1a88fb6f687bb726ccd8
Created April 13, 2015 10:57
[bash] Fetch data with a moving window (reads file by bunchs of n lines)
export X=$(wc -l file_to_copy.txt | cut -d ' ' -f 1); export X_INIT=${X}; export line_count=15;
let nb_lines=$((X_INIT - X)); tail -n +${nb_lines} file_to_copy.txt | head -${line_count}; let X=$((X - line_count - 1))
@csebille
csebille / CsvResultSet.java
Last active August 29, 2015 14:16
ResulSet implementation backed by an Iterator of CSVRecords
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import java.io.*;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
import java.util.Map;