Skip to content

Instantly share code, notes, and snippets.

View gyakoo's full-sized avatar

Manu Marin gyakoo

View GitHub Profile
@gyakoo
gyakoo / gist:a76747aeb2fdf9f7203db426a94b1929
Created October 17, 2016 22:00 — forked from jesusdesantos/gist:5371743
A benchmark for several allocators used in Noesis
------------------------------------------------------------------------
Memory Allocator perfomance benchmark
------------------------------------------------------------------------
local_n = n threads allocating and deallocating random blocks of max
size. Deallocations always happening in the same thread that
the corresponding allocation.
share_n = n threads allocating and deallocating random blocks of max
size from a shared list. Deallocation may happen in different
thread that the allocation one
@gyakoo
gyakoo / uwp_changeToFullscreen.cpp
Last active April 2, 2018 00:47
UWP C++ Fullscreen snippet
// Made this code to change to fullscreen, useful if you're creating a DX application in vs2015/c++/uwp
// Also look at this sample: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/FullScreenMode/cpp
// And this MSDN page: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.viewmanagement.applicationview.preferredlaunchwindowingmode?cs-save-lang=1&cs-lang=cpp#code-snippet-1
// preferred mode in constructor
App::App()
{
// starts with this window size
Windows::UI::ViewManagement::ApplicationView::PreferredLaunchViewSize= Windows::Foundation::Size(800,600);
Windows::UI::ViewManagement::ApplicationView::PreferredLaunchWindowingMode = Windows::UI::ViewManagement::ApplicationViewWindowingMode::PreferredLaunchViewSize;
}
@gyakoo
gyakoo / ssecheck.cpp
Created August 11, 2016 17:40 — forked from hi2p-perim/ssecheck.cpp
Check SSE/AVX instruction support.
/*
Check SSE/AVX support.
This application can detect the instruction support of
SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, SSE4a, SSE5, and AVX.
*/
#include <iostream>
#ifdef _MSC_VER
#include <intrin.h>
#endif
@gyakoo
gyakoo / rectSAT.py
Created June 28, 2016 00:25
Returns a tuple with 1st as axis with bigger distance (0=x,1=y) and 2nd as the bigger separating distance.
def rectSAT(r0,r1):
'''Returns a tuple with 1st as axis with bigger distance (0=x,1=y)
and 2nd as the bigger separating distance.
If tuple[1]<0 there's penetration. If tuple[1]>0 no penetration.
Assumes Y grows down the screen.'''
# vertical edges
if r0.left > r1.left: r0,r1 = r1,r0 # assume r0 is always on left
sepX = r1.left - r0.right
if r0.top > r1.top: r0,r1=r1,r0 # assume r0 is always on top
sepY = r1.top - r0.bottom
@gyakoo
gyakoo / Program.cs
Created February 25, 2016 23:29
Download all Tickets and Attachments from Parature for a given Account in HTML format.
// This program downloads all tickets from Parature using Parature SDK you can find here:
// https://github.com/Parature/ParatureSDK
// Create a c# project like the Parature SDK - Exercises.csproj and put this code.
// You must fill your credentials in the .config file
// It will create a folder for every ticket that will contain the text with details in html format
// and the attachment files.
// It also will create a table of content for all downloaded tickets.
// To build, download the ParatureSDK and override one of the examples with this program.
@gyakoo
gyakoo / makeHash.cpp
Created February 24, 2016 19:41
Variadic template function to make a hash using std::hash and combining them
// recursive variadic template hash
// base case
template<typename T>
std::size_t makeHash(const T& v)
{
return std::hash<T>()(v);
}
// recursive variadic template hash
template<typename T, typename... Args>
@gyakoo
gyakoo / socket.c
Created October 21, 2015 18:34 — forked from nolim1t/socket.c
HTTP Request in C using low level write to socket functionality
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
@gyakoo
gyakoo / EnumerateFilterCategories.cpp
Last active October 8, 2015 15:08
Code to print all filter categories supported in DirectShow
// -----------------------------------------------------------------
// Enumerate all objects in this category, printing the name
// -----------------------------------------------------------------
void enum_cat(REFGUID cat)
{
HRESULT hr;
ICreateDevEnum *pSysDevEnum = NULL;
IEnumMoniker *pEnum = NULL;
IMoniker *pMoniker = NULL;
VARIANT var;
@gyakoo
gyakoo / ReadImageAttr.cc
Last active August 31, 2015 14:23
Inspects header of the image file and returns the width, height, depth and size in bytes Suppoted formats: dds, sgi rgb, jpg, png, tga, bmp
/*
Inspects header of the image file and returns the width, height, depth and size in bytes
Suppoted formats: dds, sgi rgb, jpg, png, tga, bmp
You have to provide the implementation for:
* _swap16/32: Is a byte order swap for little endian platforms, because most of the formats are in network order (big endian).
* ExtensionIs: Returns true if the filename has the passed extension
Note: For the DDS format, if the depth is negative, then it specifies the compression format. -1 for DXT1, -2 for DXT2 and so on.
Note: ImgAttr might be removed and passing width/height/depth/size as out parameters of the function.
@gyakoo
gyakoo / ReportLiveObjects.cpp
Created August 25, 2015 20:42
Snippet to report all resource leaks in DX11
ID3D11Debug* pDebug=NULL;
HRESULT hr=m_pDevice->QueryInterface(__uuidof(ID3D11Debug), (void**)&pDebug);
m_pDevice->Release(); // report after device release (?)
if (SUCEEDED(hr))
{
pDebug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);
}