Skip to content

Instantly share code, notes, and snippets.

View tangoabcdelta's full-sized avatar

tangoabcdelta

View GitHub Profile
@tangoabcdelta
tangoabcdelta / instructions.md
Created December 20, 2022 05:22
git-crypt: command not found error thrown while launching source tree
  • Go to SourceTree > Preferences > Git > Git Version (section)

  • Select "Reset to Embedded Git"

  • Note: Do not use the system version of git

  • Now you need to add path of git-crypt as a symlink

  • From https://jira.atlassian.com/browse/SRCTREE-2511 : The easiest solution would be to symlink git-crypt1 to the same location as your git` binary due to variations in how to configure (per major OS revision)

  • Locate your SourceTree installation directory

  • Locate the embedded git path. This is usually /Applications/Sourcetree.app/Contents/Resources/git_local/bin/

  • Run which git-crypt

@tangoabcdelta
tangoabcdelta / Run.IntelliJ.sh
Last active August 29, 2022 19:39
How to set path to $JAVA_HOME in environment variable correctly in Mac OS (new and old - zsh and bash, both)
# For newer Mac OS versions where zsh is the default terminal
$ nano ~/.zshenv
# For older Mac OS versions where bash is the default terminal
$ nano ~/.bash_profile
# add the following two entries in ~/.zshenv
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=/correct/path/to/apache-maven-3.8.6/bin:$PATH
@tangoabcdelta
tangoabcdelta / index.css
Created August 26, 2022 06:12
BarcodeDetector Experimental Web APIs
html, body {
background: #111;
color: white;
height: 100%;
}
canvas {
display: none;
height: auto;
object-fit: contain;
@tangoabcdelta
tangoabcdelta / another.example.of.prototype.replacement.js
Last active August 7, 2022 22:53
Pprototypal inheritance in JavaScript
function Person(name) {
this.name = name;
}
const a = new Person("a");
try {
console.log(a.getName()); // Output: TypeError: a.getName is not a function
} catch (e) {
console.error(e);
@tangoabcdelta
tangoabcdelta / class-polyfill.js
Created August 7, 2022 22:26
Polyfills for a Class definition in Javascript
var _createClass = (function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) {
descriptor.writable = true;
}
Object.defineProperty(target, descriptor.key, descriptor);
@tangoabcdelta
tangoabcdelta / script.js
Created August 7, 2022 13:32
The Sindresorhus Approach for finding unique random elements from an Array
var input = [11, 12, 13, 55, 34, 66, 88, 12, 98, 67, 12, 66, 53, 23];
console.log(`input size is ${input.length}`);
(function theSindresorhusApproach() {
// the sindresorhus approach
function* play() {
let h = {};
input.map((i) => (h[i] = i));
@tangoabcdelta
tangoabcdelta / decode.html.entities.js
Created April 18, 2022 23:47
How to decode HTML entities in JavaScript?
// The native unescape or decodeURI or decodeURIComponent is not suitable for this job
// Instead, take the escaped HTML entity and set it as innerHTML
// Then, extract the innerText
// The complete list of HTML entities with their numbers and names can be found here.
// This page also includes full list of ASCII characters that can be represented in HTML.
// https://www.freeformatter.com/html-entities.html
d = document.createElement('div'); d.innerHTML = '&#33;'; d.innerText;
# create a self signed certificate for localhost
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
# writing RSA key
rm server.pass.key
openssl req -new -key server.key -out server.csr
# Country Name (2 letter code) [AU]:IN
# State or Province Name (full name) [Some-State]:Karnataka
@tangoabcdelta
tangoabcdelta / spdy.http2.js
Created April 16, 2022 14:44
determine if spdy or http2 was used to fetch website
window.performance.getEntriesByType("resource").filter(p => 'nextHopProtocol' in p)[0].nextHopProtocol // 'h2'
// deprecated
// https://chromestatus.com/feature/5637885046816768
window.chrome.loadTimes().wasFetchedViaSpdy; // true
window.chrome.loadTimes().npnNegotiatedProtocol; // 'h2'
window.chrome.loadTimes().connectionInfo; // 'h2'
@tangoabcdelta
tangoabcdelta / browser.zoom.detect.js
Created May 11, 2021 17:52
Detect-zoom - Cross Browser Zoom and Pixel Ratio Detector
/* Detect-zoom
* -----------
*https://codepen.io/reinis/pen/RooGOE
* Cross Browser Zoom and Pixel Ratio Detector
* Version 1.0.4 | Apr 1 2013
* dual-licensed under the WTFPL and MIT license
* Maintained by https://github/tombigel
* Original developer https://github.com/yonran
*/