Skip to content

Instantly share code, notes, and snippets.

View knee-cola's full-sized avatar

knee-cola

View GitHub Profile
#define DEBUG
#ifdef DEBUG
// https://forum.arduino.cc/index.php?topic=46900.0
#define DEBUG_PRINT(str) Serial.println(str);
#define DEBUG_PRINT2(str1, str2) Serial.print(str1); Serial.println(str2);
#else
#define DEBUG_PRINT(str)
#define DEBUG_PRINT2(str1, str2)
#endif
@knee-cola
knee-cola / define-process-shim.js
Created December 5, 2018 09:32
Shim for `process` variable for CDN modules packed as UMD
if(!this.process) {
this.process = {};
}
if(!this.process.env) {
this.process.env = {};
}
if(!this.process.env.NODE_ENV) {
this.process.env.NODE_ENV = "production";
@knee-cola
knee-cola / _README.md
Last active January 23, 2023 14:43
tracking battery usage on Windows laptop

What's this?

This is a script, which tracks charging and discharging time of a Windows powered laptop.

It creates a log file, which contains information about time the laptop spend charging and discharging the battery. The collected information can give you a pretty good idea about the battery life of your laptop.

Here's a sample:

charge=77
@knee-cola
knee-cola / ..README.md
Last active January 18, 2024 11:07
Concentric CSS config for VS Code extensions PostCSS Sorting & Sass Lint

What's this?

This is concentric configuration for PostCSS Sorting an Sass Lint Visual Studio code extensions.

The Sass Lint extension will check if the SCSS file is formated corectly, while PostCSS Sorting will help you automatically fix the property order.

How to install

Step1: First install both VS Code plugins.

var SphereControls = function (camera, domElement, config) {
var self = this;
config = config || {};
domElement = ( domElement !== undefined ) ? domElement : document;
domElement.addEventListener( 'mousedown', onDocumentMouseDown, false );
domElement.addEventListener( 'mousemove', onDocumentMouseMove, false );
domElement.addEventListener( 'mouseup', onDocumentMouseUp, false );
/**
* @author knee-cola / https://github.com/knee-cola
* Original file URL: https://gist.github.com/knee-cola/37875bc4359609b96c9f329cd2a68fa1
*
* This is a spinner/loader built for Three.js platform.
* It can be used to notify user that some resources are being loaded.
* I made it to replace pure CSS spinner, which was displayed in the
* overlay above the 3D animation, since it was slowing down WebGL
*
* How to use:
@knee-cola
knee-cola / ProgressiveImgLoader.js
Last active March 12, 2024 21:33
simple progressive texture image loader for Three.js
/**
* @author knee-cola / https://github.com/knee-cola
* Original file URL: https://gist.github.com/knee-cola/37875bc4359609b96c9f329cd2a68fa1
*/
// This is a simple progressive image loader for Three.js
// It enables the smaller image files to be loaded first,
// before the big texture image is fully loaded.
//
// The images are loaded in the order they are passed
// This function is based on the code found at (the original source doesn't work well)
// http://stackoverflow.com/questions/20774648/three-js-generate-uv-coordinate
//
// She following page explains how UV map should be calculated
// https://solutiondesign.com/blog/-/blogs/webgl-and-three-js-texture-mappi-1/
//
// The following documentation shows what a apherical UV map should look like
// https://threejs.org/examples/#misc_uv_tests
var ThreeUvMapper = {
@knee-cola
knee-cola / ThreeCSG.js
Last active January 12, 2021 09:50 — forked from chandlerprall/ThreeCSG.js
csg.js wrapper for three.js
/*
THREE.CSG
@author Chandler Prall <chandler.prall@gmail.com> http://chandler.prallfamily.com
Wrapper for Evan Wallace's CSG library (https://github.com/evanw/csg.js/)
Provides CSG capabilities for Three.js models.
Provided under the MIT License
*/