Skip to content

Instantly share code, notes, and snippets.

@darkfall
darkfall / gist:1656050
Created January 22, 2012 07:15
A simple class that converts a image to a icon in c# without losing image color data, unlike System.Drawing.Icon; ico with png data requires Windows Vista or above
class PngIconConverter
{
/* input image with width = height is suggested to get the best result */
/* png support in icon was introduced in Windows Vista */
public static bool Convert(System.IO.Stream input_stream, System.IO.Stream output_stream, int size, bool keep_aspect_ratio = false)
{
System.Drawing.Bitmap input_bit = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(input_stream);
if (input_bit != null)
{
int width, height;
@philipstanislaus
philipstanislaus / sane-caching.nginx.conf
Last active June 19, 2024 03:05
Sample Nginx config with sane caching settings for modern web development
# Sample Nginx config with sane caching settings for modern web development
#
# Motivation:
# Modern web development often happens with developer tools open, e. g. the Chrome Dev Tools.
# These tools automatically deactivate all sorts of caching for you, so you always have a fresh
# and juicy version of your assets available.
# At some point, however, you want to show your work to testers, your boss or your client.
# After you implemented and deployed their feedback, they reload the testing page – and report
# the exact same issues as before! What happened? Of course, they did not have developer tools
# open, and of course, they did not empty their caches before navigating to your site.
@douglasmiranda
douglasmiranda / instructions.md
Created July 19, 2018 05:51
Add email to Keybase.io PGP Key (Public Key)

Export your public key:

keybase pgp export > keybase-public.key

Export your private key:

keybase pgp export --secret > keybase-private.key
@shikendon
shikendon / config.yml
Last active March 21, 2024 06:39
Deploy a simple Minecraft proxy server.
# Change your BungeeCord configuration to enable PROXY Protocol.
listeners:
- host: 0.0.0.0:25577
proxy_protocol: true
@gabrielsson
gabrielsson / minecraft-on-raspberry-pi.md
Last active June 14, 2024 16:37
Minecraft on Raspberry Pi cluster with metrics

alt

Minecraft on Raspberry Pi cluster with metrics

Ever wanted to put your Rapsberry Pi cluster to great use? Our team is working remotely, so we started to play Minecraft. I decided I would host the Minecraft server on my Raspberry Pi cluster. This gist will guide you through the steps I took to get a k3s cluster up with k3sup and later installed Minecraft as well as metrics exporter and Prometheus Operator

Why?

Quoniam Possumus - Because we can

You'll need

#!/bin/bash
############################################################################
# This script simply formats a block device and mounts it to the data
# directory in a very safe manner by checking that the block device is
# completely empty
#
############################################################################
set -eu
if [ $# -ne 2 ]
@danvy
danvy / WSL2-Net-Fix.ps1
Created September 5, 2020 21:04
Reset your WSL network connection trying to fix WSL2 media disconnected error
# Check these threads before proceeding:
# https://github.com/microsoft/WSL/discussions/5857
# https://github.com/microsoft/WSL/issues/5821
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
$CmdLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CmdLine
Exit
}
# Restart the Host Network Service
Restart-Service -Force -Name hns
@HunterAP23
HunterAP23 / media_to_avi.bat
Last active October 21, 2023 06:59
Convert Media Sources to rawvideo AVI with transparency
@echo off
setlocal EnableDelayedExpansion
for %%a in (*.webm *.mkv) do (
FOR /F "usebackq" %%F IN (`ffprobe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%%a"`) DO (
if "%%F"=="vp8" (
ffmpeg -hide_banner -c:v libvpx -i "%%a" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 "%%~dpna_RAWVIDEO.avi"
) else (
if "%%F"=="vp9" (
ffmpeg -hide_banner -c:v libvpx-vp9 -i "%%a" -pix_fmt rgba -c:v rawvideo -c:a aac -q:a 5 "%%~dpna_RAWVIDEO.avi"
@HunterAP23
HunterAP23 / media_to_vp9.bat
Last active October 21, 2023 06:58
Convert Media Sources to lossless VP9 WEBM with transparency
@echo off
setlocal EnableDelayedExpansion
for %%a in (*.webm *.mkv) do (
FOR /F "usebackq" %%F IN (`ffprobe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%%a"`) DO (
if "%%F"=="vp8" (
ffmpeg -hide_banner -c:v libvpx -i "%%a" -pix_fmt yuva420p -c:v libvpx-vp9 -crf 0 -b:v 0 -lossless 1 -row-mt 1 -tile-columns 6 -tile-rows 2 -frame-parallel 1 -c:a libopus -b:a 96k "%%~dpna_VP9.webm"
) else (
if "%%F"=="vp9" (
ffmpeg -hide_banner -c:v libvpx-vp9 -i "%%a" -pix_fmt yuva420p -c:v libvpx-vp9 -crf 0 -b:v 0 -lossless 1 -row-mt 1 -tile-columns 6 -tile-rows 2 -frame-parallel 1 -c:a libopus -b:a 96k "%%~dpna_VP9.webm"
@HunterAP23
HunterAP23 / media_to_prores.bat
Last active October 21, 2023 06:58
Convert Media Sources to lossless ProRes MOV with transparency
@echo off
setlocal EnableDelayedExpansion
for %%a in (*.webm *.mkv) do (
FOR /F "usebackq" %%F IN (`ffprobe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 "%%a"`) DO (
if "%%F"=="vp8" (
ffmpeg -hide_banner -c:v libvpx -i "%%a" -c:v prores_ks -pix_fmt yuva444p10le -profile:v 4444xq -quant_mat hq -c:a aac -q:a 5 "%%~dpna_PRORES.mov"
) else (
if "%%F"=="vp9" (
ffmpeg -hide_banner -c:v libvpx-vp9 -i "%%a" -c:v prores_ks -pix_fmt yuva444p10le -profile:v 4444xq -quant_mat hq -c:a aac -q:a 5 "%%~dpna_PRORES.mov"