Skip to content

Instantly share code, notes, and snippets.

View gabonator's full-sized avatar
👨‍🏭
at work

Gabriel Valky gabonator

👨‍🏭
at work
View GitHub Profile
@gabonator
gabonator / spipe.cpp
Created April 26, 2012 13:13
Socket connector - double server
// spipe.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
//#include <signal.h>
BOOL m_bRunning = FALSE;
class CNetwork {
public:
@gabonator
gabonator / Tables.cpp
Created April 26, 2012 13:16
Layout tables
#include <pch.h>
#include "Tables.h"
#define foreach(decl) for ( decl = m_pListFirst; pElement; pElement = pElement->m_pNext )
/*virtual*/
void CTableWnd::GetClientRect( LPRECT prcRect )
{
_ASSERT(prcRect);
CRect *pRect = (CRect*) prcRect;
@gabonator
gabonator / usb.cpp
Created April 26, 2012 13:19
USB enumerating tools
#include "usb.h"
#ifndef DISABLE_USB
#pragma comment(lib, "setupapi.lib")
#include "SetupAPI.h"
#include "cfgmgr32.h"
#pragma pack(4)
@gabonator
gabonator / TimeZonesDlg.cpp
Created April 26, 2012 13:53
Timezones export
// TimeZonesDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TimeZonesMFC.h"
#include "TimeZoneDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
@gabonator
gabonator / ft.cpp
Created May 3, 2012 14:05
discrete Fourier transform
// fourier.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <math.h>
#include <iostream>
using namespace std;
//#include <windows.h>
typedef float FLOAT;
@gabonator
gabonator / exceptions.cpp
Created May 8, 2012 18:40
Windows CE stack dumping
void DeviceExceptionHandler( void *pep )
{
if ( !_DeviceExceptionHandler((LPEXCEPTION_POINTERS)pep) )
{
MessageBox(NULL, _T("Cannot generate dumpreport!"), _T("Illegal operation report"), MB_OK);
}
}
#include <Tlhelp32.h>
#include <vector>
@gabonator
gabonator / clip.cpp
Created July 3, 2012 12:06
Line to rectangle clipping
//http://stackoverflow.com/questions/99353/how-to-test-if-a-line-segment-intersects-an-axis-aligned-rectange-in-2d
enum {
OUT_LEFT = 1,
OUT_TOP = 2,
OUT_RIGHT = 4,
OUT_BOTTOM = 8
};
INT _ThroughCode(LONGPOSITION pt)
@gabonator
gabonator / intersect.cpp
Created July 3, 2012 12:09
Two lines intersection
LIB_INLINE BOOL32 CMath::MathRayIntersect ( POINT A1, POINT A2, POINT B1, POINT B2, POINT *lpResult )
{
INT dx1 = A2.x - A1.x;
INT dy1 = A2.y - A1.y;
INT dx2 = B2.x - B1.x;
INT dy2 = B2.y - B1.y;
DOUBLE q = (dx1 * dy2) - (dy1 * dx2);
if (abs(q) < 0.0001) q = 0.0001;
@gabonator
gabonator / ahoj.txt
Created October 21, 2012 20:06
Google speech api with non-english language
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Disposition: attachment
Date: Sun, 21 Oct 2012 20:03:54 GMT
Expires: Sun, 21 Oct 2012 20:03:54 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
@gabonator
gabonator / half_inverse_sphere.html
Created June 15, 2013 07:41
CNC code that cuts half-sphere hole into plastic/wooden cube & that cuts half sphere out of cube, could be used for making mold for Ferrero Rafaello wafer :)
<html>
<body>
<pre id="console">
</pre>
<script language="javascript">
function log(s)
{
if ( typeof(s) == "string" )
document.getElementById("console").innerHTML += s + "\n";