Skip to content

Instantly share code, notes, and snippets.

View Andrei15193's full-sized avatar

Andrei Fangli Andrei15193

View GitHub Profile
@Andrei15193
Andrei15193 / page1.html
Last active April 10, 2024 12:34
Location Replace/Assign Sample
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page 1</title>
<style>
body {
padding: 10px;
@Andrei15193
Andrei15193 / Pawn.cs
Last active August 6, 2023 00:37
sbox / Detect Touch Events for ModelEntity
public partial class Pawn : AnimatedEntity
{
public override void Spawn()
{
SetModel( "models/citizen/citizen.vmdl" );
SetupPhysicsFromModel( PhysicsMotionType.Keyframed );
// Or anything else.
// If an entity has no tags then it will default to collide.
Tags.Add( "player" );
}
@Andrei15193
Andrei15193 / entry1.js
Created March 28, 2023 09:06
Webpack Circular Dependency
import "./module1";
// import "./module2"; Importing this instead of module1 will generate a runtime Error
/*
Hi, from what I checked, the issue about circular dependencies appears
when there is code that is being executed when a module is being imported,
e.g.: function calls, const referencing each other, class inheritance, and so on.
See the following files:
* entry1.js
@Andrei15193
Andrei15193 / accurate-rounding-in-javascript.js
Last active January 17, 2023 17:06
Test JavaScript Rounding
const maximumNumberOfDecimals = 5;
const targetDecimals = 2;
const roundingAdjustment = 3;
// The more maximum number of decimals, the higher this needs to go for accurate results
// It looks like targetDecimals + roundingAdjustment = maximumNumberOfDecimals for fully accurate results
var results = [];
for (
let value = 1 / Math.pow(10, maximumNumberOfDecimals);
value <= 100;