Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Curious like a cat!

Nadee Talagala Nadeeshyama

:octocat:
Curious like a cat!
View GitHub Profile
@Nadeeshyama
Nadeeshyama / styles.css
Created Jan 24, 2021
[Match Parent's Height] Match the child elements height to parent element's height #Layout
View styles.css
.parent {
overflow: hidden;
position: relative;
width: 100%;
}
.child {
height: 100%;
position: absolute;
right: 0;
@Nadeeshyama
Nadeeshyama / fibonacci.js
Last active Jan 24, 2021
[Fibonacci Sequence] JavaScript function to output first 40 Fibonacci numbers that converge to Pi #Console
View fibonacci.js
/**
* JavaScript function to output first 40 Fibonacci and convergence to Pi
*/
for (var p = 1, q = 1, t, i = 1; i < 41; i++) {
console.log('Fibonacci[%d] (%d + %d): %d; Pi: %f', i, p, q, q, (q/p));
t = q;
q = p + q;
p = t;
}
@Nadeeshyama
Nadeeshyama / script.js
Last active Jan 24, 2021
[Set Debug Mode] Set the URL hash in the format '#debug-ddmmyyyy' to set a global variable __DEBUG__ #URL #Hash
View script.js
/**
* Set the URL hash in the format '#debug-ddmmyyyy' to set a global
* variable __DEBUG__ so that it can be used across all scritps to
* do console outputs, legacy alerts, etc.
*/
var __DEBUG__ = (function() {
var pad = function (s) {return (s.length == 1 ? '0' + s : s)}, // to pad numbers with leading 0s
t = new Date(),
y = t.getFullYear().toString(),
m = pad((t.getMonth() + 1).toString()), // month is index returned in JS :)
@Nadeeshyama
Nadeeshyama / styles.css
Last active Jan 24, 2021
[IE Hacks] Internet Explorer 5 - 8 hacks #IE #Hacks
View styles.css
/**
* IE5.x
*/
property/**/:/**/value;
/**
* IE6 and below
*/
_property: value;
-property: value;
@Nadeeshyama
Nadeeshyama / script.js
Last active Jan 24, 2021
[Find All Arrays In Page] Find all arrays in page
View script.js
var global = window; // window for browser environments
for (var prop in global) {
if (Object.prototype.toString.call(global[prop]) === '[object Array]') { // check for array
if (prop !== 'undefined') {
console.log(prop);
}
}
}