Skip to content

Instantly share code, notes, and snippets.

Mārtiņš Možeiko mmozeiko

  • San Jose, CA
Block or report user

Report or block mmozeiko

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ctime.c
/* ========================================================================
$File: tools/ctime/ctime.c $
$Date: 2016/05/08 04:16:55PM $
$Revision: 7 $
$Creator: Casey Muratori $
$Notice:
The author of this software MAKES NO WARRANTY as to the RELIABILITY,
SUITABILITY, or USABILITY of this software. USE IT AT YOUR OWN RISK.
@mmozeiko
mmozeiko / webcam_capture.c
Created Aug 28, 2019
Capture webcam device with Media Foundation API
View webcam_capture.c
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <stdio.h>
#include <intrin.h>
@mmozeiko
mmozeiko / win32_crt_float.cpp
Last active Sep 13, 2019
Visual C/C++ CRT functionality
View win32_crt_float.cpp
extern "C"
{
int _fltused;
#ifdef _M_IX86 // following functions are needed only for 32-bit architecture
__declspec(naked) void _ftol2()
{
__asm
{
@mmozeiko
mmozeiko / floor.c
Last active Sep 3, 2019
various floor functions with SSE1 or SSE2
View floor.c
// various SSE1 and SSE2 floor function for float
// assumes only normal input values
// does not handle NAN or INF - they may or may not work
// only guarantee is that 0, subnormal or normal float values will work
#include <emmintrin.h>
#ifdef _MSC_VER
#include <intrin.h>
#define NOINLINE __declspec(noinline)
@mmozeiko
mmozeiko / main.cpp
Created Feb 13, 2019
Windows drag & drop example
View main.cpp
/*
Minimal Drag and Drop Application for Windows
Copright (C) Alexandre LHUILLIER - 2019
===
This application creates an application window and a console window.
Whenever you drag a file or a set of files from the Windows explorer
to the application window, the absolute paths of the dropped files
are printed in the console window.
@mmozeiko
mmozeiko / incbin.c
Last active Sep 1, 2019
Include binary file with gcc
View incbin.c
#include <stdio.h>
#define STR2(x) #x
#define STR(x) STR2(x)
#define INCBIN(name, file) \
__asm__(".section .rodata\n" \
".global incbin_" STR(name) "_start\n" \
".type incbin_" STR(name) "_start, @object\n" \
".balign 16\n" \
@mmozeiko
mmozeiko / build.bat
Created Dec 18, 2016
build.bat with caching
View build.bat
@echo off
setlocal EnableDelayedExpansion
set ARCH=amd64
set BUILD_CACHE=%~dp0\_build_cache.cmd
if exist "!BUILD_CACHE!" (
call "!BUILD_CACHE!"
) else (
call "%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" !ARCH!
@mmozeiko
mmozeiko / hook.c
Last active Aug 13, 2019
reads process stdout + stderr and prints it out as it becomes available
View hook.c
// compile this to hook.dll
// for example, with MSVC: cl.exe /LD /MT /O2 hook.c /Fehook.dll
#include <windows.h>
// get this from https://github.com/kubo/plthook
#include "plthook_win32.c"
static plthook_t* hook;
@mmozeiko
mmozeiko / test.c
Last active Aug 1, 2019
gtk widget from x11 window
View test.c
// gcc test.c `pkg-config --cflags --libs gtk+-3.0 gdk-3.0` -lX11 && ./a.out
#include <X11/Xlib.h>
#include <unistd.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
static void my_gtk_realize(GtkWidget* widget, gpointer user)
You can’t perform that action at this time.