Skip to content

Instantly share code, notes, and snippets.

View JakubNei's full-sized avatar

Jakub Nei JakubNei

View GitHub Profile
@galek
galek / pbr.glsl
Created November 4, 2015 11:10
PBR GLSL SHADER
in vec2 v_texcoord; // texture coords
in vec3 v_normal; // normal
in vec3 v_binormal; // binormal (for TBN basis calc)
in vec3 v_pos; // pixel view space position
out vec4 color;
layout(std140) uniform Transforms
{
mat4x4 world_matrix; // object's world position
@nobnak
nobnak / Quaternion.cginc
Last active April 16, 2021 09:21
Quaternion Calculation for Unity
#ifndef __QUATERNION__
#define __QUATERNION__
#define HALF_DEG2RAD 8.72664625e-3
float4 quaternion(float3 normalizedAxis, float degree) {
float rad = degree * HALF_DEG2RAD;
return float4(normalizedAxis * sin(rad), cos(rad));
}
float4 qmul(float4 a, float4 b) {
@jackfarrington
jackfarrington / ReverseComparer.cs
Created September 11, 2015 18:37
C# Generic Reverse Comparer (IComparer<T>)
using System.Collections.Generic;
namespace Gist
{
public sealed class ReverseComparer<T> : IComparer<T>
{
public static readonly ReverseComparer<T> Default = new ReverseComparer<T>(Comparer<T>.Default);
public static ReverseComparer<T> Reverse(IComparer<T> comparer)
{
@andresfelipemendez
andresfelipemendez / Controller.cs
Last active January 21, 2016 03:37
Quacopter Controller
void Awake ()
{
hover = (body.mass * Physics.gravity.y) / -4;
}
void FixedUpdate ()
{
// compensate the spring in the controller to simulate the thortle without the spring in a real quadcopter controller
float thrust = hover + (Input.GetAxis ("Throttle") * throttle);
// FR front right
@krusynth
krusynth / dataTables_patch.js
Created January 13, 2015 04:00
dataTables.js requires you to have "good" tables. If your table has an uneven number of columns per row, and you're getting the dreaded " Cannot read property 'mData' of undefined " this will fix it.
// dataTables.js is great! But it requires you to have "good" tables in
// the first place. If your table has an uneven number of columns per
// row, and you're getting the dreaded "Cannot read property
// 'mData' of undefined" this'll fix it. If you're missing a thead or
// tbody you'll get that error too - this won't fix that!
$(document).ready(function() {
// We need to make sure every row in our table has the same number of columns.
// Otherwise dataTable doesn't work.
$('table').each(function(i, elm) {
@chales
chales / db-connect-test.php
Last active June 3, 2023 01:01
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@aksakalli
aksakalli / SimpleHTTPServer.cs
Last active May 11, 2024 03:22
SimpleHTTPServer in C#
// MIT License - Copyright (c) 2016 Can Güney Aksakalli
// https://aksakalli.github.io/2014/02/24/simple-http-server-with-csparp.html
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.IO;
@dvsqz
dvsqz / carousel-indicators.js
Last active April 13, 2022 12:11
Auto-generate Bootstrap Carousel Indicator HTML
@madneon
madneon / index.html
Last active December 28, 2015 18:39
Haxe: index.html - simple .swf embed
<html>
<head>
<title>SyntaXe</title>
<style>
* {
margin: 0;
padding: 0;
}
</style>
</head>
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Last active April 30, 2024 08:05
Unity extension methods for computing a ConfigurableJoint.TargetRotation value from a given local or world rotation.
using UnityEngine;
public static class ConfigurableJointExtensions {
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
if (joint.configuredInWorldSpace) {