Skip to content

Instantly share code, notes, and snippets.

View svermeulen's full-sized avatar

Steve Vermeulen svermeulen

View GitHub Profile
@svermeulen
svermeulen / Completion.vim
Last active August 29, 2015 14:13
Vim Completion with 'jk'
let s:startedScrolling = 0
function! g:TriggerCompletion()
if pumvisible()
call s:OnStartScrolling()
return "\<C-n>"
endif
return ""
endfunction
@svermeulen
svermeulen / cleverVariableArgs.vim
Created January 29, 2015 01:54
Clever alternative way of declaring optional parameters in vimscript
" Normal way of declaring variable arguments with default values:
function! ExampleFunc1(fix1, fix2, ...)
let var1 = a:0 > 0 ? a:1 : 'defaultVal1'
let var2 = a:0 > 1 ? a:2 : 5
echo a:fix1 .','. a:fix2 .','. var1 .','. var2
endfunction
" Alternative approach using a command:
@svermeulen
svermeulen / .cvimrc
Last active January 1, 2017 04:17
cVim Config
unmapAll
let scrollstep = 75
let barposition = "bottom"
let mapleader = ","
set typelinkhints
set numerichints
@svermeulen
svermeulen / InheritanceExample.lua
Created July 26, 2017 19:18
Lua OOP Inheritance Demo
Base = {}
function Base:new()
local obj = {foo = 'asdf'}
return setmetatable(obj, { __index = self })
end
function Base:run()
print(self.foo)
end
@svermeulen
svermeulen / gist:6ad9cd812c306730376d
Created November 14, 2014 16:30
Zenject Compatible Coroutine Task Runner
public class AsyncTaskProcessor : ITickable
{
public event Action LoadStarted = delegate {};
public event Action LoadComplete = delegate {};
// New workers to prevent a process from being popped before completion
List<WorkerData> _newWorkers = new List<WorkerData>();
// We use a stack here because otherwise sub process of current workers would never execute
// causing a state of limbo.
@svermeulen
svermeulen / gist:996213b4c6747c8c20f5a498ca67f932
Last active March 3, 2019 01:52
Hammerspoon to reload karabiner (12.2.0) complex modification. NOTE: Assumes 1 entry and that it's listed at the top in the add popup
hs.urlevent.bind("reloadKarabinerConfig", function(eventName, params)
hs.application.launchOrFocusByBundleID("org.pqrs.Karabiner-Elements.Preferences")
local delay = 10
hs.timer.doAfter(1, function()
-- Select the complex modifications tab
hs.eventtap.keyStroke({}, "right", delay)
hs.eventtap.keyStroke({}, "right", delay)
hs.timer.doAfter(1, function()
#if !NOT_UNITY3D
using System;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine;
using ModestTree;
namespace Zenject
{
@svermeulen
svermeulen / linq_python_examples.py
Created January 29, 2020 11:42
Python LINQ equivalents
def assert_throws(func):
try:
func()
except Exception:
return True
return False
def test_empty():
@svermeulen
svermeulen / pod.py
Created August 22, 2021 11:02
Dataclass base class example
from jsonpickle.unpickler import loadclass
import jsonpickle
import typeguard # type: ignore
from dataclasses import is_dataclass
import inspect
# The entire purpose of this class is just to hook into the unpickle event
# so that we can call validate_member_types
# We want to be as strict as possible when deserializing
@svermeulen
svermeulen / LICENSE
Last active September 15, 2021 15:13
MIT License
Copyright (c) 2021 Steven Vermeulen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: