Skip to content

Instantly share code, notes, and snippets.

View cGuille's full-sized avatar

Guillaume Charmetant cGuille

View GitHub Profile
@cGuille
cGuille / .todorc
Last active December 16, 2015 23:58
Bash todolist
#!/usr/bin/env bash
# Author: Guillaume Charmetant <[email protected]>
# Twitter: @cGuille
# GitHub: cGuille
# Installation instructions:
# - Put this file in your home directory;
# - Allow its execution (chmod +x .todorc);
# - Add the following lines WITHOUT THE '#' AT THE BEGINING OF LINES to the end of the file '~/.bashrc':
@cGuille
cGuille / kde-dropbox-install.bash
Last active December 22, 2015 14:18
Install the Dropbox client so it runs at start up on KDE
#!/usr/bin/env bash
# Install the Dropbox client so it runs at start up on KDE:
# Set up the destination folder of the Dropbox client (default: your home directory):
INSTALLATION_FOLDER=$HOME
# Choose your platform, 64 or 32 bits (default to 64):
PLATFORM=lnx.x86_64 # 64 bits
#PLATFORM=lnx.x86 # 32 bits
@cGuille
cGuille / string-escaper.rb
Created March 10, 2014 21:49
StringEscaper: a Ruby class designed to escape literal strings
#!/usr/bin/env ruby
BACKSLASH = '\\'
class StringEscaper
def initialize chars_to_escape, escaper = BACKSLASH
# The escaper char must be escaped as well:
chars_to_escape.push(escaper) unless chars_to_escape.include?(escaper)
# We escape backslashes as they are the regex escape character:
regex_content = chars_to_escape.join('|').gsub! '\\', '\\\\\\'
@cGuille
cGuille / bidir.bash
Last active August 29, 2015 14:10
This bash script runs the two commands passed as arguments, mutually redirecting their standard IO to each other.
#!/usr/bin/env bash
USAGE="USAGE: ${0} first-program second-program [-v|--verbose]"
if [[ $# != 2 && $# != 3 ]]; then
echo "${USAGE}" 1>&2
exit 100
fi
FIRST_PROGRAM="${1}"
SECOND_PROGRAM="${2}"
@cGuille
cGuille / lsxmltree
Created July 7, 2015 16:05
Print the hierarchy of an XML document.
#!/usr/bin/env node
/*
Author: @cGuille <[email protected]>
Usage: node lsxmltree <xml file path>
The MIT License (MIT)
Copyright (c) 2015 Guillaume Charmetant
@cGuille
cGuille / gotty-Dockerfile
Last active August 29, 2015 14:27
Dockerfile to run GoTTY commands inside a Docker container. Details about GoTTY here: https://github.com/yudai/gotty
FROM debian:8.1
MAINTAINER @cGuille <[email protected]>
RUN apt-get update && apt-get -y dist-upgrade
RUN apt-get install -y golang git
ENV GOPATH /usr/go
RUN mkdir $GOPATH
ENV PATH $GOPATH/bin:$PATH
@cGuille
cGuille / ssha_passwd.bash
Created October 29, 2015 16:25
A ssha_passwd bash function you can use to generate passwords hashed with the salted SHA method. You can use the result in an nginx htpasswd file.
function ssha_passwd() {
local clear_pass
read -sp 'Password: ' clear_pass
local salt="$(openssl rand -base64 3)"
local ssha_pass=$(printf "${clear_pass}${salt}" |openssl dgst -binary -sha1 |sed 's#$#'"${salt}"'#' |base64);
echo "{SSHA}$ssha_pass"
}
@cGuille
cGuille / post-commit
Last active May 10, 2016 11:48
Git post-commit hook to display the commit message in an enclosing sentence. The goal is to check whether the commit message wording feels right or not.
#!/usr/bin/env bash
LIGHT_GREEN='\e[1;32m'
NO_FORMAT='\e[0m'
UNDERLINE='\e[4m'
RESET_UNDERLINE='\e[24m'
COMMIT_MESSAGE="$(git show -s --format=%s HEAD)"
echo -e "${LIGHT_GREEN}When applied, this commit will ${UNDERLINE}${COMMIT_MESSAGE}${RESET_UNDERLINE}.${NO_FORMAT}"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>String concatenation</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@cGuille
cGuille / remindme
Created July 5, 2016 15:27
A bash script that schedules a desktop notification sometime later.
#!/usr/bin/env bash
# USAGE:
# remindme {WHEN} {REMINDER MESSAGE}
# - The first argument must be compliant with DATE(1) and defines when to remind you.
# - The following arguments are a message to be delivered in a desktop notification.
#
# Examples:
# remindme tomorrow Write an e-mail to John Doe
# remindme '20160705 17:25' Call Jane Doe