Skip to content

Instantly share code, notes, and snippets.

@dubgeiser
dubgeiser / autoload.file.vim
Created August 1, 2022 18:11
VimScript function to get a shorter full path of a file.
" Display a short path where the first directory is displayed with its
" full name, and the subsequent directories are shortened to their
" first letter, i.e. `/home/user/foo/foo/bar/baz.vim` becomes
" `~/foo/f/b/baz.vim`
"
" This kinda duplicates the behavior of `pathshorten()` but it differs because
" `pathshorten()` also truncates the first directory name in the path, which
" is undesired behavior since a lot of info is in there, plus, it also helps
" in differentiating between Git buffer and its corresponding file when doing
" `:GDiff` and the likes.
@dubgeiser
dubgeiser / bleh.py
Last active October 18, 2019 23:56
#!/usr/bin/env python3
import locale
locale.setlocale(locale.LC_MONETARY, 'nl_be')
def money(amount):
return locale.currency(
amount, symbol=True, grouping=True, international=True)
# https://www.tijd.be/politiek-economie/belgie/algemeen/antwerpse-gemeenteraad-stemt-over-42-procent-opslag-voor-zichzelf/10171801.html
@dubgeiser
dubgeiser / grumphptoale.py
Created May 8, 2018 11:23
Script, depending on PyYaml to parse a GrumPHP config to Vim ale variable settings. (basic POC)
#!/usr/bin/env python3
""" Script that will convert a grumphp.yml file to Vimscript.
Basically it will convert the Yaml to Vimscript assignments that can configure
the Vim Ale plugin.
The script will extract the relevant settings for phpcs and phpstan from
grumphp.yml and spit out Vimscript.
Dependencies:

Keybase proof

I hereby claim:

  • I am dubgeiser on github.
  • I am dubgeiser (https://keybase.io/dubgeiser) on keybase.
  • I have a public key ASC6QbQrwv9wlcaSQqYvhqqVph5OrHaudfdKNXi4qB3szwo

To claim this, I am signing this object:

@dubgeiser
dubgeiser / gist:3010641
Created June 28, 2012 10:48
jQuery dialog() and form fields.
//
// Situation: you have form, when a user clicks on something, a dialog needs to
// appear where the user can fill in some optional field of that form and in
// that dialog (s)he can click to submit the form.
//
// Possible solution: You hide the optional field, create a dialog via jQuery's
// dialog() and add a dialog button that submits the form.
//
// Problem: While the form submits, there is no optional field in the submitted
// data.
@dubgeiser
dubgeiser / gist:2302110
Created April 4, 2012 14:50
Upload Mac OS X screenshot to imgur.
#!/bin/bash
#
# Upload a screenshot to imgur "on the fly":
# Let user select region, take screenshot
# Upload screenshot to imgur.com
# Print resulting url to image.
#
# @see http://api.imgur.com/examples
#
@dubgeiser
dubgeiser / gist:2282745
Created April 2, 2012 11:16
Get git branch in Vim
" @return string The git branch we're in, empty if none.
function! functions#git_branch()
return system("git branch 2>/dev/null | grep '^\*' | sed 's/^\* //'")
endfunction
@dubgeiser
dubgeiser / gist:2269368
Created March 31, 2012 22:58
Delete all tables in a MySQL database.
echo 'show tables;' | mysql -uUSER -pPASSWORD DBNAME | sed '1d' | sed -E 's/^(.*)$/DROP TABLE IF EXISTS `\1`;/' | mysql -uUSER -pPASSWORD DBNAME
@dubgeiser
dubgeiser / gist:980655
Created May 19, 2011 12:44
Properties
<?php
function property() {
if (func_num_args()) {
$this->property = func_get_arg(0);
} else {
return $this->property;
}
return $this;
}