Skip to content

Instantly share code, notes, and snippets.

Avatar

Juan M. Bello-Rivas jmbr

View GitHub Profile
@jmbr
jmbr / fig-example.gp
Created Sep 19, 2020
Gnuplot figure rendered in LaTeX with proper fonts and sizes
View fig-example.gp
reset
load '~/gnuplot-colorbrewer/qualitative/Set2.plt' # Optional
set terminal push
set terminal epslatex size 3.22in, 2.255in
set output "fig-example.tex"
unset key
set border 3
@jmbr
jmbr / .stumpwmrc.lisp
Last active Aug 8, 2020
My StumpWM configuration file
View .stumpwmrc.lisp
;;; StumpWM initialization file.
(ql:quickload "swank")
(in-package :stumpwm)
(setf *window-border-style* :none
*resize-hides-windows* nil)
;;; Redirect output to ~/.stumpwm.d/stumpwm.log
@jmbr
jmbr / build-mpisbcl.sh
Created Jun 15, 2019
Create an MPI-enabled SBCL executable
View build-mpisbcl.sh
#!/bin/sh
sbcl --eval "(ql:quickload '(:swank :cl-mpi))" \
--eval "(defun toplevel () \
(push #'mpi:mpi-finalize *exit-hooks*) \
(mpi:mpi-init) \
(let ((port (+ swank::default-server-port (mpi:mpi-comm-rank)))) \
(swank:create-server :port port :dont-close t)) \
(sb-impl::toplevel-init))" \
--eval "(save-lisp-and-die \"mpisbcl\" :executable t :toplevel #'toplevel)"
View unrolled.s
.text
.align 4,0x90
.globl __Z21matrix_vector_productPKdPd
__Z21matrix_vector_productPKdPd:
LFB18:
vmovsd 8(%rdi), %xmm2
vmovsd (%rdi), %xmm1
vmulsd %xmm2, %xmm2, %xmm3
vmovsd 16(%rdi), %xmm0
vmovsd 32(%rdi), %xmm6
View unrolled.s
.text
.align 4,0x90
.globl __Z21matrix_vector_productPKdPd
__Z21matrix_vector_productPKdPd:
LFB18:
movsd (%rdi), %xmm0
movsd 8(%rdi), %xmm4
movapd %xmm0, %xmm5
movsd 16(%rdi), %xmm3
mulsd %xmm0, %xmm5
@jmbr
jmbr / gnome-flashback-stumpwm
Last active May 22, 2020
StumpWM with Gnome Flashback: all the amenities of Gnome plus the slick features of StumpWM.
View gnome-flashback-stumpwm
This file goes in /usr/lib/gnome-flashback/
#! /bin/sh
exec gnome-session --session=gnome-flashback-stumpwm --disable-acceleration-check "$@"
@jmbr
jmbr / test-cholmod.cpp
Last active Aug 29, 2015
Simple example of how to use SuiteSparse's SPQR by creating a matrix of triplets.
View test-cholmod.cpp
#include <cstdlib>
#include <iostream>
#include <SuiteSparseQR.hpp>
int main(int argc, char* argv[]) {
cholmod_common common;
cholmod_sparse *A;
cholmod_dense *x, *b, *residual;
View poor-mans-spy.cpp
/*
* Example: spy("foobar.ppm", A);
*/
int spy(std::string const& ppmfile, arma::mat const& M) {
ofstream ofs(ppmfile);
if (!ofs.is_open())
return -1;
ofs << "P3\n" << M.n_rows << " " << M.n_cols << "\n1\n";
@jmbr
jmbr / double2.h
Created Mar 29, 2014
Simple example of the RATTLE algorithm
View double2.h
#ifndef DOUBLE2_H
#define DOUBLE2_H
#include <cmath>
#include <ostream>
#include <initializer_list>
struct double2 {
union {
@jmbr
jmbr / abort_unless.h
Created Aug 30, 2013
Unlike the assert() macro, abort_unless() is not disabled by defining the preprocessor macro NDEBUG.
View abort_unless.h
#define abort_unless(expr) do { \
if (!(expr)) { \
fprintf(stderr, "%s:%u (%s): Assertion `%s' failed.\n", \
__FILE__, __LINE__, __func__, __STRING(expr)); \
fflush(stderr); \
abort(); \
} \
} while (0)