Skip to content

Instantly share code, notes, and snippets.

View japborst's full-sized avatar

Jelmer Borst japborst

  • Picnic Technologies
  • Netherlands
  • X @japborst
View GitHub Profile
private static final Logger LOG = LoggerFactory.getLogger(Example.class);
private static final String FMT2 = "with-{}-{}-placeholders";
public static void main(String[] args) {
LOG.error("with-'%s'-placeholder", args);
LOG.error(FMT2, args);
}
static final class StringIsEmpty {
@BeforeTemplate
boolean equalsEmptyString(String string) {
return string.equals("");
}
@BeforeTemplate
boolean lengthEquals0(String string) {
return string.length() == 0;
}
public static void main(String[] args) {
if (args.length > 0 && args[0].isEmpty()) {
new IllegalArgumentException( );
}
// ... rest of the main code ...
}
@japborst
japborst / download_mendeley_bibtex.py
Created February 10, 2017 09:29
Python function that downloads all Mendeley entries as bibtex
import requests
from mendeley import Mendeley
def get_mendeley_bibtex(login, api_id, api_secret):
# login: tuple containing username and password
# api_id: Mendeley API id
# api_secret: Mendeley API secret
# Temporarily disable InsecurePlatformWarnings from urllib3
@japborst
japborst / InsertCrossReference.vb
Created January 16, 2017 10:39
Simple cross-reference macros for auto selecting appropriate boxes
' Because inserting cross-references is terrible in Word, these macros
' makes life a little easier by selecting the appropriate drop-down boxes
' Open issue: NumLock may be disabled
Sub InsertFigureReference()
' Reference a Figure and insert Only label and number
With Application.Dialogs(wdDialogInsertCrossReference)
SendKeys "ff{TAB}{DOWN 2}{ENTER}", True
.InsertAsHyperLink = 1
.InsertPosition = 0
.Show
@japborst
japborst / defaultlist.py
Created September 5, 2016 09:44
A list alternative to the very useful collections.defaultdict
class DefaultList(list):
def __init__(self, factory=None):
super(DefaultList, self).__init__()
# Check if argument is callable
if factory is not None:
try:
factory()
except TypeError as e:
raise e
self._factory = factory
@japborst
japborst / SassMeister-input.scss
Created October 25, 2014 21:34
Generated by SassMeister.com.
// ----
// Sass (v3.4.6)
// Compass (v1.0.1)
// ----
// Margin
@mixin margin($top: 0, $right: $top or $left, $bottom: $top, $left: $right or $top) {
margin: $top $right $bottom $left;
}
<?php
// article.php located at /themes/<theme>/article.php
// ...
// replace
echo article_markdown();
// with
echo custom_markdown();
// ...