Skip to content

Instantly share code, notes, and snippets.

View derlin's full-sized avatar

Lucy Linder derlin

View GitHub Profile
@derlin
derlin / 50-marblemouse.conf
Created February 24, 2017 18:58
xorg configuration for my Logitech Marblemouse (left-handed)
Section "InputClass"
Identifier "Marble Mouse"
MatchProduct "Logitech USB Trackball"
MatchIsPointer "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "SendCoreEvents" "true"
# Physical buttons come from the mouse as:
# Big: 1 3
@derlin
derlin / bootstrap4.tooltip-colors.css
Created December 21, 2016 12:41
bootstrap 4 tips
/* change bootstrap 4 tooltip colors, including the arrow ! */
.tooltip-inner {
background-color: #555;
}
/* tooltip top arrow */
.tooltip.bs-tether-element-attached-bottom .tooltip-inner::before, .tooltip.tooltip-top .tooltip-inner::before {
border-top-color: #555;
}
/* tooltip bottom arrow */
@derlin
derlin / Polynomial.java
Created November 29, 2016 09:13
a polynomial class for java implementing the basic operations +, -, /, *, compose and integrate.
// see http://introcs.cs.princeton.edu/java/92symbolic/Polynomial.java.html
public class Polynomial{
private int[] coef; // coefficients
private int deg; // degree of polynomial (0 for the zero polynomial)
// a * x^b
public Polynomial( int a, int b ){
coef = new int[ b + 1 ];
@derlin
derlin / keras_drawModel.py
Last active November 22, 2016 17:48
ipython: machine learning snippets
from IPython.display import SVG
from keras.utils.visualize_util import model_to_dot
SVG(model_to_dot(model, show_shapes=True).create(prog='dot', format='svg'))
# and to save it directly to a file
from keras.utils.visualize_util import plot
plot(model, show_shapes=True, to_file='/tmp/model.png')
@derlin
derlin / trackball.sh
Created November 21, 2016 10:56
Logitech USB Trackball - Ubuntu Gnome 16.04
# left and right click reversed, scroll with small right button, middle click with small right button, go back with small left button
# xinput buttons: left-click middle-click right-click wheel-up wheel-down -wheel-left wheel-right thumb1 thumb-2 extbt7 extbt8
xinput set-button-map "Logitech USB Trackball" 3 9 1 4 5 6 7 8 2 # left-handed
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation Button" 8 9 # wheel on small button right
xinput set-int-prop "Logitech USB Trackball" "Evdev Wheel Emulation" 8 8
@derlin
derlin / UnmarshalTest.java
Last active November 16, 2016 11:54
Unmarshal json string and json file using java EclipseLink / MOXy provider (glassfish 4.0.1 and JUnit4)
import java.io.InputStream;
import java.io.StringReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import (
"io/ioutil"
"encoding/json"
)
struct Something {
i int `json:"i"`
s string `json:"name"`
}
@derlin
derlin / latex_lstlistings-conf.tex
Created September 24, 2016 07:28
Configure the latex lstlistings package for extended char support (as well as automatic wrapping and monofont)
%% Use this configuration of lstlistings to support extended characters (i.e. acctents) and automatic line wrapping.
\usepackage{listings}
\usepackage{listingsutf8}
\usepackage{inconsolata} % nicer font
\lstset{basicstyle=\footnotesize\ttfamily,breaklines=true} % set default font and line breaks
\lstset{% support extended characters
inputencoding=utf8,
@derlin
derlin / pandoc_md2pdf_header
Last active February 22, 2018 17:33
Header to use for generating PDF from a markdown file (pandoc file.md -o file.pdf).
---
title: <TITLE>
author: Lucy Linder
date: <DATE>
toc: false
mainfont: palatino
geometry: left=3.5cm, right=3.5cm, top=4cm, bottom=4cm
colorlinks: true
smart: true
@derlin
derlin / golang_ToUTF8.go
Created August 16, 2016 09:22
Properly decode an UTF-8 string in golang.
func ToUtf8(to_decode string) string {
to_decode_buf := []byte(to_decode)
buf := make([]rune, len(to_decode_buf))
for i, b := range to_decode_buf {
buf[i] = rune(b)
}
return string(buf)
}