Skip to content

Instantly share code, notes, and snippets.

View fstamour's full-sized avatar

Francis St-Amour fstamour

View GitHub Profile
@fstamour
fstamour / switch-main-display.sh
Created May 8, 2014 20:29
Use Xrandr to switch main display
# Tested with:
# xrandr --version
# xrandr program version 1.4.0
# Server reports RandR version 1.4
xrandr --primary HDMI2
@fstamour
fstamour / find_git_repos.sh
Created May 21, 2014 22:05
find_git_repos.sh
find . -name ".git" | sed -re 's@\./(.*)/\.git@\1@g'
@fstamour
fstamour / win_system_privilege.txt
Last active August 29, 2015 14:01
System privilege on windows
From http://msdn.microsoft.com/en-us/library/ms684190%28VS.85%29.aspx
psexec -i -s -h %systemroot%\system32\cmd.exe
or
runas.exe /savecred /user:administrator %systemroot%\system32\cmd.exe
WhoAmI.exe
or
echo %userprofile%
@fstamour
fstamour / win_list_privilege.txt
Created May 28, 2014 15:01
Windows list user privileges
secedit /export /areas USER_RIGHTS /cfg OUTFILE.CFG
whoami /PRIV
scedit: http://technet.microsoft.com/en-us/library/bb490997.aspx
whoami: http://technet.microsoft.com/en-us/library/cc771299.aspx
Interesting:
@fstamour
fstamour / reduce-strings.lisp
Created July 11, 2014 18:29
Reduce-strings Join adjacent strings in a list, leave other values intact.
;; Took from postmodern's s-sql.lisp
(defun reduce-strings (list)
"Join adjacent strings in a list, leave other values intact."
(let ((accum ())
(span ""))
(dolist (part list)
(cond ((stringp part) (setf span (concatenate 'string span part)))
(t (when (not (string= "" span))
(push span accum)
@fstamour
fstamour / follow.sh
Created July 31, 2014 17:46
Shell snippet to cd to anything
# Note: havn't tested it yet.
follow () {
cd "$(dirname "$(readlink -f "$1")")"
}
# Example:
# follow $(which sbcl)
# follow a_symlink
# follow ~
@fstamour
fstamour / wav_to_ulaw
Created September 14, 2014 19:01
Batch conversion, WAV to ULAW
#!/bin/bash
#
# Not perfect, but does the job pretty well.
#
for file in `ls -1 *.wav`
do
outfile=`echo $file | /bin/sed 's/\(.*\)\..*/\1/'`.ulaw
echo "Converting $file to $outfile"
sox -V $file -r 8000 -c 1 -t ul $outfile
@fstamour
fstamour / set_terminal_title.sh
Created January 22, 2015 01:34
Little shell function to set the terminal's title (like the title of a gnome-terminal tabs).
# Note that sometimes, these escape sequences are in the prompt,
# resetting the title at every command.
set_terminal_title () {
echo -en "\033]0;$@\a"
}
function loadJS(src, retryP, delay) {
try {
var scriptTag = document.createElement('script');
scriptTag.type = 'text/javascript';
scriptTag.src = src;
var fail = function (event) {
console.error("Unable to load the script: '" + src + "'");
if (retryP) {
window.setTimeout(function () {
# Disclaimer, not tested yet, I did the equivalent in vim.
# curl/wget this: https://moodle.polymtl.ca/pluginfile.php/69155/mod_folder/content/0/INF4420a%20intra%20A2014_version%20AAAA0001%20avec%20solution.pdf?forcedownload=1
# Copy the text in it, from the 1st question to the last.
# Remove Q5 and Q6 because they didn't survived the Ctrl-C Ctrl-V.
# Then
# 1st regex 2nd regex 3rg regex 4th regex Buffer (not avail on all system)
sed -ir -e 's/(^[0-9]{0,2}\..*)/\n\1/g' -e 's/^[a-e]/\ [ ] \1/g' -e '/^INF/d' -e '/^Poly/d' <FILENAME> | sponge <FILENAME>
# -r on BSD (so OSX) is -E