A Pen by AdinanCenci on CodePen.
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Restring number input</title> | |
</head> | |
<body> | |
<p> | |
This input elements are restringed by multiples of the number in the [ multiple ] attribute. |
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
/** | |
* PHP's __call magic method is pretty useful. Unfortunately | |
* there is no equivalent in JavaScript, but it can be | |
* emulated with Proxy: | |
*/ | |
magicMethodsProxy = | |
{ | |
get: function(target, prop, receiver) | |
{ |
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 http = require('http'); | |
const https = require('https'); | |
const url = require('url'); | |
async function request(address, options = {}) | |
{ | |
var myUrl = url.parse(address); | |
var protocol = myUrl.protocol == 'https:' ? https : http; | |
var defaultOptions = |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script> | |
function onClick(e) | |
{ | |
var x, width, perc; |
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
async function loadScript(src) | |
{ | |
return new Promise(async function(success, fail) | |
{ | |
var script; | |
script = document.createElement('script'); | |
script.async = true; | |
script.type = 'text/javascript'; | |
script.onload = function(e) |
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 getRidOfSearchResults() | |
{ | |
for (let c of document.querySelectorAll('cite')){ | |
if (! /pinterest\./.test(c.innerText)) { | |
continue; | |
} | |
var wrapper = getParentWithClass(c, 'g'); | |
wrapper.style.opacity = 0.1; |
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
<?php | |
function getKey($key, &$array, $alternative) | |
{ | |
if (! array_key_exists($key, $array)) { | |
return $alternative; | |
} | |
$value = empty($array[$key]) ? $alternative : $array[$key]; |
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
<?php | |
function isPrime($number) | |
{ | |
// the only even prime number is 2 | |
if (($number % 2 == 0 and $number != 2) or $number == 1) { | |
return false; | |
} | |
$finish = floor($number / 2); // the higher denominator of any number is its half |