Skip to content

Instantly share code, notes, and snippets.

@bg5sbk
bg5sbk / bevy_rapier_pan_orbit_cam.rs
Last active August 13, 2023 14:57
Rapier example for Bevy with Pan + Orbit Camera
// bevy = "0.11.0"
// bevy_rapier3d = { version = "0.22.0", features = [ "simd-stable", "debug-render-3d" ] }
// Pan + Orbit camera code: https://bevy-cheatbook.github.io/cookbook/pan-orbit-camera.html
// Use the right mouse button to rotate, middle button to pan, scroll wheel to move inwards/outwards.
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
use bevy::input::mouse::{MouseWheel,MouseMotion};
use bevy::render::camera::Projection;
@bg5sbk
bg5sbk / Example.cpp
Created February 18, 2017 06:44 — forked from reklis/Example.cpp
reliability-and-flow-control
/*
Reliability and Flow Control Example
From "Networking for Game Programmers" - http://www.gaffer.org/networking-for-game-programmers
Author: Glenn Fiedler <gaffer@gaffer.org>
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
@bg5sbk
bg5sbk / golang-tls.md
Created January 5, 2017 03:27 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
" Vim color file
"
" Author: Tomas Restrepo <tomas@winterdom.com>
"
" Note: Based on the monokai theme for textmate
" by Wimer Hazenberg and its darker variant
" by Hamish Stuart Macpherson
"
hi clear
@bg5sbk
bg5sbk / str_replace.c
Created April 18, 2014 18:30
replace string in C
// fork from https://github.com/irl/la-cucina/blob/master/str_replace.c
char* str_replace(char* string, const char* substr, const char* replacement) {
char* tok = NULL;
char* newstr = NULL;
char* oldstr = NULL;
int oldstr_len = 0;
int substr_len = 0;
int replacement_len = 0;
newstr = strdup(string);
@bg5sbk
bg5sbk / spotlight.sh
Created April 4, 2014 13:45
Disable or enable spotlight on Mac OS
#!/bin/sh
if [ ! $# == 1 ]; then
echo "How To Use:" >&2
echo " ./spotlight.sh [load|unload]" >&2
exit
elif [ ! $1 == 'load' ] && [ ! $1 == 'unload' ]; then
echo "How To Use:" >&2
echo " ./spotlight.sh [load|unload]" >&2
exit
@bg5sbk
bg5sbk / showall.sh
Created April 4, 2014 13:44
Enable or disable show all file on Mac OS
#!/bin/sh
if [ ! $# -eq 1 ]; then
echo "How To Use:" >&2
echo " ./show_all.sh [Yes|No]" >&2
exit
elif [ ! $1 == 'Yes' ] && [ ! $1 == 'No' ]; then
echo "How To Use:" >&2
echo " ./show_all.sh [Yes|No]" >&2
exit
@bg5sbk
bg5sbk / dashboard.sh
Created April 4, 2014 13:43
Disable or enable dashboard on Mac OS
#!/bin/sh
if [ ! $# -eq 1 ]; then
echo "How To Use:" >&2
echo " ./dashboard.sh [enable|disable]" >&2
exit
fi
if [ $1 == 'enable' ]; then
X='No'
@bg5sbk
bg5sbk / tcp_bench.go
Last active November 22, 2023 18:31
tcp benchmark for echo servers
package main
import (
"flag"
"fmt"
"log"
"net"
"sync"
"sync/atomic"
"time"
@bg5sbk
bg5sbk / http_timeout.go
Last active February 1, 2018 15:50
How to set timeout for http.Get() in golang.
//
// How to set timeout for http.Get() in golang
//
package main
import (
"io"
"io/ioutil"
"log"
"net"