Skip to content

Instantly share code, notes, and snippets.

View bverbeken's full-sized avatar

Ben Verbeken bverbeken

View GitHub Profile
import random
class RollAbilitiesAttempt:
def __init__(self):
self.rolls = self.roll_abilities()
@bverbeken
bverbeken / keybase.md
Created September 17, 2014 19:32
keybase.md

Keybase proof

I hereby claim:

  • I am bverbeken on github.
  • I am bverbeken (https://keybase.io/bverbeken) on keybase.
  • I have a public key whose fingerprint is 5DC6 51DE A375 C585 6E3E F081 EDF5 A528 591C A784

To claim this, I am signing this object:

@bverbeken
bverbeken / client.js
Created July 8, 2014 19:12
slanger client (nodejs)
var Slanger = (function() {
var crypto = require('crypto');
var request = require('request');
var Slanger = function (options) {
this.options = options;
this.options.domain = this.options.domain || 'localhost';
this.options.domain = this.options.domain || 4567;
this.options.scheme = this.options.scheme || 'http';
@bverbeken
bverbeken / MyImplicits.scala
Created May 19, 2014 10:24
How can I avoid duplication here?
object MyImplicits {
implicit def fieldString_To_OptionString(duck: {def getValue(): String}): Option[String] = {
duck match {
case null => None
case x => Option(x.getValue())
}
}
implicit def fieldDecimal_To_OptionOfBigDecimal(duck: {def getValue(): java.math.BigDecimal}): Option[BigDecimal] = {
@bverbeken
bverbeken / .bash_aliases
Created February 6, 2014 12:43
Deploy to heroku - bash
deploy() {
heroku maintenance:on -r $1
git push $1
heroku maintenance:off -r $1
}
@bverbeken
bverbeken / SomeController.java
Last active May 13, 2020 16:00
convert spring field errors to json
@RequestMapping(method = POST)
@ResponseBody
public ResponseEntity<?> submit(@Valid MyRequestType request, BindingResult result) {
if (result.hasErrors()) {
return new ResponseEntity<>(getErrorsInASaneFormat(result), BAD_REQUEST);
}
// do stuff
return new ResponseEntity(CREATED);
}
@bverbeken
bverbeken / app.js
Last active July 22, 2018 13:37
angular, spring MVC and multipart/form-data
$scope.saveMyObject = function () {
return $http({
method: 'POST',
url: '/my/url',
headers: {
'Content-Type': undefined // --> makes sure the boundary is set in the Content-Type header, see result file
},
data: {
file: $scope.file,
startDate: $scope.startDate,
@bverbeken
bverbeken / application.js
Created November 29, 2013 11:00
WnotW pricing table fix
$('#pricingModal').click(function(e){
e.preventDefault();
var scroll = $(window).scrollTop();
$('#modalBackdrop, #modalPrice').show();
$('#modalPrice').css({
position: 'absolute', // This is missing
@bverbeken
bverbeken / gist:6230172
Created August 14, 2013 11:24
.bash_aliases
alias q='exit'
alias cd..='cd ..'
alias top='htop'
alias ports='netstat -tulanp'
alias ll='ls -hal'
@bverbeken
bverbeken / gist:5908972
Created July 2, 2013 12:44
eclipse-like keybindings for sublime 2
[
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+alt+j"], "command": "join_lines" },
{ "keys": ["ctrl+alt+down"], "command": "duplicate_line" },
{ "keys": ["shift+ctrl+r"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["ctrl+shift+s"], "command": "save_all" },
{ "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["shift+ctrl+f4"], "command": "close_all" },