Skip to content

Instantly share code, notes, and snippets.

🐧
¯\_(ツ)_/¯

Niels van Velzen nielsvanvelzen

Block or report user

Report or block nielsvanvelzen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nielsvanvelzen
nielsvanvelzen / ExposedQueryOrderByDistance.kt
Created Mar 15, 2019
Order by distance function for JetBrains Exposed.
View ExposedQueryOrderByDistance.kt
import org.jetbrains.exposed.sql.*
fun Query.orderByDistance(
columnX: Column<Double>,
columnY: Column<Double>,
compareX: Double,
compareY: Double,
order: SortOrder = SortOrder.ASC
@nielsvanvelzen
nielsvanvelzen / example.js
Created May 3, 2018
ES6 Async constructors
View example.js
/*
* Ecmascript supports the `async` keyword to make functions async.
* Unfortunately it doesn't work on construcors.
*
* However: you can return in a constructor!
*/
(async() => { // for top level await
class Example {
// ES6 constructor
@nielsvanvelzen
nielsvanvelzen / prime-toggle.sh
Last active Aug 13, 2017
Toggle prime on gnome
View prime-toggle.sh
CURRENT_DRIVER=$(prime-select query)
NEW_DRIVER="intel"
if [ "$CURRENT_DRIVER" = "intel" ]; then
NEW_DRIVER="nvidia"
fi
pkexec prime-select "$NEW_DRIVER" > /dev/null
echo "Switched from $CURRENT_DRIVER to $NEW_DRIVER"
View Tile.kt
package nl.ndat.isometric.ui
import nl.ndat.isometric.Bootstrap
import nl.ndat.isometric.core.IView
import org.w3c.dom.CanvasRenderingContext2D
import org.w3c.dom.Path2D
class Tile : IView() {
val styleInside = "#8BB255"
val styleInsideHover = "#54b2a5"
View kotlin_touch_event.kt
import org.w3c.dom.events.EventTarget
import org.w3c.dom.events.UIEvent
external abstract class TouchEvent : UIEvent {
open val touches: Array<Touch>
open val targetTouches: Array<Touch>
open val changedTouches: Array<Touch>
open val altKey: Boolean
open val metaKey: Boolean
open val ctlKey: Boolean
View SampleScene.kt
package nl.ndat.yui.scene
import java.io.File
import javax.imageio.ImageIO
class SampleScene : Scene() {
val logo = ImageIO.read(File("logo.png"))!!
var x = 0
var y = 0
var xR = false
View example_database.js
'use strict';
const Database = require('../src/Database');
//let database = new Database(__dirname + '/example.db'); // Use file "example.db"
let database = new Database(null); // Use memory
database.define('user', {
id: {type: Number, index: true},
name: String,
View gameplay.list
tinkers-construct
storage-drawers
iron-chests
chisels-bits
rftools
random-things
actually-additions
psi
rftools-dimensions
more-foods
View picasa.js
/* npm install request */
var user = null;
var album = null;
var authkey = null;
var downloadDir = './download/{user}-{album}/';
var args = process.argv.slice(2);
if(args.length >= 1 && args[0].substr(0, 4) === 'http'){
user = args[0].substr(args[0].indexOf('.com/') + 5).split('/')[0];
View interface_test.lua
local width = 1600
local height = 900
-- Create window & show loading message
window.create(width, height, "Interface test")
canvas.init()
canvas.beginFrame(width, height, 1.0)
canvas.createFont("Open Sans", "test/font/OpenSans-Regular.ttf")
canvas.fontFace("Open Sans")
canvas.fontSize(24)
You can’t perform that action at this time.