Skip to content

Instantly share code, notes, and snippets.

View RIscRIpt's full-sized avatar

Richard Dzenis RIscRIpt

View GitHub Profile
macro AngleVectors pitch, yaw, roll, fwd, rgt, _up {
virtual at fwd
.forward vec3_s
end virtual
virtual at rgt
.right vec3_s
end virtual
virtual at _up
.up vec3_s
end virtual
@RIscRIpt
RIscRIpt / SSE2_VS_FPU_SIN
Created June 23, 2014 12:35
Benchmark of SSE2 sinus calculation (based on intel's Approximate Math Library) vs FPU fsin instruction
format PE CONSOLE
include 'win32ax.inc'
entry main
pow = 20
section '.code' code readable executable
proc main
@echo off
mode con:lines=32
cd \FASM
set include=C:\FASM\INCLUDE
color 0a
echo Compiling: %*
echo.
echo.
FASM.EXE %*
echo.
@RIscRIpt
RIscRIpt / rect_common_area.c
Created October 13, 2014 19:41
Find common area of two rectangles
#include <stdio.h>
#include <stdlib.h>
#define inline __inline
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
typedef struct {
double x, y;
} point_t;
@RIscRIpt
RIscRIpt / int_sqrt.asm
Last active August 29, 2015 14:07
Calculate integer square root
;EAX - Input
;ECX - Result
mov ecx, -1
mov edx, -1
@@:
add edx, 2
inc ecx
sub eax, edx
jns @b
ret
@RIscRIpt
RIscRIpt / gist:60fa3f3fcbeca5df0730
Created April 1, 2015 09:09
Get Process ID by Name
DWORD GetProcessIdByName(char *name) {
PROCESSENTRY32 pe;
pe.dwSize = sizeof(pe);
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
Process32First(hSnapshot, &pe);
do {
if(!strcmp(pe.szExeFile, name))
break;
} while(Process32Next(hSnapshot, &pe));
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
template<typename T>
class password {
public:
template<typename T>
@RIscRIpt
RIscRIpt / com_munge2.asm
Last active September 13, 2015 15:55
COM_UnMunge2 written in x64/x86 ASM
;64 bit verison
proc INETWorker_Munge buf, len, npacket
mov r13d, r8d
xor eax, eax
not r13d
shr edx, 2 ;div 4
jz @f
.loop:
and al, 0x3F
mov r15d, [rcx]
@RIscRIpt
RIscRIpt / turing_machine.py
Created April 7, 2016 20:28
Turing machine written in PY3, which converts unary number to binary
import os
import numpy as np
from collections import deque
clear = lambda: os.system('cls' if os.name=='nt' else 'clear')
class TuringTape:
def __init__(self, initial_data, empty_symbol):
self.data = deque(initial_data)
self.base_offset = 0
@RIscRIpt
RIscRIpt / arduino_tvremote_n_relay.c
Created April 22, 2016 12:48
Arduino // tv_remote + relay
//https://geektimes.ru/post/255488/
#include <IRremote.h>
#define IR_KEY_POWER 0x807F08F7
#define IR_KEY_MENU 0x807FA857
#define IR_KEY_VOLUME_MORE 0x807F708F
#define IR_KEY_VOLUME_LESS 0x807FF00F
#define IR_KEY_PROGRAM_NEXT 0x807F30CF
#define IR_KEY_PROGRAM_PREV 0x807FB04F