Skip to content

Instantly share code, notes, and snippets.

View peterhellberg's full-sized avatar
💙
Coding Go

Peter Hellberg peterhellberg

💙
Coding Go
View GitHub Profile
@peterhellberg
peterhellberg / alacritty.yml
Last active April 23, 2023 09:58
Alacritty configuration with Jellybeans colorscheme, and ⌘↵ to ToggleSimpleFullscreen
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
@peterhellberg
peterhellberg / tailget.sh
Created April 21, 2023 05:51
Taildrop: Receive file into temporary directory, change ownership, move to target directory
#!/usr/bin/env bash
user=peter
group=peter
target=/home/$user/Downloads/Taildrop/
tmpdir=$(mktemp -d '/tmp/taildrop.XXXXXX' 2>/dev/null || mktemp -d -t 'taildrop')
if [ -z "$tmpdir" ]
then
echo "Could not create temporary directory"
else
@peterhellberg
peterhellberg / ffmpeg-example.go
Created April 23, 2017 15:44
FFmpeg from Go usage example
package main
import (
"os/exec"
)
func newCmd(imageFile, audioFile, outFile string) *exec.Cmd {
return exec.Command("ffmpeg",
"-r", "1",
"-loop", "1",
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char **argv)
{
FILE *afile = NULL;
FILE *bfile = NULL;
unsigned char *bbuffer = NULL;
@peterhellberg
peterhellberg / server.go.plush
Created January 11, 2023 16:08
Oto template which include otohttp inline instead of importing it.
// Code generated by oto; DO NOT EDIT.
package <%= def.PackageName %>
import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
"io"
@peterhellberg
peterhellberg / ffserver.conf
Last active December 2, 2022 06:30
MJPEG stream from Webcam using FFServer and FFMpeg
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 200
MaxClients 100
MaxBandWidth 500000
CustomLog -
<Feed camera.ffm>
File /tmp/camera.ffm
FileMaxSize 200M
const std = @import("std");
const ray = @cImport({
@cInclude("raylib.h");
});
pub fn main() void {
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
@peterhellberg
peterhellberg / max_parallelism.go
Created June 24, 2013 07:25
Find out the max value for GOMAXPROCS on your machine.
package main
import (
"fmt"
"runtime"
)
func MaxParallelism() int {
maxProcs := runtime.GOMAXPROCS(0)
numCPU := runtime.NumCPU()
@peterhellberg
peterhellberg / conf.lua
Created November 14, 2015 08:45
Scrolling Shooter from the tutorial “Your First Love2d Game in 200 Lines”
-- Configuration
function love.conf(t)
t.title = "Scrolling Shooter"
t.version = "0.9.2"
t.window.width = 480
t.window.height = 700
t.console = true
end
@peterhellberg
peterhellberg / pixel-pong.go
Last active July 5, 2022 12:29
Minimal Pong rendered by Pixel
package main
import (
"fmt"
"image/color"
"math/rand"
"github.com/faiface/pixel"
"github.com/faiface/pixel/imdraw"
"github.com/faiface/pixel/pixelgl"