Skip to content

Instantly share code, notes, and snippets.

View weibeld's full-sized avatar

Daniel Weibel weibeld

View GitHub Profile
@weibeld
weibeld / getopt-std.pl
Last active October 30, 2022 08:24
Reference example for using the Getopt::Std Perl module
use strict;
use warnings;
use feature qw(say);
use Getopt::Std;
# If set to true, exit script after processing --help or --version flags
$Getopt::Std::STANDARD_HELP_VERSION = 1;
our $VERSION = "0.1";
#------------------------------------------------------------------------------#
@weibeld
weibeld / screen_size.r
Created October 17, 2017 19:24
Calculate the physical size of an HTML element on the screen of a specific device
# Calculate the size of an HTML element, whose size is specified with CSS, on
# the screen of a specific device (laptop, tablet, phone, ...).
#
# Where to get the needed information?
# - ppi: https://www.gsmarena.com/ or http://dpi.lv/
# - dpr: http://devicepixelratio.com/
# - linres: https://www.gsmarena.com/
# - viewport: default viewport width for mobile only, first line of:
# http://whatsmy.browsersize.com/
#
@weibeld
weibeld / my_alphorder.bst
Last active October 29, 2017 11:58
Custom BibTeX bibliography style with entries sorted in alphabetical order
% Begin of manually added comments
%------------------------------------------------------------------------------%
%
% The main characteristics of this bib style are:
% - Ordering of references in ALPHABETICAL order
% - Author names: initials + surname (e.g. J. F. Smith)
% - Maximum three authors (missing names replaced by et al.)
% - Date as month + year
% - Titles (and punctuation) in double quotes
% - Don't change capitalisation of titles
@weibeld
weibeld / my_citorder.bst
Last active October 29, 2017 11:58
Custom BibTeX bibliography style with entries sorted in order of citation
% Begin of manually added comments
%------------------------------------------------------------------------------%
%
% The main characteristics of this bib style are:
% - Ordering of references in CITATION order
% - Author names: initials + surname (e.g. J. F. Smith)
% - Maximum three authors (missing names replaced by et al.)
% - Date as month + year
% - Titles (and punctuation) in double quotes
% - Don't change capitalisation of titles
@weibeld
weibeld / note.cls
Last active October 29, 2017 15:00
Simple LaTeX class for short uncomplicated notes
% LaTeX class for simple short (or long) notes.
%
% Usage: place .cls file in same directory as .tex file and reference class
% in .tex file with: \documentclass{note}
%
% Daniel Weibel <danielmweibel@gmail.com> 7 May 2016
%------------------------------------------------------------------------------%
\LoadClass[a4paper]{article}
@weibeld
weibeld / letter.tex
Last active October 29, 2017 16:16
Writing a formal letter with LaTeX and the newlfm class
% Usage: pdflatex letter.tex
\documentclass[
11pt,
stdletter,
orderfromtodate,
sigleft,
a4paper
]{newlfm}
\usepackage{kpfonts}
@weibeld
weibeld / resize-images.sh
Created October 31, 2017 22:00
Bash script for resizing all the images in a directory with ImageMagick
#!/usr/bin/env bash
#
# Resize all the images in a specified folder with ImageMagick. Put the
# resized images in another specified folder.
#
# Of course, this script is an overkill. Just typing the loop on the command
# line would be enough...
#
# Daniel Weibel <danielmweibel@gmail.com>, 27 Dec. 2014
#------------------------------------------------------------------------------#
@weibeld
weibeld / graphviz.dot
Last active October 31, 2017 22:27
A small Graphviz "Hello World" program
// A small Graphviz "Hello World" program
//
// Usage:
//
// dot -Tpdf graphviz.dot >out.pdf
//
// See all supported output formats with:
//
// dot -Txxx
//
@weibeld
weibeld / cheatsheet.r
Last active November 1, 2017 10:41
A small R cheatsheet written directly as an R file
# Vectors (all elts. same type)
teams <- c("PHI","NYM","FLA","ATL","WSN")
w <- c(92, 89, 94, 72, 59)
l <- c(70, 73, 77, 90, 102)
# Lists (elts. can have different types)
list <- list(teams=teams, wins=w, losses=l)
# Data frame (list of equally long vectors)
df <- data.frame(teams=teams, wins=w, losses=l)
@weibeld
weibeld / A.java
Created January 13, 2018 00:31
Class for JDB tutorial article on http://weibeld.net/java/debugging-with-jdb.html
public class A {
private int x;
private int y;
public A(int a, int b) {
x = a;
y = b;
}
public static void main(String[] args) {