I’m trying to redirect anyone viewing my blog from certain IP addresses (or ranges of IP addresses) to a different page. I found something that works for individual IP addresses, but I can’t figure out how to block ranges of IP addresses – like 123.123.123.* Here’s the script: I’…
Author: admin@master
Snake Game with Mobile Button Controls
In this Snake game, I need the buttons to control the snake just like the arrow keys do. This will allow the game to be played on a mobile device. You can see i have code in there for the buttons, but they are not working properly and not controlling the movement of the snake. Any advice to make the
Easiest way to get list of files in the server directory
I need to get array of all images (or simply of all files) in directory (e.g. www.example.com/images/). I prefer to use JavaScript but it’s hard to make. So should I use PHP, meybe? Could you please help me – I’m not good at this. Thank you very much! Answer Javascript cannot fetch all files…
Reverse array in Javascript without mutating original array
Array.prototype.reverse reverses the contents of an array in place (with mutation)… Is there a similarly simple strategy for reversing an array without altering the contents of the original array (without mutation)? Answer You can use slice() to make a copy then reverse() it
Javascript regex matching at least one letter or number?
What would be the JavaScript regex to match a string with at least one letter or number? This should require at least one alphanumeric character (at least one letter OR at least one number). Answer In general, a pattern matching any string that contains an alphanumeric char is However, a regex requirement lik…
How to query a field in MongoDB with a boolean value and return a boolean whether it’s true or false
Check my simple collection: What I want to do once a document is found, is to manipulate a DOM and show a <div class=”driving-tutorial> if the field canDrive value is false and hide it if the value is true Like this in meteor: Answer You could implement this logic with the findOne() method which f…
ECMAScript 6: what is WeakSet for?
The WeakSet is supposed to store elements by weak reference. That is, if an object is not referenced by anything else, it should be cleaned from the WeakSet. I have written the following test: Even though my [1, 2, 3] array is not referenced by anything, it’s not being removed from the WeakSet. The cons…
Html2canvas image capturing issue with UTF-8 characters
I want to capture my webpage, In order to this I find html2canvas, when I use as shown below ,my UTF-8 (persian) characters get in trouble and this direction destroyed as you see. HTML: JavaScript: WebPage: Captured WebPage via html2canvas: you can see full example here What is wrong with my implementation? A…
Fixing greyed-out .owl-carousel div
I’m making a call to get a page (getresult.php) through AJAX. The ID div in my index: My footer: The script for calling getresult in the footer: Now this is my page getresult: My problem is the carousel class doesn’t work. When I remove the class owl-carousel, I can see the pic. I have the CSS and…
D3js find closest point on circle
what I’m trying to achieve is to take the current coordinates of a mousemove event and match them with the coordinates of the closest location on a circle. I’ve managed to get this partially working using a for loop which iterates over each possible point in the circle and compares the coordinates…