Skip to content

Instantly share code, notes, and snippets.

View thokra's full-sized avatar

Thomas Krampl thokra

View GitHub Profile
@Arnklit
Arnklit / generate_plane.gd
Created March 16, 2022 06:56
Subdivided Plane Set as Lod Levels in Godot 4.0
@tool
extends MeshInstance3D
@export var generate := false:
set(v):
gen_mesh()
@export_range(0, 10) var subdivisions := 5
@export var size := 8.0
@rushilgupta
rushilgupta / GoConcurrency.md
Last active July 11, 2024 12:52
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@cryzed
cryzed / fix-infinality.md
Last active June 24, 2024 02:24
A set of instructions on how to fix the harfbuzz + Infinality issue and restoring good-looking, Infinality-like font rendering.

Disclaimer: Please follow this guide being aware of the fact that I'm not an expert regarding the things outlined below, however I made my best attempt. A few people in IRC confirmed it worked for them and the results looked acceptable.

Attention: After following all the steps run gdk-pixbuf-query-loaders --update-cache as root, this prevents various gdk-related bugs that have been reported in the last few hours. Symptoms are varied, and for Cinnamon the DE fails to start entirely while for XFCE the icon theme seemingly can't be changed anymore etc.

Check the gist's comments for any further tips and instructions, especially if you are running into problems!

Screenshots

Results after following the guide as of 11.01.2017 13:08:

@obonyojimmy
obonyojimmy / keyboardcapture.go
Last active February 21, 2024 10:13
go lang keyboard capture
package main
import (
"fmt"
"syscall"
//~ "time"
"unsafe"
"golang.org/x/sys/windows"
)
@artyom
artyom / bashrc-snippet.bash
Created November 18, 2016 09:47
Show gopher when current working directory is under GOPATH
__pschar () {
IFS=':' read -ra PDIRS <<< "$GOPATH"
for P in "${PDIRS[@]}" ; do
test "${1#$P}" = "$1" || {
printf ""
return
}
done
printf "¶"
}
# MAC manipulators
alias random_mac='sudo ifconfig en0 ether `openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//"`'
alias restore_mac='sudo ifconfig en0 ether YOUR_ORIGINAL_MAC_ADDRESS_GOES_HERE'
@ismasan
ismasan / gist:3804361
Created September 29, 2012 15:32 — forked from mattetti/gist:3798173
async fetching of urls using goroutines and channels
package main
import (
"fmt"
"net/http"
"time"
)
var urls = []string{
"http://pulsoconf.co/",
@TinkerWorX
TinkerWorX / AwesomiumComponent.cs
Created May 13, 2012 22:20
An XNA compatible Awesomium component.
JCPM_MWX.Awesomium.Xna
{
public class AwesomiumComponent : DrawableGameComponent
{
private delegate Int32 ProcessMessagesDelegate(Int32 code, Int32 wParam, ref Message lParam);
private static class User32
{
[DllImport("user32.dll", SetLastError = true)]
internal static extern IntPtr SetWindowsHookEx(Int32 windowsHookId, ProcessMessagesDelegate function, IntPtr mod, Int32 threadId);
@madrobby
madrobby / i18n.coffee
Created November 14, 2011 15:45
Backbone i18n with CoffeeScript
# before this file is loaded, a locale should be set:
#
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
#
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
@bradly
bradly / deploy.rake
Created July 27, 2011 03:58
Simple Rails Deployments with Net/SSH
require 'net/ssh'
desc "Deploy site to production"
task :deploy => :environment do
host = 'yourhost.com'
user = 'username'
options = {:keys => '~/.ssh/keys/yourserver.pem'}
remote_path = '/path/to/rails_app'
commands = [