Skip to content

Instantly share code, notes, and snippets.

@carlopi
carlopi / cheerp_jit.cpp
Created March 21, 2021 19:47
Skeleton of Jit implementation with Cheerp
namespace [[cheerp::genericjs]] client {
//forward declare a bunch of JavaScript APIs existing on the browser
namespace WebAssembly {
public:
Promise* instantiate(ArrayBuffer* code, ImportObject* imports);
};
}
[[cheerp::genericjs]] void onSuccess(ModuleAndInstance* res) {
auto start_function = res->get_instance()->get_start_function();
@eikendev
eikendev / walsh-hadamard-transform.cpp
Created April 12, 2020 20:10
Walsh-Hadamard transform using SIMD intrinsics
#include <immintrin.h>
#define NR (8) // Number of rows.
#define MR (75) // Number of columns.
static const inline __m256d transform1a(__m256d a, __m256d b)
{
const __m256d ret = _mm256_add_pd(a, b);
return ret;
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
@ayamflow
ayamflow / gist:96a1f554c3f88eef2f9d0024fc42940f
Last active May 15, 2024 12:37
Threejs Fit plane to screen
var cameraZ = camera.position.z;
var planeZ = 5;
var distance = cameraZ - planeZ;
var aspect = viewWidth / viewHeight;
var vFov = camera.fov * Math.PI / 180;
var planeHeightAtDistance = 2 * Math.tan(vFov / 2) * distance;
var planeWidthAtDistance = planeHeightAtDistance * aspect;
// or
@androidfred
androidfred / javafx.md
Last active October 27, 2021 03:21
java.lang.ClassNotFoundException: javafx.util.Pair

java.lang.ClassNotFoundException: javafx.util.Pair happens because javafx.util.Pair and other classes from javafx.util are not included in OpenJDK. Options for resolving:

Switch class

Map.Entry<K, V> from java.util is similar to javafx.util.Pair.

Install java-openjfx

Install java-openjfx through your package manager. (or whatever means you used to install Java on your machine) Note that java-openjfx is compatible with OpenJDK8, not previous versions.

After installing java-openjfx, you may have to add it manually to your IDE SDK classpath. Eg in IntelliJ, you may have to go to Project Structure | SDKs | <select your SDK> | Classpath | + (the Classpath +, not the SDKs +) | and add /usr/lib/jvm/java-8-openjdk/jre/lib/ext/jfxrt.jar (which should be there now that java-openjfx has been installed) | OK

@tea
tea / NvEncoderPerf.cpp
Created April 25, 2016 11:14
nvenc sample
////////////////////////////////////////////////////////////////////////////
//
// Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
//
// Please refer to the NVIDIA end user license agreement (EULA) associated
// with this source code for terms and conditions that govern your use of
// this software. Any use, reproduction, disclosure, or distribution of
// this software and related documentation outside the terms of the EULA
// is strictly prohibited.
//
@codecontemplator
codecontemplator / gausselimination.js
Created May 30, 2015 14:13
Example implementation of gauss elimination in javascript
function print(M, msg) {
console.log("======" + msg + "=========")
for(var k=0; k<M.length; ++k) {
console.log(M[k]);
}
console.log("==========================")
}
function diagonalize(M) {
var m = M.length;