Skip to content

Instantly share code, notes, and snippets.

View jonas-johansson's full-sized avatar

Jonas Johansson jonas-johansson

View GitHub Profile
@jonas-johansson
jonas-johansson / index.html
Created May 23, 2024 08:15
Auto size SVG between header and footer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SVG Full Height</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet" />
</head>
<body class="flex flex-col h-screen">
<header class="bg-blue-500 text-white p-4">
@jonas-johansson
jonas-johansson / top-content-bottom.tsx
Created May 16, 2024 19:24
Top, content, bottom with content using flex grow to fill available space
<div className="flex flex-col min-h-full h-full">
<div className="bg-blue-500">Top</div>
<div className="flex-grow bg-green-500">
<div>Content</div>
</div>
<div className="bg-red-500">Bottom</div>
</div>
@jonas-johansson
jonas-johansson / FileBackedStringCollection.cs
Created February 15, 2023 17:14
A collection of strings with a backing store on disk. It's useful if you want to have a persistent collection of strings in a pinch.
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
/// <summary>
/// A collection of strings with a backing store on disk.
/// It's useful if you want to have a persistent collection of strings in a pinch.
/// </summary>
class FileBackedStringCollection : ICollection<string>
@jonas-johansson
jonas-johansson / pre-commit
Created November 28, 2022 14:05
Git pre-commit hook that checks if there are any conflict markers present in any file.
#! /bin/sh
# Check to see if there are any conflict markers still present in a file. If so, exit 1 to prevent commit.
CONFLICT_MARKERS='<<<<<<<|=======|>>>>>>>'
CHECK=$(git diff --staged | grep "^+" | grep -Ei "$CONFLICT_MARKERS" -c)
if [ "$CHECK" -gt 0 ]
then
echo "ERROR: Conflict markers are still present in a file. Talk to a developer. Detected by a custom .git/hooks/pre-commit file."
git diff --name-only -G"$CONFLICT_MARKERS"
exit 1
@jonas-johansson
jonas-johansson / gist:096a1110184ab821e41e91d9950ae86f
Created August 1, 2022 09:49
Editor window that lists scenes in editor build settings and allows user to open or play them.
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
/// <summary>
/// Editor window that lists scenes in editor build settings and allows user to open or play them.
/// </summary>
public class SceneListEditorWindow : EditorWindow
@jonas-johansson
jonas-johansson / CoroutineRunnerUnity.cs
Last active November 26, 2020 15:05
This Bolt unit runs a coroutine by name on a MonoBehaviour.
using Bolt;
using Ludiq;
using System.Collections;
using UnityEngine;
namespace Neuston.Bolt
{
public class CoroutineRunnerUnit : Unit
{
[DoNotSerialize] public ControlInput start;
var client = new System.Net.Sockets.TcpClient("192.168.101.131", 21000);
if (client.Connected)
{
Debug.Log("Connected to server");
var stream = client.GetStream();
var data = new Byte[256];
var bytes = stream.Read(data, 0, data.Length);