Skip to content

Instantly share code, notes, and snippets.

@lydonchandra
lydonchandra / BilinearInterpolationSSE3.cpp
Created October 6, 2020 11:37
BilinearInterpolationSSE3.cpp
// https://fastcpp.blogspot.com/2011/06/bilinear-pixel-interpolation-using-sse.html
inline Pixel GetPixelSSE3(const Image<Pixel>* img, float x, float y)
{
const int stride = img->width;
const Pixel* p0 = img->data + (int)x + (int)y * stride; // pointer to first pixel
// Load the data (2 pixels in one load)
__m128i p12 = _mm_loadl_epi64((const __m128i*)&p0[0 * stride]);
__m128i p34 = _mm_loadl_epi64((const __m128i*)&p0[1 * stride]);
@lydonchandra
lydonchandra / CSharpSIMD_Benchmark.cs
Created October 5, 2020 17:38
Benchmark array multiplications
//#LINQPad optimize+
public class Bench1
{
private double[] data1;
private double[] data2;
[Params(1_024, 2_048, 4_096)]
public int N;
@lydonchandra
lydonchandra / deedle-nodatime-instant.cs
Created August 17, 2020 05:52
deedle-nodatime-instant.cs
Series<Interval, double> srsNoda = Enumerable
.Range(0, 100)
.Select( idx => {
Instant instant1 = SystemClock.Instance.GetCurrentInstant();
return KeyValue.Create(
new Interval(instant1, instant1.Plus( Duration.FromHours(idx) ) )
, (double)idx );
})
.ToSeries();
@lydonchandra
lydonchandra / ODataV4Test.cs
Created July 8, 2020 19:00
OData V4.0 ComplexType Serialization Test
using Microsoft.OData;
using Microsoft.OData.Edm;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace ConsoleApp1
{
lsblk
sudo growpart /dev/nvme0n1 1
sudo resize2fs /dev/nvme0n1p1
with points as (
select * from (
select st_makepoint(1799,2397,53) as point3d
union
select st_makepoint(1804,2395,53) as point3d
union
select st_makepoint(1807,2397,53) as point3d
union
select st_makepoint(1780,2402,53) as point3d
) as seed
@lydonchandra
lydonchandra / triangleIntersection.js
Created February 8, 2020 18:17
triangleIntersection.js
var VisMan = Symbol.for("VisMan")
var cesiumViewer = () => {
return window[VisMan].cesiumViewer
}
var initCesiumViewer = () => {
if(window.viewer && window.viewer.state && window.viewer.state.viewer) {
window[VisMan].cesiumViewer = window.viewer.state.viewer
} else {
@lydonchandra
lydonchandra / detect_blur_photos.py
Created February 6, 2020 18:24
detect_blur_photos.py
from imutils import paths
import argparse
import cv2
from multiprocessing import Pool, TimeoutError
def ResizeWithAspectRatio(image, width=None, height=None, inter=cv2.INTER_AREA):
dim = None
(h, w) = image.shape[:2]
try {
// get a list of files and directories in the main bundle
RNFS.readDir(NativeModules.RNFetchBlob.DownloadDir) // On Android, use "RNFS.DocumentDirectoryPath" (MainBundlePath is not defined)
.then((result) => {
console.log('GOT RESULT', result);
var promises = []
result.forEach(async (path) => {
console.log("path", path)
@lydonchandra
lydonchandra / getX3d.sql
Last active December 19, 2019 11:38
getX3d.sql
select getX3d( ST_GeomFromText(
'POLYHEDRALSURFACE Z (
((12 0 10, 8 8 10, 8 10 20, 12 2 20, 12 0 10)),
((8 8 10, 0 12 10, 0 14 20, 8 10 20, 8 8 10)),
((0 12 10, -8 8 10, -8 10 20, 0 14 20, 0 12 10))
)'
), ST_GeomFromText(
'POLYHEDRALSURFACE Z (
((12 0 10, 8 8 10, 8 10 20, 12 2 20, 12 0 10)),
((8 8 10, 0 12 10, 0 14 20, 8 10 20, 8 8 10)),