Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am hamcha on github.
  • I am hamcha (https://keybase.io/hamcha) on keybase.
  • I have a public key whose fingerprint is 35DD CAF8 2452 CFA6 B102 9AF3 5486 840A F825 0D9A

To claim this, I am signing this object:

@Hamcha
Hamcha / money.hs
Last active August 29, 2015 14:04
Simple and explained Haskell app which does a very simple job: Count the minimum required coins to get a specific sum
-- If you have Haskell -> ghc money.hs && ./money
module Main where
-- We use Decimal because it provides us with decent floating point arithmetic.
-- Using IEEE 754 (Float) math is bad when we're talking money!
import Data.Decimal
-- All the kinds of notes and coins we have at our disposal
@Hamcha
Hamcha / devil.go
Last active March 14, 2017 02:47
Devil Traumae nick generator, based on @pedrox's exploit
// http://events.ccc.de/congress/2011/Fahrplan/attachments/2007_28C3_Effective_DoS_on_web_application_platforms.pdf
// Original by pedrox (https://gist.github.com/pedrox/eb8d674bf2b8be63da0f)
package main
import (
"fmt"
"math/rand"
"strconv"
)
@Hamcha
Hamcha / override.css
Last active August 29, 2015 14:01
Hamcha PHPBB style override
/* Global */
@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic);
* {
color: #333;
}
#logo, .forum-image, .headerbar, .servizi img {
display: none;
@Hamcha
Hamcha / CameraTracking.cs
Created February 3, 2014 22:00
Unity3D Top down (2D) Weighed Camera
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CameraTracking : MonoBehaviour
{
public struct CameraObject
{
public GameObject Object;
public float Weight;
@Hamcha
Hamcha / fdoc.md
Last active January 2, 2016 11:19
Speedcoding library

Speedcoding library

Functions

init()

Initializes the canvas element and fires up the render loop.

Default canvas size is 600x600, you can override it by calling init(true) to make it fill the screen or init(w,h) for a custom width (w) and height (h).

clear() , clearp(a)

@Hamcha
Hamcha / log.go
Last active January 1, 2016 01:09
Logsrv ported from Coffeescript (Node.JS) to Go trying to reduce Memory usage - Node.js version: 26.5MiB - Go version: 3.7MiB
package main
import (
"io/ioutil"
"net/http"
"html/template"
)
type ChatLog struct {
Content string
@Hamcha
Hamcha / Sprite2D.cs
Last active April 26, 2023 16:01
Stupid Unity scripts: 2D Billboards with perspective camera.
using UnityEngine;
using System.Collections;
public class Sprite2D : MonoBehaviour {
public Camera gameCamera;
private float initialRotation;
void Start()
{
@Hamcha
Hamcha / SmoothFollow.cs
Created July 28, 2013 00:45
Stupid Unity scripts : "Smooth Follow" from Standard Assets
// Smooth Follow from Standard Assets
// Converted to C# because I fucking hate UnityScript and it's inexistant C# interoperability
// If you have C# code and you want to edit SmoothFollow's vars ingame, use this instead.
using UnityEngine;
using System.Collections;
public class SmoothFollow : MonoBehaviour {
// The target we are following
public Transform target;
uniform vec2 resolution;
uniform float lowFreq, midFreq, highFreq;
uniform float time;
uniform vec2 mouse;
void rX(inout vec3 p, float a) { float c,s;vec3 q=p; c = cos(a); s = sin(a); p.y = c * q.y - s * q.z; p.z = s * q.y + c * q.z; }
void rY(inout vec3 p, float a) { float c,s;vec3 q=p; c = cos(a); s = sin(a); p.x = c * q.x + s * q.z; p.z = -s * q.x + c * q.z;}
float star(vec3 p, float s) { return length(p)-s; }
float starfield(vec3 p, float s, vec3 c) { vec3 q = mod(p,c)-.5*c; return star(q,s); }