Skip to content

Instantly share code, notes, and snippets.

View sailfish009's full-sized avatar

sailfish009

  • freelancer
  • South Korea
View GitHub Profile
@sailfish009
sailfish009 / binary_gcd.cpp
Created April 21, 2019 05:44 — forked from cslarsen/binary_gcd.cpp
Binary gcd algorithm in C++ using iteration and bit shifts
/*
* The binary gcd algorithm using iteration.
* Should be fairly fast.
*
* Put in the public domain by the author:
*
* Christian Stigen Larsen
* http://csl.sublevel3.org
*/
int binary_gcd(int u, int v)
@sailfish009
sailfish009 / ctz_clz.cpp
Created April 20, 2019 08:22 — forked from pps83/ctz_clz.cpp
__builtin_ctz (ctzl, ctzll) and __builtin_clz (clzl, clzll) for Visual Studio
#ifdef _MSC_VER
#include <intrin.h>
static inline int __builtin_ctz(uint32_t x) {
unsigned long ret;
_BitScanForward(&ret, x);
return (int)ret;
}
static inline int __builtin_ctzll(unsigned long long x) {
// https://stackoverflow.com/questions/10956543/gcd-function-in-c-sans-cmath-library
template <typename Number>
Number GCD(Number u, Number v)
{
while (v != 0)
{
Number r = u % v;
u = v;
v = r;
}
https://stackoverflow.com/questions/290227/java-system-currenttimemillis-equivalent-in-c-sharp
private static readonly DateTime Jan1st1970 =
new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long currentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
findContours:
https://docs.opencv.org/2.4.13.4/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html
approxPolyDP:
http://answers.opencv.org/question/71309/how-to-get-the-corners-of-rectangle-shapes/
#include <opencv2/opencv.hpp>
#include "opencv2/core/core.hpp"
https://gudanrkim.blogspot.com/2014/11/how-to-display-opencv-cvmat-to-mfc.html?_escaped_fragment_
void cvShowImageHWND(HWND hwnd, const CvArr* arr)
{
SIZE size = { 0, 0 };
int channels = 0;
// COM Data Types:
// https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/sak564ww(v=vs.90)
using System.Runtime.InteropServices;
namespace COMDLL
{
[Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMyclass
@sailfish009
sailfish009 / c2nasm.bash
Created March 21, 2019 05:47 — forked from abcdabcd987/c2nasm.bash
C to NASM Assembly
#!/bin/bash
# thanks to http://stackoverflow.com/a/20743090
# thanks to https://github.com/diogovk/c2nasm
# install objconv: https://github.com/vertis/objconv
#
# $1: source code
set -e
C_FILE="$1"
BASE_NAME="${C_FILE%.*}"
https://aaronbloomfield.github.io/pdr/book/x86-64bit-ccc-chapter.pdf
http://www.modernescpp.com/index.php/c-17-avoid-copying-with-std-string-view