Skip to content

Instantly share code, notes, and snippets.

View discosultan's full-sized avatar

Jaanus Varus discosultan

  • Amsterdam, The Netherlands
View GitHub Profile
@BeRo1985
BeRo1985 / octahedralmap.glsl
Last active December 3, 2023 05:01
GLSL Octahedral Texture Mapping with Edge Mirroring and Bilinear Interpolation
// GLSL Octahedral Texture Mapping with Edge Mirroring and Bilinear Interpolation (by Benjamin 'BeRo' Rosseaux)
ivec2 wrapOctahedralTexelCoordinates(const in ivec2 texel, const in ivec2 texSize) {
ivec2 wrapped = ((texel % texSize) + texSize) % texSize;
return ((((abs(texel.x / texSize.x) + int(texel.x < 0)) ^ (abs(texel.y / texSize.y) + int(texel.y < 0))) & 1) != 0) ? (texSize - (wrapped + ivec2(1))) : wrapped;
}
vec4 textureOctahedralMap(const in sampler2D tex, vec3 direction) {
direction = normalize(direction); // just for to make sure that it is normalized
vec2 uv = direction.xy / (abs(direction.x) + abs(direction.y) + abs(direction.z));
@sgtoj
sgtoj / aws_sso.py
Last active February 13, 2024 18:58
AWS SSO Credentials File Updater for AWS SDKs
#!/usr/bin/env python3
import json
import os
import sys
from configparser import ConfigParser
from datetime import datetime
from pathlib import Path
import boto3
@yeraydiazdiaz
yeraydiazdiaz / threadpool_future_cancellation.py
Last active February 6, 2021 04:59
Cancellation on run_in_executor using ThreadPoolExecutor
"""
A demonstration on how raising KeyboardInterrupt in the context of tasks
spawned via asyncio's loop.run_in_executor does not cancel the threads
using any of the cancellation methods in asyncio Futures.
The only "proper" way to cancel is to:
1. unregister the `atexit` registered `_python_exit` function
2. call `shutdown(wait=False)`
The reason is that the `thread` module registers `_python_exit` forcing a
@mdlavin
mdlavin / lambda-function-xray-enablement.tf
Last active July 23, 2024 14:40
Terraform configuration to enable X-Ray for a Lambda function
resource "aws_lambda_function" "service" {
# Your usual aws_lambda_function configuration settings here
tracing_config {
mode = "Active"
}
}
@zthxxx
zthxxx / Activate Office 2019 for macOS VoL.md
Last active July 31, 2024 03:52
crack activate Office on mac with license file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sammchardy
sammchardy / binance-depth-cache-notes.txt
Last active September 25, 2022 10:36
Binance Depth Cache Notes
Ninj0r admin, [Oct 20, 2017, 9:18:55 AM]:
It's a three step process:
1) Start listening to the stream and buffering the messages
2) Get a depth snapshot
3) replay the buffered messages and the live messges.
Depth updates have two variables, u and U
U is the initial updateId, and u is the final updateId. There can be multiple updates "compressed" into a single update that comes out via the web socket stream.
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
// needed for no_std
@shanselman
shanselman / Dockerfile
Last active November 10, 2023 19:17
Smarter ASP.NET Core Docker File
FROM microsoft/dotnet:2.0-sdk as builder
RUN mkdir -p /root/src/app/aspnetcoreapp
WORKDIR /root/src/app/aspnetcoreapp
#copy just the project file over
# this prevents additional extraneous restores
# and allows us to resuse the intermediate layer
# This only happens again if we change the csproj.
# This means WAY faster builds!
@privatwolke
privatwolke / gather_dict.py
Created September 20, 2017 13:27
Python: Gather a dictionary of asyncio Task instances while preserving keys
async def gather_dict(tasks: dict):
async def mark(key, coro):
return key, await coro
return {
key: result
for key, result in await gather(
*(mark(key, coro) for key, coro in tasks.items())
)
}