Skip to content

Instantly share code, notes, and snippets.

View spajus's full-sized avatar
🌴
On vacation

Tomas Varaneckas spajus

🌴
On vacation
View GitHub Profile
@spajus
spajus / docker_volumes.md
Created April 6, 2024 07:00
Docker volumes

When running an application inside a Docker container on Linux and you need to persist files or share files between the host and the container, you indeed use volumes. Docker volumes are the preferred mechanism for persisting data generated by and used by Docker containers.

To mount a volume and persist files, you generally follow these steps:

  1. Decide on the Host Directory: First, decide which directory on your host system you want to persist data in. This can be any path, for example, /home/username/data.

  2. Create the Volume (Optional): This step is optional because Docker can automatically create the host path if it doesn't exist when you run the container. However, if you want to configure or use a named volume, you can create one explicitly with:

    docker volume create volume_name
using System;
using System.Collections;
using System.Collections.Generic;
using Game.Audio;
using Game.Commands;
using Game.Components;
using Game.Constants;
using Game.Data;
using Game.Utils;
using Game.Visuals;
float3 RGBtoHSV(float3 In)
{
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 P = lerp(float4(In.bg, K.wz), float4(In.gb, K.xy), step(In.b, In.g));
float4 Q = lerp(float4(P.xyw, In.r), float4(In.r, P.yzx), step(P.x, In.r));
float D = Q.x - min(Q.w, Q.y);
float E = 1e-10;
return float3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);
}
@spajus
spajus / Resize.cpp
Last active July 17, 2023 14:26
A tiling window manager for streaming / recording video on 3440x1440 screen with 2560x1440 capture area in the center.
#include <iostream>
#include <string>
#include <Windows.h>
#include <WinUser.h>
#include <TlHelp32.h>
void ResizeActiveWindow(float hScale, float vScale, int newX, int newY) {
HWND activeWindow = GetForegroundWindow();
if (activeWindow) {
// Get the handle to the monitor where the window is currently located
# CSharp formatting rules:
[*.cs]
csharp_new_line_before_open_brace = none
csharp_new_line_before_else = false
csharp_new_line_before_catch = false
csharp_new_line_before_finally = false
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_between_query_expression_clauses = false
@spajus
spajus / video_to_cropped_gif.bat
Created January 25, 2023 07:00
A batch file that uses ffmpeg to create high quality cropped gifs from any video footage
@echo off
if exist "%~1" (
echo "Will convert to gif: %~1"
) else (
echo "Usage: Drag and drop a video file on this script"
pause
exit 1
)
set "start_time=0.0"
@spajus
spajus / TraitCat.cs
Created October 18, 2022 05:51
Stardeus Species Traits example C# code
using System.Collections.Generic;
using Game.Components;
using Game.Constants;
using Game.Data;
using KL.Collections;
using Game.Utils;
using KL.Randomness;
using UnityEngine;
namespace Game.AI.Traits {
@spajus
spajus / WreckedEmptyShipScenario.cs
Created October 13, 2022 08:14
Stardeus scenario example code
using System.Collections;
using Game.Audio;
using Game.Constants;
using Game.Data;
using Game.Procgen;
using Game.Story.Events;
using Game.Systems.Goals;
using Game.Utils;
using KL.Randomness;
using KL.Utils;
using UnityEngine;
namespace KL.Utils {
public class LoadPrefab : MonoBehaviour {
#pragma warning disable 0649
[SerializeField] private GameObject prefab;
[SerializeField] private bool inEditor = true;
[SerializeField] private bool inRuntime = true;
#pragma warning restore 0649
@spajus
spajus / CompileTime.cs
Created July 2, 2020 07:59
Put this into Scripts/Editor and open via Unity menu Kodo Linija > Compile Time
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEditor.SceneManagement;
using UnityEngine;
class CompileTime : EditorWindow {
bool allowProfiler = false;
bool isTrackingTime;