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 isMobile = (userAgent) => { | |
userAgent = userAgent || window.navigator.userAgent; | |
const device = ['iPhone', 'iPod', 'Android', 'Windows CE', 'BlackBerry', 'Symbian', 'Windows Phone', 'webOS', 'Opera Mini', 'Opera Mobi', 'POLARIS', 'IEMobile', 'lgtelecom', 'nokia', 'SonyEricsson', 'LG', 'SAMSUNG'].join('|'); | |
const regexp = new RegExp(device, 'i'); | |
return regexp.test(userAgent); | |
}; |
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 shuffle(arr) { | |
var i = arr.length; | |
var random; | |
var temp; | |
while (i > 0) { | |
random = Math.floor(Math.random() * i--); | |
temp = arr[i]; | |
arr[i] = arr[random]; |
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 post(url, body) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open("POST", url, true); | |
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); | |
xhr.onreadystatechange = function() { | |
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) { | |
console.log(this); | |
console.log(url, body); | |
} |
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 requestUtils(method, url, body) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open(method, url, true); | |
xhr.withCredentials = true; | |
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); | |
xhr.onreadystatechange = function() { | |
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) { | |
console.log(this); | |
console.log(url, body); |
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
window.__autoPlay = setInterval(() => { | |
this.playTracks(); | |
}, 500); | |
const promise = new Audio('/temp.mp3').play(); | |
if (promise !== undefined) { | |
promise.then(() => { | |
window.__autoPlay && clearInterval(window.__autoPlay); | |
}).catch(() => {}); |
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
public static String decimalToHex(int decimal, Integer length) { | |
return String.format("%0"+length+"x", decimal); | |
} |
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
public static String getDateTime() { | |
Date from = new Date(); | |
SimpleDateFormat transFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
return transFormat.format(from); | |
} |
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 reverse(str) { | |
return str.split('').reserve().join('') | |
} |
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
$$('.btn-octicon.js-details-target').forEach(a => a.click()) | |
$$('.js-reviewed-checkbox:checked').forEach(a => a.click()) |
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
from urllib.request import urlopen | |
from urllib.error import HTTPError | |
def checkHttpStatus(URL): | |
try: | |
res = urlopen(URL) | |
return res.status | |
except HTTPError as e: | |
code = e.getcode() |
OlderNewer