Skip to content

Instantly share code, notes, and snippets.

View Nadeeshyama's full-sized avatar
:octocat:
Curious like a cat!

Nadee Talagala Nadeeshyama

:octocat:
Curious like a cat!
View GitHub Profile
@Nadeeshyama
Nadeeshyama / styles.css
Created January 24, 2021 12:42
[Match Parent's Height] Match the child elements height to parent element's height #Layout
.parent {
overflow: hidden;
position: relative;
width: 100%;
}
.child {
height: 100%;
position: absolute;
right: 0;
@Nadeeshyama
Nadeeshyama / fibonacci.js
Last active January 24, 2021 12:35
[Fibonacci Sequence] JavaScript function to output first 40 Fibonacci numbers that converge to Pi #Console
/**
* 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 January 24, 2021 12:38
[Set Debug Mode] Set the URL hash in the format '#debug-ddmmyyyy' to set a global variable __DEBUG__ #URL #Hash
/**
* 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 January 24, 2021 12:41
[IE Hacks] Internet Explorer 5 - 8 hacks #IE #Hacks
/**
* IE5.x
*/
property/**/:/**/value;
/**
* IE6 and below
*/
_property: value;
-property: value;
@Nadeeshyama
Nadeeshyama / script.js
Last active January 24, 2021 12:39
[Find All Arrays In Page] Find all arrays in page
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);
}
}
}