Skip to content

Instantly share code, notes, and snippets.

View rsnemmen's full-sized avatar

Rodrigo Nemmen rsnemmen

View GitHub Profile
@rsnemmen
rsnemmen / jail.local
Created May 23, 2018 21:53
fail2ban VNC rule
[vnc]
enabled = true
port = 5901
filter = vnc
logpath = /var/log/auth.log
@rsnemmen
rsnemmen / deviceQuery.c
Created April 3, 2018 16:24
Gets useful information about your NVIDIA GPU with CUDA
/*
Queries NVIDIA GPU for useful information.
Please compile with nvcc.
*/
#include <stdio.h>
int main() {
int nDevices;
@rsnemmen
rsnemmen / mdtex.sh
Created March 9, 2018 16:26
Shell script that converts a Markdown document with LaTeX math expressions to a nice PDF
#!/bin/sh
#
# Convert Markdown with LaTeX directives to a PDF file.
#
# Requirements: pandoc
#
# Run this inside your document folder:
# md2tex.sh <MARKDOWN FILE> <OUTPUT FILE>
#
# where:
@rsnemmen
rsnemmen / movie.sh
Created February 28, 2018 16:29
Creates a movie from a set of images
#!/bin/sh
#
# Creates movie file based on sequential images in the current directory.
#
# Usage: movie.sh <image extension> <fps> <output file basename>
#
# Example:
#
# $ movie.sh png 5 movie
#
@rsnemmen
rsnemmen / findPATH.py
Created February 27, 2018 14:54
Given a PATH or PYTHONPATH environment variable, find the full path of a file among different options
# Obtained from https://stackoverflow.com/a/1124851/793218
#
for p in os.environ["PYTHONPATH"].split(":"):
for r,d,f in os.walk(p):
for files in f:
if files == "filename.extension":
print(os.path.join(r,files))
@rsnemmen
rsnemmen / search_array.c
Created February 19, 2018 21:40
Given a desired number, this snippet generates a random array (0<values<1) and outputs the index of the array with value nearest the given float
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
int search(double xref, size_t length, double *x) {
@rsnemmen
rsnemmen / example.i
Created February 8, 2018 13:50
Interface file which serves as input to SWIG, SWIG tutorial
/*
example.i
"Interface file" which is the input to SWIG. Obtained
from http://www.swig.org/tutorial.html.
*/
%module example
%{
/* Put header files here or function declarations like below */
@rsnemmen
rsnemmen / example.c
Created February 8, 2018 13:46
Example C function for interfacing with SWIG
/*
File : example.c
Obtained from http://www.swig.org/tutorial.html
*/
#include <time.h>
double My_variable = 3.0;
int fact(int n) {
@rsnemmen
rsnemmen / csync.sh
Created February 5, 2018 16:28
Syncs the content of the current directory with a remote server using rsync via SSH
#!/bin/sh
#
# Syncs the content of the current directory with a remote server using rsync
# via SSH.
#
# Usage: csync.sh <user@remoteserver> <remote path where directory will be synced>
#
# Example: csync.sh nemmen@alphacrucis pluto
# check if there were command-line arguments
@rsnemmen
rsnemmen / arxiv.awk
Created September 27, 2017 18:32
Removes all comments in a LaTeX document, for a "clean" submission to a journal or arXiv
#!/usr/bin/awk -f
#
# Processes a LaTeX/TeX file for a "clean" submission to arXiv.
# Removes all comments.
#
# How to use it:
#
# $ arxiv.awk origin.tex > destination.tex
$0 !~ /^%/