Skip to content

Instantly share code, notes, and snippets.

@azrafe7
azrafe7 / elemToSelector.js
Last active November 17, 2023 14:19
ElementToSelector
// create css selector from element
// adapted from https://stackoverflow.com/questions/42184322/javascript-get-element-unique-selector/67840046#67840046
function elemToSelector(elem, options={}) {
const defaults = {compact:false, fullPath:false};
options = {...defaults, ...options};
const {compact, fullPath} = options;
// console.log(options, compact, fullPath);
const tagName = elem.tagName.toLowerCase();
const id = elem.getAttribute('id') ?? '';
@azrafe7
azrafe7 / polyClipExtrude.md
Last active May 26, 2021 00:59
Maya + hxClipper
@azrafe7
azrafe7 / protect.py
Last active December 14, 2022 22:04
protect maya files
# Credits to Farsheed Ashouri (https://www.highend3d.com/maya/script/protect-for-maya)
# Code adapted and improved from there
import maya.cmds as cmds
import zlib
import base64
import hashlib
# SETUP
@azrafe7
azrafe7 / heroku_pydrive_gdrive_upload2folder.md
Created April 25, 2020 21:42
NOTES: heroku + pydrive + GDrive auth + upload to folder
  • setup heroku project
  • setup GDrive auth via cloud console (watch out for slashes when setting up URIs)
  • download client_secrets.json and put it in the local root folder (so PyDrive can use it)
  • gitignore it
  • use CommandLineAuth() instead of LocalWebserverAuth() locally
  • put the relevant secrets in local json files to be used for auth locally
  • test it locally and ensure it all works
  • create secret env keys in heroku with the content of both received jsons
  • be sure to gitignore both json files
  • create a ".profile" that will create the two files from ENV secrets when the docker image is run on heroku
@azrafe7
azrafe7 / nearestPtsBetweenLines.py
Created January 10, 2020 22:38
The shortest line between two lines in 3D (based on http://paulbourke.net/geometry/pointlineplane/ (Paul Bourke 1988))
# [START] The shortest line between two lines in 3D ###
#
# credits to the following sources:
# - http://paulbourke.net/geometry/pointlineplane/ (Paul Bourke 1988)
# - code from http://paulbourke.net/geometry/pointlineplane/source.mel (Dan Wills [dan@rsp.com.au] 2003)
def d_function(m, n, o, p):
return ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z))
def interpolate(a, b, factor):
<NotepadPlus>
<UserLang name="LESS" ext="less" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="yes" Keywords4="no" Keywords5="yes" Keywords6="no" Keywords7="yes" Keywords8="yes" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00// 01 02 03/* 04*/</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2">#</Keywords>
<NotepadPlus>
<UserLang name="LESS" ext="less" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="yes" Keywords4="no" Keywords5="yes" Keywords6="no" Keywords7="yes" Keywords8="yes" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00// 01 02 03/* 04*/</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2">#</Keywords>
@azrafe7
azrafe7 / FisherYatesShuffle.hx
Created January 9, 2019 21:33
Fisher-Yates shuffle algorithm
// https://try.haxe.org/#2C0EE
// https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
static public inline function swap<T>(a:Array<T>, i:Int, j:Int):Void
{
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
@azrafe7
azrafe7 / FlashDebug.hx
Created October 29, 2018 18:25
[haxe] flash debug helpers (exit on esc, set properties of trace textField, etc.)
#if flash
import flash.Boot;
import flash.text.TextField;
enum abstract TextFieldFont(String) from String to String {
var SANS = "_sans";
var TYPEWRITER = "_typewriter";
var TIMES = "_times";
}