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 parseMcTxt($inputTxt){ | |
$inputTxt = str_replace('||', '<br>', $inputTxt); | |
$split = explode("&", $inputTxt); | |
$output = ""; | |
foreach ($split as $key => $value) { | |
$color = substr($value, 0, 1); | |
$str = substr($value, 1); | |
$span = "<span style='color: "; |
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 hexToRGBA(hex, opacity){ | |
var rgba = "rgba("; | |
var inc = Math.abs(hex.length - 5); | |
for (var i = 1; i < hex.length; i+=inc){ | |
var component = hex[i] + hex[i + (inc-1)]; | |
rgba += parseInt(component, 16) + ","; | |
} | |
return rgba + opacity + ")"; | |
} | |
// abs() gives absolute val (modulus); -5 just produces correct increment (1 or 2, based on length of 4 or 7... #f0f vs #ff00ff) |
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
// Minimum & Maximum values for the speed of the vector | |
var minSpeed = 5; | |
var maxSpeed = 20; | |
// Random vector components in range -1,1 | |
var randX = (Math.random()*2)-1; | |
var randY = (Math.random()*2)-1; | |
// Get magnitude of the random vector | |
var mag = Math.sqrt(Math.pow(randX,2) + Math.pow(randY,2)); | |
// Use magnitude to normalise the vector components |
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
var xmlhttp = new XMLHttpRequest(); | |
var url = "myFile.json"; | |
xmlhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
var myArr = JSON.parse(this.responseText); | |
myFunction(myArr); | |
} | |
}; | |
xmlhttp.open("GET", url, true); |
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
var chain = [ | |
()=>{ | |
console.log('chain1111'); | |
return chain.shift()(); | |
}, | |
()=>{ | |
console.log('chain22222'); | |
return chain.shift()(); | |
}, |
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 validEmail(address) { | |
// Regular Express from http://emailregex.com | |
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
if (emailRegex.test(address)) return true; | |
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
// INFO: This script currently relies on the 'request' npm module, | |
// however this will change in the near future to become independant. | |
// http://wiki.vg/Mojang_API | |
const MojangAPI = { | |
base: "https://api.mojang.com", | |
getUUID: (username, done)=>{ | |
request(MojangAPI.base + '/users/profiles/minecraft/' + username, (err, response, 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 myFunc(things, stuff){ | |
return new Promise( (resolve,reject) =>{ // setup | |
var result = []; | |
resolve(result); | |
}).then( (result) =>{ // Action 1 | |
return new Promise( (resolve,reject) =>{ | |
myFirstFunction(things,stuff) |
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 myFunc(items){ | |
var fn = function addSomethingToItem(item){ | |
return new Promise(resolve => { | |
myFirstActionFunc() | |
.then( response =>{ | |
item.value = response; | |
resolve(item); | |
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
/** Find the intersection between two JS arrays of objects | |
* finds based on an object property (using 'filter' and 'map') | |
*/ | |
products = [ // an array of products | |
{reference:'LOWP8F7H', name:'Nike Blazer', price:120, category:1}, | |
{reference:'3PFH3LDP', name:'Nike Kyrie', price:340, category:1}, | |
{reference:'FGH4P40K', NAME:'Nike Bomber', price:70, category:0} | |
]; |
OlderNewer