Skip to content

Instantly share code, notes, and snippets.

@bitnenfer
bitnenfer / infix-to-postfix.js
Last active August 29, 2015 14:09
This is a infix to postfix expression translator.
/*
* This was created out of my own study
* of lexical analysis and expression
* parsing.
*
* Demo at: http://dev.shin.cl/infixtopostfix/
*
* @author Felipe Alfonso
*/
(function (scope) {
@bitnenfer
bitnenfer / parser.js
Created November 11, 2014 00:44
Simple Arithmetic Lexer, Expression Parser & Tree Generator
/*
* This was created out of my own study
* of lexical analysis and expression
* parsing.
*
* Demo at: http://dev.shin.cl/binaryexpression/
*
* @author Felipe Alfonso
*/
var NUMS = '0123456789',
@bitnenfer
bitnenfer / sqrt.c
Created December 14, 2014 08:46
Square Root
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PRECISION 0.00001f
double SQRT (double input);
double SQRT_PREC (const double *input, double precision);
int main (int argc, char **argv) {
@bitnenfer
bitnenfer / SortComponent.cs
Last active August 29, 2015 14:15
Unity Rendering Sorting Layer
using UnityEngine;
using System.Collections;
namespace SortingOrder
{
[RequireComponent(typeof(Renderer))]
public class SortComponent : MonoBehaviour { }
}
@bitnenfer
bitnenfer / jekyll_win32_setup.py
Created February 11, 2016 14:35
Jekyll setup script wirtten in pyhton.
# Jekyll setup for windows
# it just follows the instructions
# from this website: http://jekyll-windows.juthilo.com/
# If you prefer doing it manually, just visit
# the previous website.
#
# author: Felipe Alfonso
# url: http://voidptr.io/
import urllib
struct mat4
{
float data[16];
};
mat4 mat4_add(mat4& lhs, mat4& rhs)
{
float *dat_l = lhs.data;
float *dat_r = rhs.data;
mat4 result;
result.data[0] = dat_l[0] + dat_r[0]; result.data[1] = dat_l[1] + dat_r[1];
result.data[2] = dat_l[2] + dat_r[2]; result.data[3] = dat_l[3] + dat_r[3];
result.data[4] = dat_l[4] + dat_r[4]; result.data[5] = dat_l[5] + dat_r[5];
result.data[6] = dat_l[6] + dat_r[6]; result.data[7] = dat_l[7] + dat_r[7];
struct mat4
{
union alignas(16)
{
struct
{
float
a, b, c, d,
e, f, g, h,
i, j, k, l,
inline static void sse_mat4_add(__m128* m0, __m128* m1, __m128* dst)
{
__asm
{
// First load the args addresses
// into ecx, edx and edi registers.
mov ecx, m0
mov edx, m1
mov edi, dst
// Do a an aligned move of m0
mat4 m0;
mat4 m1;
sse_mat4_add(m0.sse_data, m1.sse_data, m0.sse_data);