Skip to content

Instantly share code, notes, and snippets.

View dlucidone's full-sized avatar

Ravi dlucidone

View GitHub Profile
@dlucidone
dlucidone / Nativescript String to Base64 String and Vice-Versa.ts
Last active January 31, 2021 00:53
Nativescript Base64 Manipulation Methods
/*
* Convert A String to Base64 String or Vice-Versa
*/
declare const android: any;
declare const java: any;
declare const NSData: any;
declare const NSUTF8StringEncoding: any;
declare const NSString: any;
Observer Design Pattern
1-https://pawelgrzybek.com/the-observer-pattern-in-javascript-explained/
JS-
let observers = [],
data;
const subscribe = f => observers.push(f);
const unsubscribe = f => observers = observers.filter(o => o !== f);
const notify = () => observers.forEach(o => o(data));
@dlucidone
dlucidone / Observer-Pattern.html
Last active January 15, 2019 04:54
JS BinObserver-Pattern// source https://jsbin.com/ferarux
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Observer-Pattern">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input class="js-input" type="text" placeholder="type something "/>
@dlucidone
dlucidone / index.html
Created January 15, 2019 06:46
JS Bin PubSub // source https://jsbin.com/jamevox
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="PubSub">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@dlucidone
dlucidone / debounce & throttle.txt
Last active February 12, 2019 03:29
Debounce & Throttle
1- Debounce
<html>
<body>
<button id="debounce">
Debounce
</button>
<script>
var button = document.getElementById("debounce");
const debounce = (func, delay) => {
let debounceTimer
@dlucidone
dlucidone / PromiseSimple.js
Created January 18, 2019 04:36
Promise Implementation
class PromiseSimple {
constructor(executionFunction) {
this.promiseChain = [];
this.handleError = () => {};
this.onResolve = this.onResolve.bind(this);
this.onReject = this.onReject.bind(this);
executionFunction(this.onResolve, this.onReject);
}
@dlucidone
dlucidone / extend.js
Created January 22, 2019 03:30
Class Extend Implementation
function extend(subClass, superClass) {
var F = function() {};
F.prototype = superClass.prototype;
subClass.prototype = new F();
subClass.prototype.constructor = subClass;
subClass.superclass = superClass.prototype;
if (superClass.prototype.constructor == Object.prototype.constructor) {
superClass.prototype.constructor = superClass;
}
@dlucidone
dlucidone / ArrayRotate.html
Last active February 12, 2019 03:28
Array Rotate
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@dlucidone
dlucidone / ArraySpiral.html
Last active February 12, 2019 03:27
Array Spiral
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@dlucidone
dlucidone / linkedlist.js
Last active February 6, 2019 05:19
Linked list JS
function Node(data){
this.data = data;
this.next = null;
}
function LinkedList(){
this.length=0;
this.head = null;
}