Skip to content

Instantly share code, notes, and snippets.

View scemama's full-sized avatar
🏠
Working from home

Anthony Scemama scemama

🏠
Working from home
View GitHub Profile
@scemama
scemama / gist:2614c4d24c172c24b3391d35aa568698
Created November 2, 2021 21:04 — forked from thomaslee/gist:1631057
Building Debian Packages
Notes from here: http://www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html
This assumes you're using autotools to build your project.
1. sudo apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder
2. We want a source folder with the pattern: <package>-<version>
$ cd ginvoke
$ git archive --format=tar --prefix=ginvoke-$(date +'%Y%m%d')/ master | tar xvf - -C ..
@scemama
scemama / bootstrap.log
Created February 15, 2021 13:22
bootstrap.log
+ [ tar ] tar xzf repo/archives/ocaml-base-compiler.4.11.1/4.11.1.tar.gz
+ [ ./configure ] ./configure -prefix /home/test/ocamlbuild-bundle/bootstrap
configure: Configuring OCaml version 4.11.1
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for ld... ld
checking how to print strings... printf
checking for gcc... gcc
@scemama
scemama / convert_to_cm-1.py
Last active April 10, 2020 16:15
Converts vibrational frequencies from atomic units to cm-1 for diatomics
#!/usr/bin/env python
"""Converts vibrational frequencies from atomic units to cm-1 for diatomics."""
import sys
from math import sqrt, pi
# Atomic masses obtained using
# import periodictable as pt
# for el in pt.elements:
# mass[el.symbol] = sorted([ (el[x].abundance,el[x].mass) for x in el.isotopes ])[-1][1]
@scemama
scemama / gist:514d9066de33430bad2bfa9ad5e382e5
Created March 15, 2017 14:48
Display Assembl with ifort
ifort -S -O2 -xCORE-AVX2 slater_rules.irp.F90 -fcode-asm -fsource-asm -fverbose-asm -o test.s
#!/bin/bash
# Modifies a partition of a SLURM job
scontrol update jobid=$1 partition=$2
@scemama
scemama / reduce_pdf.sh
Created June 20, 2016 19:54
Reduce size of a scanned pdf file
#!/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 October 26, 2015 22:40
Evaluate a string in OCaml
(* 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 September 23, 2015 17:38
Timer in the bash prompt
function timer_start {
timer=${timer:-$SECONDS}
}
function timer_stop {
timer_show=$(($SECONDS - $timer))
unset timer
}
trap 'timer_start' DEBUG

`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 November 22, 2021 18:59 — forked from TApplencourt/get_bibtex.sh
Gets a bibtex file from a DOI or an ISBN
#!/bin/bash
str_utilisation="$0 (doi|isbn) <value>"
if [ "$#" -ne 2 ];then
echo ${str_utilisation}
exit 1
fi
if [ "$1" == "doi" ];then