Instantly share code, notes, and snippets.

View fibersTest.cpp
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#include <array>
#include <algorithm>
void printStack( const char* what )
{
View memcpy.asm
page ,132
title memcpy - Copy source memory bytes to destination
;***
;memcpy.asm - contains memcpy and memmove routines
;
; Copyright (c) Microsoft Corporation. All rights reserved.
;
;Purpose:
; memcpy() copies a source memory buffer to a destination buffer.
; Overlapping buffers are not treated specially, so propogation may occur.
View ChineseDecode.cs
using System;
using System.Text;
using System.IO;
namespace ChineeseDecode
{
class Program
{
static void main( string path )
{
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 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 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 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 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 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 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;