This file contains hidden or 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 romans(){const romans={I:1,V:5,X:10,L:50,C:100,D:500,M:1000};function getDecimalFromRomanNumeral(romanNumeral){let decimal;decimal=0;for (let i=0,l=romanNumeral.length;i<l;++i) {if(romanNumeral[i+1]&&romans[romanNumeral[i]]<romans[romanNumeral[i+1]]){decimal+=romans[romanNumeral[i+1]]-romans[romanNumeral[i]];++i;}else{decimal+=romans[romanNumeral[i]];}}return decimal;}const input=prompt('Roman numerals');const result=getDecimalFromRomanNumeral(input.toUpperCase());alert(result);})(); |
This file contains hidden or 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()%7Bfunction Types()%7Bthis.characterTypes%3D%5B%27uppercase%27,%27lowercase%27,%27number%27,%27dash%27%5D%3Bthis.limits%3D%7Buppercase:1,lowercase:13,number:1,dash:1%7D%7DTypes.prototype.getValidType%3Dfunction()%7Bconst types%3D%5B%5D%3Bif(this.limits.uppercase>0)%7Btypes.push(%27uppercase%27)%7Dif(this.limits.lowercase>0)%7Btypes.push(%27lowercase%27)%7Dif(this.limits.number>0)%7Btypes.push(%27number%27)%7Dif(this.limits.dash>0)%7Btypes.push(%27dash%27)%7Dconst type%3Dtypes%5BgetRandomNumber(0,types.length-1)%5D%3Breturn type%7D%3BTypes.prototype.decrement%3Dfunction(type)%7Bthis.limits%5Btype%5D-%3D1%3Bif(this.limits%5Btype%5D<0)%7Bthis.limits%5Btype%5D%3D0%7D%7D%3Bfunction getRandomNumber(min,max)%7Breturn Math.floor(Math.random()*(max-min%2B1))%2Bmin%7Dfunction getValidType()%7Breturn(new Types()).getValidType()%7Dfunction getCharacterCode(types,type)%7Blet number%3Bswitch(type)%7Bcase %27uppercase%27:number%3DgetRandomNumber(65,90)%3Btypes.decrement(%27uppercase%27)%3Bbreak%3Bcase |
This file contains hidden or 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:location.href=location.href.split('?%27)%5B0%5D; |
This file contains hidden or 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 getWeekNumber() { | |
const now = new Date() | |
const oneJan = new Date(now.getFullYear(), 0, 1) | |
const numDays = Math.floor((now - oneJan) / (24 * 60 * 60 * 1000)) | |
return Math.ceil(( now.getDay() + 1 + numDays) / 7) | |
} |
This file contains hidden or 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
<?php | |
// pass through proxy for wikipedia’s “nearby” api | |
function isValidOrigin() { | |
$host = $_SERVER['HTTP_HOST']; | |
$origin = $_SERVER['HTTP_ORIGIN']; | |
$allowed_hosts = array( | |
'segdeha.com', | |
); |
This file contains hidden or 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 Counter(count, displaySelector, buttonSelector) { | |
this.count = count | |
this.displayElement = document.querySelector(displaySelector) | |
this.buttonElement = document.querySelector(buttonSelector) | |
this.setCount() | |
} | |
Counter.prototype = { |
This file contains hidden or 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
/** | |
* Calculate a weighted estimate for the interval until the next purchase | |
* Current purchase a tiny bit less weight than all previous purchases | |
* @param {Number} lastEstimate The last stored purchase interval estimate | |
* @param {Number} latestInterval The interval between the most recent and previous purchases | |
* @param {Number} numberOfPurchases Total number of purchases for the item | |
*/ | |
const calculateEstimate = (lastEstimate, latestInterval, numberOfPurchases) => { | |
if (isNaN(lastEstimate)) { | |
lastEstimate = 14; |
This file contains hidden or 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 words = [ "aaa", "aaaa", "aaron", "aba", "ababa", "aback", "abase", "abash", "abate", "abbas", "abbe", "abbey", "abbot", "abbott", "abc", "abe", "abed", "abel", "abet", "abide", "abject", "ablaze", "able", "abner", "abo", "abode", "abort", "about", "above", "abrade", "abram", "absorb", "abuse", "abut", "abyss", "acadia", "accra", "accrue", "ace", "acetic", "ache", "acid", "acidic", "acm", "acme", "acorn", "acre", "acrid", "act", "acton", "actor", "acts", "acuity", "acute", "ada", "adage", "adagio", "adair", "adam", "adams", "adapt", "add", "added", "addict", "addis", "addle", "adele", "aden", "adept", "adieu", "adjust", "adler", "admit", "admix", "ado", "adobe", "adonis", "adopt", "adore", "adorn", "adult", "advent", "advert", "advise", "aegis", "aeneid", "afar", "affair", "affine", "affix", "afire", "afoot", "afraid", "africa", "afro", "aft", "again", "agate", "agave", "age", "agee", "agenda", "agent", "agile", "aging", "agnes", "agnew", "ago", "agone", "agony", "agree", "ague", "agway", "ahead", "ahem |
This file contains hidden or 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 capitalise = name => name.slice(0, 1).toUpperCase() + | |
name.slice(1, name.length).toLowerCase(); | |
let name = 'diane'; | |
alert(`Hi ${capitalise(name)}. You are pretty cool!`); |
This file contains hidden or 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
let name = 'diane'; | |
let name_capitalised = name.slice(0, 1).toUpperCase() + | |
name.slice(1, name.length).toLowerCase(); | |
alert(`Hi ${name_capitalised}. You are pretty cool!`); |
NewerOlder