Skip to content

Instantly share code, notes, and snippets.

Konstantin Const-me

Block or report user

Report or block Const-me

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 Capstone.DisasmEx.cs
using Gee.External.Capstone;
using Gee.External.Capstone.X86;
using System;
using System.Collections.Generic;
using System.Linq;
namespace InstructionsCheck
{
/// <summary>This class implements a way to disassemble real-life modules with Capstone.</summary>
/// <remarks>Real-life x86 and amd64 code contains inline data.
@Const-me
Const-me / SinCosMicrobench.cpp
Created Jul 25, 2016
A benchmark comparing three methods of sine + cosine computation: stdlib, DirectX which is 10-11 degree polynomial approximation, and linearly-interpolated lookup table.
View SinCosMicrobench.cpp
#include "stdafx.h"
using std::vector;
typedef std::chrono::high_resolution_clock stopwatch;
using namespace DirectX;
using std::array;
struct StdLib
{
inline void sinCos( float val, float& s, float& c ) const
View ffx.cpp
#include "stdafx.h"
int f( int x )
{
if( 0 == x )
return 0;
if( 0x80000000 == x )
return 0x80000001;
const int c = ( ( x >> 31 ) & 1 ) * -2 + 1;
const int mul = ( x & 1 ) * 2 - 1;
View set-count.cpp
#include <unordered_set>
#include <chrono>
using stopwatch = std::chrono::high_resolution_clock;
static const size_t count = 4 * 1024 * 1024;
void setup( std::unordered_set<size_t>& set )
{
srand( 0 );
for( size_t i = 0; i < count; i++ )
View SinCosAngle.cpp
#define _USE_MATH_DEFINES
#include <math.h>
struct Point
{
double x, y;
};
// A class that contains a 2D angle as a pair of sine + cosine values.
// Sometimes, this approach saves substantial CPU time that would be wasted running these trigonometry functions.
View shared-ptr-example.cpp
#include <stdint.h>
#include <string>
#include <vector>
#include <array>
#include <memory>
// Can be hundreds of megabytes in these vectors
class Mesh
{
std::string name;
View FixEncoding.cs
// (c) 2018 const.me
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement.
// In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or
View SyncTest.cs
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ThreadsTest
{
static class Program
{
static readonly object syncRoot = new object();
static readonly int[] array = new int[] { 1,2,3,4,5,6 };
View Lines.cs
using System.Windows;
// Base class for lines
abstract class LineBase
{
// First and second point of the line
public readonly Point p0, p2;
public override string ToString()
{
View ChineseDecode.cs
using System;
using System.Text;
using System.IO;
namespace ChineeseDecode
{
class Program
{
static void main( string path )
{
You can’t perform that action at this time.