Skip to content

Instantly share code, notes, and snippets.

View Bambofy's full-sized avatar
Drinking coffee and coding!

Richard Bamford Bambofy

Drinking coffee and coding!
  • England
  • 16:37 (UTC +01:00)
View GitHub Profile
@Bambofy
Bambofy / tracing.lua
Created April 22, 2012 20:09
Just a simple set of functions for 2D tracing.
function PointWithinShape(shape, tx, ty)
if #shape == 0 then
return false
elseif #shape == 1 then
return shape[1].x == tx and shape[1].y == ty
elseif #shape == 2 then
return PointWithinLine(shape, tx, ty)
else
return CrossingsMultiplyTest(shape, tx, ty)
end
@Bambofy
Bambofy / utilx.lua
Created April 24, 2012 19:03
UtilX - A collab lua gmod function library.
-----------------------------------
-- utilx
-- A project stared by Gbps
-- expanded with community input
-----------------------------------
utilx = {}
utilx.Version = 1.0
--------------------
@Bambofy
Bambofy / randstrgen.py
Created May 20, 2012 10:11
Python random string generator
from random import choice
import string
chars = string.letters + string.digits # Python 2
chars = string.ascii_letters + string.digits # Python 3
rand_name = lambda x: ''.join(choice(chars) for i in range(x))
@Bambofy
Bambofy / gist:4349283
Created December 20, 2012 22:49
reddit reddit reddit
-- sb_row.lua
---- Scoreboard player score row, based on sandbox version
include("sb_info.lua")
local GetTranslation = LANG.GetTranslation
local GetPTranslation = LANG.GetParamTranslation
@Bambofy
Bambofy / timelapse.sh
Created March 20, 2013 07:15
Simple .sh to create image files of your desktop and place them in the current working directory every 60 seconds. Macs.
while true ; do sleep 60 && echo `date`‘ Capturing screenshot…’ && screencapture -C -m -t jpg -x -f cap.`date +%s`.jpg ; done
@Bambofy
Bambofy / loopingImages.cs
Created March 24, 2013 14:25
How to loop through an image and get the values of each pixel FAST!
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
using System.IO;
namespace Gignus
{
class Program
{
@Bambofy
Bambofy / conwaysgameoflife
Created September 11, 2013 10:16
Conways GOL WIP
// Conways game of life.
// init array
var arr = [];
for (var x = 1; x < 11; x++)
{
arr[x] = [];
for (var y = 1; y < 11; y++)
{
arr[x][y] = new Rect((x-1)*32, (y-1)*32, 32, 32).fill("black");
function bubbleSort( L )
local newL = {}
for k,v in pairs( L ) do
if (k+1) > tableLength( L ) then -- end of the array
newL[k] = L[k]
break
end
if L[k] > L[k+1] then
@Bambofy
Bambofy / encoderdecoder
Created October 24, 2013 15:20
Simple encoding/decoding in Lua
local datetime = os.date("*t");
local function convert( chars, dist, inv )
return string.char( ( string.byte( chars ) - 32 + ( inv and -dist or dist ) ) % 95 + 32 )
end
local function crypt(str, k, inv)
local enc= "";
for i=1,#str do
if (#str-k[5] >= i or not inv) then
@Bambofy
Bambofy / ConverterFunction
Created December 27, 2013 12:55
Converting String to Keyboard.Key (SFML C#)
public Keyboard.Key ConvertFromString(string keystr)
{
return (Keyboard.Key) Enum.Parse(typeof (Keyboard.Key), keystr);
}