Skip to content

Instantly share code, notes, and snippets.

View RomkeVdMeulen's full-sized avatar

Romke van der Meulen RomkeVdMeulen

View GitHub Profile
@RomkeVdMeulen
RomkeVdMeulen / cache.spec.ts
Last active January 10, 2017 16:17
Aurelia cache service
import {Container} from "aurelia-framework";
import {CacheService, CACHE_STORE} from "./cache";
describe("The Cache Service", () => {
let cacheManager: CacheService;
beforeEach(() => {
cacheManager = new Container().get(CacheService);
});
@RomkeVdMeulen
RomkeVdMeulen / smooth-anchors-scroll.js
Created July 30, 2016 14:38
Smooth scrolling to anchors using jQuery
$('a').click(function(ev){
href = this.href.replace(window.location.href,'');
if ( href[0] != '#' || !$(href) ) {
return;
}
$('html, body').animate({ scrollTop: $(href).offset().top }, 500);
ev.stopPropagation();
return false;
});
@RomkeVdMeulen
RomkeVdMeulen / deferrred.ts
Last active December 24, 2017 18:26
A Typescript utility classes for working with promises that are resolved elsewhere.
/**
* @see https://github.com/domenic/promises-unwrapping/blob/master/docs/states-and-fates.md
*/
export class Deferred<T> {
public promise: Promise<T>;
private fate: "resolved" | "unresolved";
private state: "pending" | "fulfilled" | "rejected";
private _resolve: Function;
alias ttime_green="sh -c \"sleep 180 && notify-send -u critical 'The tea is ready'\" &"
alias ttime_black="sh -c \"sleep 300 && notify-send -u critical 'The tea is ready'\" &"
@RomkeVdMeulen
RomkeVdMeulen / glassfish_pkg_for_64.sh
Created September 1, 2016 08:24
Instructions for running the 32-bit Glassfish pkg tool on 64-bit Ubuntu
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libidn11:i386 libgssapi-krb5-2:i386
@RomkeVdMeulen
RomkeVdMeulen / ts-collect-textkeys.js
Last active October 12, 2016 10:43
Collect text usage during build step
var es = require('event-stream');
var fs = require('fs');
var mkdirp = Promise.denodeify(require('mkdirp'));
var path = require('path');
var plumber = require('gulp-plumber');
var Promise = require('promise');
var ts = require('typescript');
var typescript = require('gulp-typescript');
var paths = {
export function translation(textkey: string) {
if (!textkey) {
throw "Parameter textkey is required with the @translation decorator";
}
return (target: any, property: string) => {
translationService().getTranslation(textkey)
.then(text => target[property] = text);
}
}
@Singleton
public class FrontendTextBean {
@EJB
private TextCache textCache;
private Set<String> textkeys = new HashSet<>();
@PostConstruct
public void init() {
@RomkeVdMeulen
RomkeVdMeulen / key-listener.ts
Last active December 27, 2021 05:59
TypeScript decorator to apply to a method that should only be invoked in response to certain keypress events.
export const enum KeyCode {
ENTER = 13,
SPACE = 32
}
export function keyListener(keyCodes: KeyCode | KeyCode[]) {
if (!(keyCodes instanceof Array)) {
keyCodes = [keyCodes];
}