Skip to content

Instantly share code, notes, and snippets.

@Ambratolm
Ambratolm / ShadowCaster2DGenerator.cs
Last active February 20, 2023 16:07
Unity 2D Script : Attach this script to a CompositeCollider2D GameObject to quickly auto-generate ShadowCaster2D Childs based on the paths of the composite collider. Pretty handy for Tilemap case in which adding a ShadowCaster2D component just covers the map as whole, not every tile one by one as it is supposed to do. 🙂
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering.Universal;
[RequireComponent(typeof(CompositeCollider2D))]
public class ShadowCaster2DGenerator : MonoBehaviour
{
@Ambratolm
Ambratolm / user_aliases.cmd
Last active September 18, 2022 07:26
Useful Cmder user aliases. To put in the file at "%CMDER_ROOT%\config\user_aliases.cmd".
;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here
;= [Default]
e.=explorer .
gl=git log --oneline --all --graph --decorate $*
@Ambratolm
Ambratolm / copy-acl. ps1
Last active July 12, 2022 02:08
Copy security permissions (access control lists or ACL) from a file or folder to another.
# Open PowerShell with Admin rights
Get-Acl -Path 'C:\Some\Path' | Set-Acl -Path 'C:\Some\Other\Path'
@Ambratolm
Ambratolm / check.js
Last active April 17, 2022 18:25
Simple JavaScript functions wrapper module for common checking of data types.
export const check = {
// Primitives
boolean(value) {
return typeof value === "boolean";
},
number(value) {
return (value) => typeof value === "number" && !isNaN(value);
},
biginit(value) {
@Ambratolm
Ambratolm / comments.sublime-snippet
Last active March 17, 2022 01:10
Special comments snippets for Sublime Text.
<!--
# How to use:
• In Windows, Place the .sublime-sinppet files inside the "%AppData%\Sublime Text\Packages\User" folder.
• "%AppData%" refers commonly to "C:\Users\<WinUserName>\AppData\Roaming".
# Preview:
══════════════════════════════════════════════════════════════════════════════
■ Main-Title (file-name.js)
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
Description.
@Ambratolm
Ambratolm / random.js
Last active February 23, 2022 19:55
Simple random number generation functions. Generate number between two numbers. Min and Max are always included.
// Generate a integer random number between min and max (both inclusives)
function random(min = 0, max = 9) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1) + min);
}
// Generate a random decimal (float) number between min and max (both inclusives)
function randomF(min = 0.0, max = 9.0) {
return Math.random() * (max - min + 1) + min;
@Ambratolm
Ambratolm / milliseconds.js
Created February 23, 2022 19:38
Set of handy functions to convert time to milliseconds. Added to global object to use everywhere.
global.seconds = (seconds) => Number(seconds) * 1e3;
global.minutes = (minutes) => Number(minutes) * 6e4;
global.hours = (hours) => Number(hours) * 3.6e6;
global.days = (days) => Number(days) * 8.64e7;
global.weeks = (weeks) => Number(weeks) * 6.048e8;
global.months = (months) => Number(months) * 2.628e9;
global.years = (years) => Number(years) * 3.154e10;
global.decades = (decades) => Number(decades) * 3.154e11;
global.centuries = () => Number(centuries) * 3.154e12;
global.date = (miliseconds) => new Date(Number(miliseconds));
@Ambratolm
Ambratolm / new-github-repo.bat
Created November 16, 2021 01:32
Create a new private GitHub repository using GitHub CLI.
git init
git add .
git commit -m "Initial Commit"
gh repo create owner/name -d "Repo Description Here" --private -y
git push -u origin main
@Ambratolm
Ambratolm / node-console-clear.js
Last active March 11, 2022 23:51
Clear the console in NodeJS. This adds the method to the console object. So, it can be called via `console.cls()`.
// Method 1
console.cls = function () {
process.stdout.write("\033c"); // or process.stdout.write("\x1Bc");
};
// Method 2
console.cls = function () {
const readline = require("readline");
console.log("\n".repeat(process.stdout.rows));
readline.cursorTo(process.stdout, 0, 0);
@Ambratolm
Ambratolm / open-with-sublime-text-3.bat
Last active February 23, 2022 19:06
Open folders and files with Sublime Text 3 from Windows explorer context menu.
Rem ============================================================================
Rem ■ Open with Sublime Text 3
Rem ----------------------------------------------------------------------------
Rem Open folders and files with Sublime Text 3
Rem from Windows explorer context menu.
Rem ============================================================================
Rem ----------------------------------------------------------------------------
Rem ● Settings
Rem ----------------------------------------------------------------------------