Skip to content

Instantly share code, notes, and snippets.

@keturn
keturn / fpcursorpagination.py
Last active April 21, 2022 15:21
test for CursorPagination with floating point field
class FloatingPointCursorPagination(CursorPagination):
__rounding_down = decimal.Context(prec=14, rounding=decimal.ROUND_FLOOR)
__rounding_up = decimal.Context(prec=14, rounding=decimal.ROUND_CEILING)
def _get_position_from_instance(self, instance, ordering):
field_name = ordering[0].lstrip('-')
if isinstance(instance, dict):
attr = instance[field_name]
else:
attr = getattr(instance, field_name)
@keturn
keturn / manage-shell-plus-notebook.log
Last active June 20, 2017 23:32
jupyter notebook fails to bind network address
$ docker-compose run --rm django
[I 22:09:16.284 NotebookApp] Writing notebook server cookie secret to /home/django/.local/share/jupyter/runtime/notebook_cookie_secret
Traceback (most recent call last):
File "./notebug/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
@keturn
keturn / 00_README
Last active June 12, 2018 06:44 — forked from dogeared/00_README
Extracting / Exporting custom emoji from Slack
This builds off the excellent work of @lmarkus & @dogeared.
The scripts below can be used in conjunction with the Slack Emoji Tools Google Chrome extension to export emojis from
one Slack team and import into another team.
Original work here:
* https://gist.github.com/lmarkus/8722f56baf8c47045621
* https://gist.github.com/dogeared/f8af0c03d96f75c8215731a29faf172c
@keturn
keturn / bundle.gradle.kts
Last active October 2, 2018 00:10
sample Gradle Kotlin-DSL build script for libktx project
plugins {
eclipse
idea
kotlin("jvm") version "1.2.71"
}
allprojects {
version = "1.0"
val appName by extra { "MY_PROJECT_NAME" }
@keturn
keturn / pr-only-fork.sh
Created December 29, 2019 01:52
Document git fork as "Pull-Request Only"
#!/bin/bash
# Replace the repo's default branch with a README explaining this fork is only for its submitted pull requests.
set -e -x -o pipefail
REMOTE=origin
GH_USERNAME="${GH_USERNAME:-$USER}"
TRUNK="$(git symbolic-ref --short refs/remotes/$REMOTE/HEAD | sed "s:${REMOTE}/::")"
REMOTE_URL="$(git remote get-url $REMOTE)"
@keturn
keturn / nouns.txt
Created February 10, 2020 04:10
Azarinth Healer: People and Places (Proper Nouns)
Aaron
Abby
Adam Strand
Agor
Akelion
Aki
Albert
Alex
Aliana
Alice Forkspear
@keturn
keturn / Terasology Engine Package.xml
Created March 7, 2021 21:06
Terasology migration for engine packages
<?xml version="1.0" encoding="UTF-8"?>
<migrationMap>
<name value="Terasology Engine Package" />
<description value="Move the `:engine` project entirely inside `org.terasology.engine`&#10;&#10;reflection, persistence, and protobuf are left out due to being mixed up with other sources&#10;&#10;https://github.com/MovingBlocks/Terasology/pull/4560" />
<entry oldName="org.terasology.engine.module" newName="org.terasology.engine.core.module" type="package" recursive="true" />
<entry oldName="org.terasology.audio" newName="org.terasology.engine.audio" type="package" recursive="true" />
<entry oldName="org.terasology.config" newName="org.terasology.engine.config" type="package" recursive="true" />
<entry oldName="org.terasology.context" newName="org.terasology.engine.context" type="package" recursive="true" />
<entry oldName="org.terasology.entitySystem" newName="org.terasology.engine.entitySystem" type="package" recursive="true" />
<entry oldName="org.terasology.game" newName="org.terasology.engine.
@keturn
keturn / SpyingOutputObjectStream.java
Last active May 18, 2022 03:01
Java: Get a lambda's parameter types
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.lang.invoke.MethodType;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@keturn
keturn / MethodHandleAdapters.java
Last active May 18, 2022 03:01
Java MethodHandle from SerializedLambda
import com.google.common.base.Throwables;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandleInfo;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.SerializedLambda;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
@keturn
keturn / engine-tests.md
Last active May 23, 2022 19:32
Terasology Test Dependency Diagram

Main Implementation Dependencies

flowchart TD

modA(Module A)
modB(Module B)
engine-tests
engine