Skip to content

Instantly share code, notes, and snippets.

@torgeir
torgeir / wine-helix-native-vst.log
Last active March 18, 2024 10:17
Wine installing Helix Native 3.11 on Ubuntu Studio 21.01 with wine-staging 6.12
# Install a bunch of Windows DLLs needed to make Native work
# https://ubuntuhandbook.org/index.php/2021/05/wine-6-9-released-install-in-ubuntu-21-04-20-04/
sudo apt install --install-recommends winehq-staging
wine 'wineboot'
sudo apt install winetricks
# on manjaro with x11 this worked fine
winetricks vcrun2013 gdiplus urlmon
# on arch with wayland (amd) I needed
winetricks dxvk vcrun2013 gdiplus urlmon
@torgeir
torgeir / method-missing-proxy.js
Last active March 11, 2024 01:59
es6 proxies method missing example
/*
What happens?
- `new Type().what` is looked up with a call to `get` on the proxy
- a function is returned that will look up `METHOD_NAME` when called
- `METHOD_NAME` is called because of the `()` behind `new Type().what`
- if `METHOD_NAME` exists on you object, your own function is called
- if not, because of prototypal inheritance, `get` is called again
- `name` is now `METHOD_NAME` and we can throw as we know `METHOD_NAME` is not implemented on the type
credits http://soft.vub.ac.be/~tvcutsem/proxies/
@torgeir
torgeir / minimal-maven-pom.xml
Last active February 17, 2024 00:08
A minimal maven pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gd.wa</groupId>
<artifactId>minimal-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
@torgeir
torgeir / install-java8-arm-on-raspberry-pi.sh
Created December 22, 2014 16:38
Installing java 8 arm on a raspberry pi
# download jdk-8-linux-arm-vfp-hflt.tar.gz from oracle
$ sudo tar zxvf jdk-8-linux-arm-vfp-hflt.tar.gz -C /opt
# ...
$ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_06/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_06/bin/java 1
@torgeir
torgeir / team-member-by-week.js
Created September 15, 2023 17:11
A script to post the name of a team member to a slack web hook once a week.
(async function () {
var webHookUrl = "https://hooks.slack.com/triggers/a/b/c";
// credits chatgpt
function isoWeek(date) {
// copy date so don't modify original
date = new Date(date);
// set to nearest thursday (current date + 4 - current day) % 7
date.setUTCDate(date.getUTCDate() + 4 - (date.getUTCDay() || 7));
@torgeir
torgeir / foldleft.js
Created September 5, 2011 07:51
js foldleft implementation
Array.prototype.foldLeft = function (sum, callback) {
var head,
list = Array.prototype.slice.call(this);
if (list.length) {
head = list.shift(1);
return list.foldLeft(callback(sum, head), callback);
}
return sum;
};
@torgeir
torgeir / gulpfile.js
Last active June 12, 2023 09:52 — forked from markgoodyear/01-gulpfile.js
Example gulpfile.js
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
@torgeir
torgeir / ExampleProxyMethodReturnTypeMismatch.java
Created June 6, 2023 08:35
Java example showing how a proxied methods return type may cause runtime class cast errors
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
class DynamicInvocationHandler implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return 42;
}
@torgeir
torgeir / TypeArgumentTest.java
Last active May 22, 2023 10:37
Find runtime generic type argument from superclass.
import java.lang.reflect.ParameterizedType;
public class TypeArgumentTest {
public static void main(String[] args) {
abstract class Super<T> {
public Class findTypeArgument() {
ParameterizedType genericSuperclass = (ParameterizedType) this.getClass().getGenericSuperclass();
@torgeir
torgeir / bq-table-suffix-different-schema.sql
Last active March 16, 2023 12:03
BQ table suffix when schema differs
# one: string
#INSERT INTO `torgeirtester.schema_one` values ("one");
# one: string, two: number
#INSERT INTO `torgeirtester.schema_two` values ("one", 2);
# three: boolean
#INSERT INTO `torgeirtester.schema_three` values (true);
SELECT * FROM `torgeirtester.schema_*`;