This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (function () { | |
var re = window.location.href.match(/v=([^\?&"'>]+)/g); | |
if (re && re.length > 0) { | |
window.location='https://youtu.be/' + re[0].split('=')[1] + "?t=" + Math.round(document.getElementById('movie_player').getCurrentTime()); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getFactors = num => { | |
const maxFactorNum = Math.floor(Math.sqrt(num)); | |
const factorArr = []; | |
let count = 0; // count of factors found < maxFactorNum | |
for (let i = 1; i <= maxFactorNum; i++) { | |
//inserting new elements in the middle using splice | |
if (num % i === 0) { | |
//(index, how many to remove, inserted element) | |
factorArr.splice(count, 0, i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isPrime(num) { | |
//check if value is a natural numbers (integer) | |
//without this check, it returns true | |
if (isNaN(num) || num % 1 !== 0) { | |
return false; | |
} | |
num = Math.abs(num); //*negative values can be primes | |
if (num === 0 || num === 1) { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Example JS: | |
const timer = new Timer(); | |
timer.start(); | |
timer.stop(); | |
Example HTML: | |
<span id="timerDisplay"><!-- not required --></span> | |
<button onclick="timer.start();">start</button> | |
<button onclick="timer.stop();">stop</button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
/* Hide radio buttons */ | |
input[type="radio"][name="css-tab-rdo"] { | |
display: none; | |
} | |
/* Show selected tab contents */ | |
#tab1Rdo:checked ~ #tab1 { display: block; } | |
#tab2Rdo:checked ~ #tab2 { display: block; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
m.name AS table_name, | |
p.cid AS col_id, | |
p.name AS col_name, | |
p.type AS col_type, | |
p.pk AS col_is_pk, | |
p.dflt_value AS col_default_val, | |
p.[notnull] AS col_is_not_null | |
FROM sqlite_master m | |
LEFT OUTER JOIN pragma_table_info((m.name)) p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
m.name AS table_name, | |
p.cid AS col_id, | |
p.name AS col_name, | |
p.type AS col_type, | |
p.pk AS col_is_pk, | |
p.dflt_value AS col_default_val, | |
p.[notnull] AS col_is_not_null | |
FROM sqlite_master m | |
LEFT OUTER JOIN pragma_table_info((m.name)) p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html><html><head><meta charset="utf-8"><title>Template</title></head> | |
<body> | |
<div id="output"></div> | |
<script> | |
window.onload = function() { | |
var i | |
, row | |
, output = document.getElementById("output") | |
, size = data.list.length | |
, arr = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//See also my answer on StackOverflow: https://stackoverflow.com/a/23945027/1675237 | |
const extractHostname = url => { | |
//find & remove protocol (http, ftp, etc.) and get hostname | |
let hostname = url.split('/')[url.indexOf("//") > -1 ? 2 : 0]; | |
//find & remove port number | |
hostname = hostname.split(':')[0]; | |
//find & remove "?" | |
return hostname.split('?')[0]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
My StackOverflow answer to "How to find out what character key is pressed?": | |
https://stackoverflow.com/a/51955727/1675237 | |
--> | |
<table> | |
<tr><td>Key:</td><td id="key"></td></tr> | |
<tr><td>Key Code:</td><td id="keyCode"></td></tr> | |
<tr><td>Event Code:</td><td id="eventCode"></td></tr> | |
</table> | |
<script type="text/javascript"> |
OlderNewer