Skip to content

Instantly share code, notes, and snippets.

View StrixG's full-sized avatar

Nikita Obrekht StrixG

View GitHub Profile
@forkerer
forkerer / dxDrawCircle.fx
Created August 19, 2018 13:50
Faster shader based dxDrawCircle
float4x4 gWorldViewProjection : WORLDVIEWPROJECTION;
struct VSInput
{
float3 Position : POSITION0;
float4 Diffuse : COLOR0;
float2 TexCoord : TEXCOORD0;
};
struct PSInput
{
float4 Position : POSITION0;
@Toliak
Toliak / encodeString-filesize-fix.lua
Last active February 22, 2020 15:29
MTA encodeString filesize fix
local KEY = "sampletext"
addEventHandler("onResourceStart", resourceRoot, function()
-- ENCODE
local file = File.open("test.txt")
local raw = file:read(file.size)
file:close()
local len = #raw
local lent = {}
@carloseduardosx
carloseduardosx / AutoIncrementEntity.java
Last active January 18, 2021 05:36
RealmAutoIncrement is a singleton which maintain the last id saved from each database model
package com.carloseduardo.model;
import com.carloseduardo.constants.KnownClasses;
import com.carloseduardo.exception.UnknownModelException;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import io.realm.annotations.Required;
/**
local map_setSoundProperty = {["SampleRate"] = 1, ["Tempo"] = 2, ["Pitch"] = 3, ["Reversed"] = 4}
function setSoundProperty(sound, property, value)
-- Only handle sound elements
if (not isElement(sound) or getElementType(sound) ~= "sound") then return end
-- Get the current properties
local properties = { getSoundProperties(sound) }
-- Get the index by using the property parameter
local index = map_setSoundProperty[property]
@cbsmith
cbsmith / random_selection.cpp
Last active August 9, 2022 12:29
Hopefully serves as a reference implementation on how to do random selection of an element from a container.
// -*- compile-command: "clang++ -ggdb -o random_selection -std=c++0x -stdlib=libc++ random_selection.cpp" -*-
//Reference implementation for doing random number selection from a container.
//Kept for posterity and because I made a surprising number of subtle mistakes on my first attempt.
#include <random>
#include <iterator>
template <typename RandomGenerator = std::default_random_engine>
struct random_selector
{
//On most platforms, you probably want to use std::random_device("/dev/urandom")()