Skip to content

Instantly share code, notes, and snippets.

View blewert's full-sized avatar
:electron:
back to electron!

Benjamin Williams blewert

:electron:
back to electron!
View GitHub Profile
%% Benjamin Williams <[email protected]>
%% Get in touch if you have any questions or problems!
%% University of Lincoln Computer Science Thesis Template
% The document class -- remove [harvard] if you want
% numeric-style referencing.
\documentclass[harvard]{lincolncsthesis}
% Custom packages that you need to include
\input{preamble/packages.tex}
\def\@classname {lincolncsthesis}
\def\ifClassOption [#1]#2 {
\@ifclasswith{\@classname}{#1}{#2}{#3}
}
\def\defineThesisOption [#1] {
\ifClassOption [#1] {
\expandafter\def \csname __thesis#1\endcsname ##1{\empty}
Shader "Custom/sail-shader"
{
Properties
{
[Header(Appearance properties)]
_Color ("Color", Color) = (1,1,1,1)
_TintColor ("Tint color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
// _NoiseTex ("Noise Texture (RGB)", 2D) = "white" {}
[KeywordEnum(Normal, Toon)] _ToonShading("Shading mode", Int) = 1
@blewert
blewert / PhysXClock.cpp
Created February 15, 2019 09:01
A clock in PhysX using revolute joints + motors
//Make the minute and hour hands, the shapes
Capsule* minuteHand = new Capsule(PxTransform(PxVec3(0, 8, 0)), PxVec2(0.1f, 2));
Capsule* hourHand = new Capsule(PxTransform(PxVec3(0, 8, 0)), PxVec2(0.1f, 1));
//Turn off gravity
hourHand->Get()->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, true);
minuteHand->Get()->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, true);
//Add them to the scene
Add(hourHand);
@blewert
blewert / convex-mesh-pyramid.cpp
Last active February 5, 2019 08:40
Visualising local axes and velocity in PhysX 3.3.4
std::vector<PxVec3> verts = {
//
PxVec3(0, 1, 0),
PxVec3(-1, -1, 1),
PxVec3(1, -1, 1),
//
PxVec3(0, 1, 0),
PxVec3(-1, -1, 1),
@blewert
blewert / transform-extensions.md
Last active January 27, 2019 13:51
A way to get all components in a transform, including itself & children. Unity.

Unity: Find all components of a type in an object

Tired of writing out GetComponents<Blah>() and then GetComponentsInChildren<Blah>()? Well, here are two functions which do that for you.

To use it, just shove it in some file. Then, do transform.GetAllComponents<Blah>() and voila! You have all components of this type in a nice, enumerable format.

public static class TransformExtensions
{
    public static IEnumerable<T> GetAllComponents<T>(this Transform transform)
    {
@blewert
blewert / get_old_selection_idx.js
Last active November 30, 2018 16:51
Getting old selection indices using seedrandom, and hooking javascript functions
function get_old_selection_idx(seed)
{
Math.seedrandom(+seed);
return Math.floor(Math.random() * 4);
}
@blewert
blewert / sdl_ttf_leak_test.c
Created November 5, 2018 11:17
A file to test if SDL_ttf is leaking memory
#include <iostream>
#include <string>
//--
#include "SDL.h"
#include "SDL_ttf.h"
//--
#include <windows.h>
#include <psapi.h>
#include <iostream>
#include <Windows.h>
#include "PCarsSharedMemory.h"
// Name of the pCars memory mapped file
#define MAP_OBJECT_NAME "$pcars$"
PCarsSharedMemory::PCarsSharedMemory(void)
{
this->game = this->getSharedMemory();
#
# modified slightly from <https://raw.githubusercontent.com/nhempel/Simple-Python-Twitch-IRC-Bot/master/simpleircbot.py>
#
import re
import socket
HOST = "irc.chat.twitch.tv"
PORT = 6667
CHAN = "#dakotaz" # The channel you wanna scrape (this is some random guys stream i found)