Skip to content

Instantly share code, notes, and snippets.

View csebille's full-sized avatar

Christophe SEBILLE csebille

View GitHub Profile
@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;
@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 / 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 '
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 / 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})
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
Supprimer tous les espaces dans un fichier :
:%s/ //g
Supprimer tous les espaces en début de ligne :
:%le
Shorter keystroke than :w
nnoremap ZS :w<cr> into your .vimrc
https://swagger.io
https://swaggerhub.com
https://apihandyman.io/do-you-really-know-why-you-prefer-rest-over-rpc/
https://apihandyman.io/ -> Arnaud Lauret https://www.linkedin.com/in/arnaudlauret/
# graphQL
https://github.com/APIs-guru/graphql-apis
https://github.com/APIs-guru/graphql-voyager
https://github.com/NathanRSmith/graphql-visualizer
@csebille
csebille / Top5_LiveJournalPageRank.scala
Created April 20, 2017 15:37
[Spark] Get top 5 from LiveJournalPageRank result file
import scala.io.Source
// This file is the result of the graphx LiveJournalPageRank example
// it contains for each line an id and a rank (separated by a tab character)
val filename="/opt/spark-2.1.0-bin-hadoop2.6/examples/src/main/scala/org/apache/spark/examples/graphx/sortie_1000004_1/part-00000"
val ranks = Source.fromFile(filename).getLines().toList
// Here each line is split then reversed
// The list is then sorted and only the five top elements are printed
#############################
##
## Dynamic function call
##
#############################
if_it_exists_launch_function clean_before_${JOB_NICKNAME}
# This function calls another function, if it exists
function if_it_exists_launch_function() {