Skip to content

Instantly share code, notes, and snippets.

Anthony Scemama scemama

Block or report user

Report or block scemama

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:514d9066de33430bad2bfa9ad5e382e5
ifort -S -O2 -xCORE-AVX2 slater_rules.irp.F90 -fcode-asm -fsource-asm -fverbose-asm -o test.s
View modify_partition.sh
#!/bin/bash
# Modifies a partition of a SLURM job
scontrol update jobid=$1 partition=$2
@scemama
scemama / reduce_pdf.sh
Created Jun 20, 2016
Reduce size of a scanned pdf file
View reduce_pdf.sh
#!/bin/bash
if [[ -z $0 ]]
then
echo $0 "<input.pdf> <output.pdf>"
exit -1
fi
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$2 $1
@scemama
scemama / eval.ml
Created Oct 26, 2015
Evaluate a string in OCaml
View eval.ml
(* http://stackoverflow.com/questions/33291754/eval-a-string-in-ocaml *)
#require "compiler-libs" (* Assuming you're using utop, if compiling then this is the package you need *)
let eval code =
let as_buf = Lexing.from_string code in
let parsed = !Toploop.parse_toplevel_phrase as_buf in
ignore (Toploop.execute_phrase true Format.std_formatter parsed)
eval "let () = print_endline \"hello\";;"
@scemama
scemama / timer.sh
Created Sep 23, 2015
Timer in the bash prompt
View timer.sh
function timer_start {
timer=${timer:-$SECONDS}
}
function timer_stop {
timer_show=$(($SECONDS - $timer))
unset timer
}
trap 'timer_start' DEBUG
View Bash_guidelines.rst

`bash set -u # The script crashes if a variable is uninitialized set -e # The script crashes if the exit code of a command is not zero `

  • Use "$@" instead of $@
  • Use quotes around filenames
  • Use mkdir -p to create a full path
  • Use ``rm || true `` to avoid a non-zero exit
  • Use traps when using temporary files:
@scemama
scemama / get_bibtex.sh
Last active Sep 20, 2015 — forked from TApplencourt/get_bibtex.sh
Gets a bibtex file from a DOI or an ISBN
View get_bibtex.sh
#!/bin/bash
str_utilisation="$0 (doi|isbn) <value>"
if [ "$#" -ne 2 ];then
echo ${str_utilisation}
exit 1
fi
if [ "$1" == "doi" ];then
@scemama
scemama / turbo.sh
Created Jun 30, 2015
Adjust turbo frequency manually
View turbo.sh
echo 1 > /sys/module/processor/parameters/ignore_ppc
for x in /sys/devices/system/cpu/cpu[0-3]/cpufreq/;do
echo 3601000 > $x/scaling_max_freq
done
@scemama
scemama / mega-dl.sh
Created Jun 8, 2015
Download file from mega.com.nz
View mega-dl.sh
#!/bin/bash
#
# Code found originally here on a post from t0n1 :
# http://hacktracking.blogspot.fr/2013/07/download-mega-files-from-command-line.html
#
url=$1
enc_file=$2.enc
out_file=$2
@scemama
scemama / cuthill_mckee.f
Created Apr 23, 2015
Reverse Cuthill-MacKee subroutine
View cuthill_mckee.f
subroutine cuthill_mckee(matrix,LDA,n,iorder)
implicit none
! Uses the Cuthill-McKee algorithm to reorder the columns and rows of the matrix
integer, intent(in) :: n,LDA
integer, intent(out) :: iorder(n)
double precision, intent(in) :: matrix(LDA,n)
integer :: i,j,k
You can’t perform that action at this time.