Skip to content

Instantly share code, notes, and snippets.

Avatar

Louis Beaumont louis030195

View GitHub Profile
@louis030195
louis030195 / SpawnThingsAboveGround.cs
Last active Jun 3, 2020
Unity helper to spawn object above ground or try to spawn objects above ground in a random sphere while keeping a given distance
View SpawnThingsAboveGround.cs
public static class Spatial
{
/// <summary>
/// Return position above ground relatively from the prefab size
/// Global position
/// </summary>
/// <param name="position"></param>
/// <param name="prefabHeight">Prefab height needed in order to place well on top of ground</param>
/// <param name="transform">Transform parent</param>
/// <param name="layerMask">Layers to ignore</param>
@louis030195
louis030195 / diamond.go
Created May 7, 2020
Diamond square algorithm in Golang
View diamond.go
package main
import (
"errors"
"math/rand"
)
// Copy pasta https://gist.github.com/awilki01/83b65ad852a0ab30192af07cda3d7c0b
// Originally was Java, then C# then Go ... have fun
////size of grid to generate, note this must be a
@louis030195
louis030195 / Makefile
Created May 1, 2020
Makefile to build Unity project for Linux (since Unity doesn't provides any documentation for Linux)
View Makefile
UNITY_PROJECT_PATH ?= $(HOME)/my/path/to/unity/project
NS ?= my_game_name
VERSION ?= 1.0.0
EDITOR_PATH ?= $(HOME)/my/path/to/unity/project
CUSTOM_BUILD_SCRIPT ?= MyNameSpace.MyClass.MyFunction
.PHONY: help build run
help:
@echo ''
@echo 'Usage: make [TARGET]'
@louis030195
louis030195 / Dockerfile
Created Apr 30, 2020
Simulate Apache Kafka changes safely and cleanly before doing it in production
View Dockerfile
FROM debian:9
# Wget, ps, java
RUN apt-get update && apt-get install -y wget procps default-jdk
ENV KAFKA_VERSION=1.1.1
ENV KAFKA_DIRECTORY=kafka_2.12-${KAFKA_VERSION}
# Current version
RUN wget https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/${KAFKA_DIRECTORY}.tgz \
View grpc_test.go
package main
import (
"fmt"
"github.com/The-Tensox/erutan/cfg"
erutan "github.com/The-Tensox/erutan/protobuf"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"io"
@louis030195
louis030195 / wait_for_open_port_inside_docker.sh
Created Apr 14, 2020
Bash script to wait for an open port inside Docker container
View wait_for_open_port_inside_docker.sh
CONTAINER_NAME=my-awesome-container
PORT=1337
while [ ! "$(docker exec -t -i $CONTAINER_NAME curl --write-out %{http_code} --silent --output /dev/null localhost:$PORT)" = "-ne 200" ] ; do
echo "Waiting for port $PORT to be opened ..."
sleep 20
done
@louis030195
louis030195 / json_to_yaml.sh
Last active Apr 21, 2020
JSON to YAML, one liner bash, usage: chmod +x json_to_yaml.sh && ./json_to_yaml.sh my_json.json my_yaml.yml
View json_to_yaml.sh
#!/bin/bash
python3 -m venv .my_super_env && # Yeah random name to avoid erasing local virtualenv
source .my_super_env/bin/activate &&
pip install pyyaml &&
python3 -c "import yaml, json, sys
sys.stdout.write(yaml.dump(json.load(sys.stdin)))" \
< $1 > $2
# Remove the temporary venv in any case
rm -rf .my_super_env
View protodef_example_split.json
{
"name": "myList",
"type": [
"array",
{
"count": ";",
"type": [
"container",
[
{
View play_with_rocket_mongodb.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[get("/")]
fn index() -> &'static str {
let coll = client.db("media").collection("movies");
coll.insert_one(doc!{ "title": "Back to the Future" }, None).unwrap();
coll.update_one(doc!{}, doc!{ "director": "Robert Zemeckis" }, None).unwrap();
coll.delete_many(doc!{}, None).unwrap();
View test.rs
// See https://rocket.rs/v0.4/guide/testing/#local-dispatching
#[cfg(test)]
mod test {
use mongodb::{doc, error::Error, oid::ObjectId};
use rocket::http::{ContentType, Status};
use rocket::local::Client;
use rocket_contrib::json::Json;
use rustlang_rocket_mongodb::cats::Cat;
use rustlang_rocket_mongodb::rocket;
You can’t perform that action at this time.