Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,195,394 members, 7,958,130 topics. Date: Wednesday, 25 September 2024 at 09:19 AM

Skptricks's Posts

Nairaland Forum / Skptricks's Profile / Skptricks's Posts

(1) (2) (3) (4) (5) (of 5 pages)

Programming / Jquery Pagination Plugin by skptricks: 4:59pm On Jan 25, 2018
http://www.skptricks.com/2018/01/jquery-pagination-plugin.html


In this tutorial we are going to learn how to use JQuery Pagination Plugin, which automatically create pagination buttons based on our requirement (create button like first, last, previous, next etc).



This plugin help you to create simple, effective, and useful pagination for your site. All you need to do is specify an element (preferably a ul or div) and the plugin takes care of the rest. This pagination requires Jquery library, the plugin itself, and optionally the Bootstrap CSS (as it helps to create formatted button with help of Bootstrap CSS).

Follow the below steps to include this JQuery Plugin in your web based application.


http://www.skptricks.com/2018/01/jquery-pagination-plugin.html


https://www.youtube.com/watch?v=w9lTYkL9RSs

Programming / Flip Animation Effect Using CSS3 by skptricks: 7:07am On Jan 24, 2018
Flip Animation Effect Using CSS3
post link : http://www.skptricks.com/2018/01/flip-animation-effect-using-css3.html

This Post Explain how to create Flip Animation effect using CSS3. Here we are using CSS keyframe attribute to perform flip animation effect horizontally and vertically to small square div box. All the animation effect is controlled Keyframes Rule and it provides very smooth animation effect.




Keyframe Animation :
Here we are using below CSS Style to perform flip animation effect horizontally and vertically to small square div box.
@keyframes rotate-div {
0% {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg);
} 50% {
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
-webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
} 100% {
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
-webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
background-color: #ec407a;
}
}

post link : http://www.skptricks.com/2018/01/flip-animation-effect-using-css3.html


https://www.youtube.com/watch?v=8OYyvpr6zg8
Programming / Gmail Like Loading Animation Using CSS3 by skptricks: 8:04am On Jan 20, 2018
In this post, We are going to provide a small example and source code for "Gmail Like Loading Animation Using CSS3". For displaying loading and animation effect , CSS3 Plays a most important role over here.


All the animation effects are controlled Keyframes Rule. Here we have used two keyframes, which provides you smooth animation effect.

Post Link : http://www.skptricks.com/2018/01/gmail-like-loading-animation-using-css3.html

Programming / Regular Expression Validation In Javascript by skptricks: 6:28am On Jan 19, 2018
Post Link : http://www.skptricks.com/2018/01/regular-expression-validation-in-javascript.html

A Regular expressions is a powerful tool in any language. In this tutorial we will be discussing how to use regular expression in JavaScript. Regular expression is the most important part in form validations and it is widely used for search, replace and web crawling systems. A regular expression is also known as RegEx.


or succinctly,
Regular expressions use to detect patterns in strings of text. Regular expressions provides a quick and easy way of matching a string to a pattern. Validation of mobile no, username, email id, website url are possible through Regular expressions.

Learn Regular Expressions by Examples :

Post Link : http://www.skptricks.com/2018/01/regular-expression-validation-in-javascript.html

Programming / Convert URL To Clickable Link Using PHP by skptricks: 12:16pm On Jan 07, 2018
This post explains how to Convert URL To Clickable Link Using PHP. Here I am using below PHP function to turn all URLs in clickable links with the help of Regular Expression validation.

Post link : http://www.skptricks.com/2018/01/convert-url-to-clickable-link-using-php.html

lets see the user defined PHP Function which convert URL to Clickable Link.

convertLink.php
This function covert URL to Link with the help of Regular Expression validation.

<?php
function Convert_link_to_urls($text = '')
{
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
$finaltext = ' ' . $text;
$finaltext = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<span class='ccc'><a href=\"\\2\" target=\"_blank\"><font style='font-family: Verdana, Geneva, sans-serif;color: blue;font-size:13px; line-height:20px;'>\\2</font></a></span>", $finaltext);
$finaltext = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<span class='ccc'><a href=\"http://\\2\" target=\"_blank\"><font style='font-family: Verdana, Geneva, sans-serif;color: blue;font-size:13px; line-height:20px;'>\\2</font></a></span>", $finaltext);
$finaltext = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<span class='ccc'><a href=\"mailto:\\2@\\3\"><font style='font-family: Verdana, Geneva, sans-serif;color: blue;font-size:13px; line-height:20px;'>\\2@\\3</font></a></span>", $finaltext);
$finaltext = substr($finaltext, 1);
return $finaltext;
}
?>

Index.php
Here we are calling Convert_link_to_urls Function to display the clickable Link:

<?php
include('convertLink.php');

$text='welcome to skptricks : http://www.skptricks.com/2017/12/download-urls-content-using-php-curl.html';

echo Convert_link_to_urls($text);

?>

Post link : http://www.skptricks.com/2018/01/convert-url-to-clickable-link-using-php.html

1 Like

Education / Extract URL Data Like Facebook Using PHP, Jquery And Ajax by skptricks: 8:58am On Dec 30, 2017
Post Link : http://www.skptricks.com/2017/12/extract-url-data-like-facebook-and-web-scraping.html
-----------------------------------------------------------------------------------------------------------------------
https:///q13Wxv

This post explains how to create Extract URL Data Like Facebook Using PHP, jQuery and Ajax. Basically in the URL Extraction we are retrieving the Meta Tag details from the webpages, which is available in the Head Tag.

From the Meta Tag we are picking up some important information like Title, Description, Images and some URL. If you have observed the most the company like Facebook, Twitter, Google, LinkedIn etc using this link extraction technique in their webpages. In another word this extraction technique is also called as web scraping.

What is web scraping ?
Web Scraping refers to an application that processes the HTML of a Web page to extract data for manipulation such as converting the Web page to another format (i.e. HTML to WML).

Here in this post we have provided simple example to Extract URL Data and also it gives you ideas how to get the cross domain data with jquery and ajax.
extract url in php Technical Guruji

lets see the below source code and clear you understanding step by step.
Post Link : http://www.skptricks.com/2017/12/extract-url-data-like-facebook-and-web-scraping.html
-----------------------------------------------------------------------------------------------------------------------


https://www.youtube.com/watch?v=Zjh1ahyHwMA

Programming / Extract URL Data Like Facebook Using PHP, Jquery And Ajax by skptricks: 8:46am On Dec 30, 2017
Post Link : http://www.skptricks.com/2017/12/extract-url-data-like-facebook-and-web-scraping.html
-----------------------------------------------------------------------------------------------------------------------

This post explains how to create Extract URL Data Like Facebook Using PHP, jQuery and Ajax. Basically in the URL Extraction we are retrieving the Meta Tag details from the webpages, which is available in the Head Tag.

From the Meta Tag we are picking up some important information like Title, Description, Images and some URL. If you have observed the most the company like Facebook, Twitter, Google, LinkedIn etc using this link extraction technique in their webpages. In another word this extraction technique is also called as web scraping.

What is web scraping ?
Web Scraping refers to an application that processes the HTML of a Web page to extract data for manipulation such as converting the Web page to another format (i.e. HTML to WML).

Here in this post we have provided simple example to Extract URL Data and also it gives you ideas how to get the cross domain data with jquery and ajax.
extract url in php Technical Guruji

lets see the below source code and clear you understanding step by step.
Post Link : http://www.skptricks.com/2017/12/extract-url-data-like-facebook-and-web-scraping.html
-----------------------------------------------------------------------------------------------------------------------


https://www.youtube.com/watch?v=Zjh1ahyHwMA

Programming / Download A Url’s Content Using PHP Curl by skptricks: 8:31am On Dec 25, 2017
----------------------------------------------------------------------------------------------------
Link : http://www.skptricks.com/2017/12/download-urls-content-using-php-curl.html
----------------------------------------------------------------------------------------------------

In this tutorial we are going to learn how to extract or download the content from the specific URL. Nowadays it is a common and useful technique to extract data from another server. By this way we can extract useful data like meta tag details, html attribute/ tags details.
PHP's cURL library, which often comes with default shared hosting configurations, allows web developers to complete this task.


Lets see the below function which will extract information from specific URL.
PHP cURL Method.

/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

To call get_data() function, you need to mention below statement in PHP tag.
$returned_content = get_data('https://www.skptricks.com');

Alternative Method

Alternatively, you can use the file_get_contents function remotely, but many hosts don't allow this.

<?php
$URL ="http://www.skptricks.com"
file_get_contents($URL)
?>


----------------------------------------------------------------------------------------------------
Link : http://www.skptricks.com/2017/12/download-urls-content-using-php-curl.html
----------------------------------------------------------------------------------------------------

Programming / Re: I Want To Learn Programming. Which Language Should I Start With? by skptricks: 8:30am On Dec 25, 2017
Javanian:
Due to the numerous "i want to start programming, which language should i start with" threads on this board i decided to create a thread that will address this issue. I am not a wonderful writer and i won't say i know it all but i will try. I urge every one on this board to correct me where i err an also contribute in whatever way you can to make this thread worth it. I will try as much as possible not to be biased in this write up.

I am not going to go into detail in defining what programming is because i will assume before entering this thread you should already know what programming is. But in summary programming is the act of creating whatever you want with your brain and computer programming is the act of creating whatever you want with your brain and a computer. You can read more from

http://en.wikipedia.org/wiki/Computer_programming

Programmers could also be called software programmers, software developers and other big-big names you can think of.

Feel free to ask your questions, i will try and answer the ones i can my Ogas in the house will help me with those i can't answer

Please every Programmer should try as much as possible to check on this thread once in a while to help answer some questions Newbies would like to ask.

PHP is a best option.
http://www.skptricks.com/p/php.html

1 Like 1 Share

Programming / Htaccess File Tutorial And Tips by skptricks: 10:12am On Dec 24, 2017
Link : http://www.skptricks.com/2017/12/htaccess-file-tutorial-and-tips.html

Today we are going to share some ideas about Htaccess. Basically Htaccess is a configuration file use on web servers running the Apache Web Server software and Using Htaccess you can easily configure and redirect Apache Web Server file system.


What is .htaccess ?
.htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn 'loaded via the Apache Web Server', then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. These facilities include basic redirect functionality, for instance if a 404 file not found error occurs, or for more advanced functions such as content password protection or image hot link prevention.
How to Enable .htaccess in Xampp Application
Once you have installed Xampp application in your system, all the configuration file should be available with you in your system. Here we have installed Xampp application in D: Drive.

Lets follow the below steps to enable the .htaccess :
1. Open the below directory in you system :
D:\Xampp\apache\conf



2. Then Open httpd.conf File using text editor and search for below line :
LoadModule rewrite_module modules/mod_rewrite.so

and Remove hash form the that line and save that file after that restart your Apache server and reload that page in browser.


How to Create a .htaccess File?
Open any text editor application and file save as with .htaccess in root directory folder. Check the below screenshot for more reference.


Lets see the few basic operations for .htaccess configuration file.
Default directory Listing
This is the default directory listing for Xampp application, no restriction is here.




Disable directory Listing
If you want to disable folder files listing, include following code in .htaccess file.
# Disable Directory Browsing
Options All -Indexes

Error Pages Redirection
If you enter invalid Link, then it will redirect to error.html page. For Error Page redirection, you require following code :

errorDocument 400 http://localhost/skptricks/demo/error.html
errorDocument 401 http://localhost/skptricks/demo/error.html
errorDocument 404 http://localhost/skptricks/demo/error.html
errorDocument 500 http://localhost/skptricks/demo/error.html

Entering invalid link in address bar :

Page redirected to error.html page :

NOTE : To use Rewrite Rules feature in Apache Server, you need to turn on the RewriteEngine. if you want to turn off, just change the value to off. Mention the below statement in .htaccess file.

Example :
RewriteEngine on
RewriteEngine off

You need to turn on the RewriteEngine for the below examples, Otherwise it will work.
Domain Redirection
.htacces code for redirecting yourwebsite.com to www.yourwebsite.com


RewriteCond %{HTTP_HOST} ^yourwebsite.com
RewriteRule (.*) http://www.yourwebsite.com/$1 [R=301,L]

Sub Domain Redirection
Sub domain redirection mapping to folder. Here http://www.yourwebsite.com is connecting to website_folder folder.

RewriteCond %{HTTP_HOST} ^www\.yourwebsite\.com$
RewriteCond %{REQUEST_URI} !^/website_folder/
RewriteRule (.*) /website_folder/$1

Similarly we can link to sub-domain folder.
Here http://subdomain.yourwebsite.com is connecting to subdomain_folder folder.

RewriteCond %{HTTP_HOST} ^subdomain\.yourwebsite\.com$
RewriteCond %{REQUEST_URI} !^/subdomain_folder/
RewriteRule (.*) /subdomain_folder/$1
Profile URL
Profile parameter allows [a-zA-Z0-9_-] these inputs and here we have used regular expression statement.
we are apply rewrite rules to below URL.
http://localhost/skptricks/demo/profile.php?username=skptricks
to
http://localhost/skptricks/demo/skptricks

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?username=$1



Post URL
Similarly we are using rewrite rules in another URL. Which will rewrite the URL in below format.
http://localhost/skptricks/demo/post.php?title=html
to
http://localhost/skptricks/demo/post/html


RewriteEngine on
RewriteRule ^post/([a-zA-Z0-9_-]+)$ post.php?title=$1
RewriteRule ^post/([a-zA-Z0-9_-]+)/$ post.php?title=$1



Forum URL With Two Parameter
Similarly we are using rewrite rules in another URL. Which will rewrite the URL in below format.
http://localhost/skptricks/demo/forum.php?year=2017&title=UFT
to
http://localhost/skptricks/demo/forum/2017/UFT

RewriteEngine on
RewriteRule ^forum/([0-9]+)/([a-zA-Z0-9_-]+)$ forum.php?year=$1&title=$2
RewriteRule ^forum/([0-9]+)/([a-zA-Z0-9_-]+)$ forum.php?year=$1&title=$2



Hiding File Extension
If you want to hide the webpage extension then use the below code :
http://localhost/skptricks/demo/post.php
to
http://localhost/skptricks/demo/post

RewriteRule ^([^/.]+)/?$ $1.php

Video Link :


Download Link : https://github.com/skptricks/php-Tutorials/tree/master/Htaccess%20File%20Tutorial%20and%20Tips

Do Comments in case of any questions...

Programming / CSS Geometric Shapes by skptricks: 6:54am On Dec 16, 2017
Today, we are going to share some ideas about CSS Geometric Shapes. This CSS Geometric Shapes helps you while doing CSS coding. we have designed some Geometric Shapes using CSS and some of them support CSS3.
With the help of below CSS design you can design some more Geometric Shapes. After this tutorial you may require any images to design Geometric Shapes.
CSS Geometric Shapes

Lets see the step by step guide to design Geometric Shapes using CSS :

http://www.skptricks.com/2017/12/css-geometric-shapes.html

Programming / Facebook Loading Animation Using CSS3 by skptricks: 7:53am On Dec 10, 2017
Today we are going to discuss Facebook loading animation using CSS3. If you observed that when you open Facebook in web application it shows a content loading placeholder like below screenshots.
How the Facebook content placeholder works
To display loading effect in webpage based application, you need some ideas on CSS3. Here we are using CSS3 Keyframes to create desire effect.

Lets start with [url="http://www.skptricks.com/2017/12/facebook-loading-animation-using-css3.html"]loading animation[/url].

http://www.skptricks.com/2017/12/facebook-loading-animation-using-css3.html


https://www.youtube.com/watch?v=1E3s5lPQYXg


https://www.youtube.com/watch?v=jQj21I634ZE

1 Share

Gaming / Create A Classic Snake Game Using HTML5 And Jquery by skptricks: 5:56pm On Dec 06, 2017
[url="http://www.skptricks.com/2017/12/html5-snake-game.html"]Create A Classic Snake Game Using HTML5 and JQuery[/url]

Today's Post we are going to share a code related to A Classic Snake Game. we have implemented this using HTML5 and JQuery.

html5-snake-game

Lets see the complete example of Snake Game :
game.html
<!DOCTYPE html>
<html>
<head>
<title> Snake Game </title>
<link rel="stylesheet" href="snake.css">
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<style>
#container {
margin: auto;
width: 600px;
}

#myCanvas {
background-color: #000000;
border: 3px red solid;

}

#gameover {
position : absolute;
top: 200px;
left: 600px;
font-size: 25px;
text-align: center;
color: #FFFFFF;
display: none;
}

#score {
width: 600px;
height: 100px;
margin: auto;
background-color: grey;
}

#current, #highest {
font-size : 25px;
color: black;
text-align: center;
}

a {
text-decoration: none;
color : #FFFFFF;
}

span {
color : #FFFFFF;
}
</style>

<script>
$(document).ready(function() {

var canvas = $("#myCanvas"wink[0];
var ctx = canvas.getContext("2d"wink;
var w = $("#myCanvas"wink.width();
var h = $("#myCanvas"wink.height();
var cw = 15;
var food;
var snake;
var d = "RIGHT";

var gameloop = setInterval(update, 100);

function update() {
if (d == "RIGHT"wink
snake.x = snake.x + 1;
else if (d == "LEFT"wink
snake.x = snake.x - 1;
else if (d == "UP"wink
snake.y = snake.y - 1;
else if (d == "DOWN"wink
snake.y = snake.y + 1;

check_borders();
check_food();
blank();
paint_cell(food.x, food.y, "grey"wink;
paint_cell(snake.x, snake.y, "green"wink;
}

function showGameOver() {

var current = $('#current').text();
$('#final').text(current);
$('#gameover').fadeIn();
}

function updateHighScore() {
var current = $("#current"wink.text();
var highest = $("#highest"wink.text();
if (parseInt(current) > parseInt(highest)) {
$('#highest').text(current)
}

}

function placeFood() {
food = {
x : Math.round(Math.random()*(w-cw)/cw),
y : Math.round(Math.random()*(h-cw)/cw)
}
}

function placeSnake() {
snake = {
x : Math.round(Math.random()*(w-cw)/cw),
y : Math.round(Math.random()*(h-cw)/cw)
}
}

function blank(){
//Paint The Canvas
ctx.fillStyle = "black";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "white";
ctx.strokeRect(0, 0, w, h);

}

function check_borders() {
if (snake.x < 0 || snake.x > (w-cw)/cw || snake.y < 0 || snake.y > (h-cw)/cw) {
clearInterval(gameloop);
showGameOver();
}
}

function paint_cell(x,y, color){
ctx.fillStyle=color;
ctx.fillRect(x*cw,y*cw,cw,cw);
ctx.strokeStyle="white";
ctx.strokeRect(x*cw,y*cw,cw,cw);
}

function check_food() {
if (food.x == snake.x && food.y == snake.y) {
var current = parseInt($('#current').text());
current += 1;
$('#current').text(current);
placeFood();
}


}

placeFood();
paint_cell(food.x, food.y, "grey"wink;
placeSnake();
paint_cell(snake.x, snake.y, "green"wink;

//Keyboard Controller
$(document).keydown(function(e){
//39: RIGHT
//37: LEFT
//38: UP
//40: DOWN
var key = e.which;
if(key == "37"wink {
snake.x -= 1;
d = "LEFT";
}
else if(key == "38"wink {
snake.y -= 1;
d = "UP";
}
else if(key == "39"wink {
snake.x += 1;
d = "RIGHT";
}
else if(key == "40"wink {
snake.y += 1;
d = "DOWN";
}

check_food();
blank();
color = "grey";
paint_cell(food.x, food.y);
color = "green";
paint_cell(snake.x, snake.y);

});

});
</script>
</head>
<body>
<div id="container">
<div id="gameover">
Game over!
<br>
Your score is <span id="final"></span>
<br>
<a onClick="window.location.reload()" href="#">Click To Play Again</a>
</div>
<canvas id="myCanvas" width="600" height="450">
Your browser does not support the canvas feature
</canvas>
<div id="score">
<div>Current Score:<span id="current">0</span>
</div>
<div>High Score:<span id="highest">3</span>
</div>
</div>
</div>



</body>
</html>

1 Like

Programming / Create A Classic Snake Game Using HTML5 And Jquery by skptricks: 5:16am On Dec 05, 2017
[url="http://www.skptricks.com/2017/12/html5-snake-game.html"]Create A Classic Snake Game Using HTML5 and JQuery[/url]

Today's Post we are going to share a code related to A Classic Snake Game. we have implemented this using HTML5 and JQuery.

html5-snake-game

Lets see the complete example of Snake Game :
game.html
<!DOCTYPE html>
<html>
<head>
<title> Snake Game </title>
<link rel="stylesheet" href="snake.css">
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<style>
#container {
margin: auto;
width: 600px;
}

#myCanvas {
background-color: #000000;
border: 3px red solid;

}

#gameover {
position : absolute;
top: 200px;
left: 600px;
font-size: 25px;
text-align: center;
color: #FFFFFF;
display: none;
}

#score {
width: 600px;
height: 100px;
margin: auto;
background-color: grey;
}

#current, #highest {
font-size : 25px;
color: black;
text-align: center;
}

a {
text-decoration: none;
color : #FFFFFF;
}

span {
color : #FFFFFF;
}
</style>

<script>
$(document).ready(function() {

var canvas = $("#myCanvas"wink[0];
var ctx = canvas.getContext("2d"wink;
var w = $("#myCanvas"wink.width();
var h = $("#myCanvas"wink.height();
var cw = 15;
var food;
var snake;
var d = "RIGHT";

var gameloop = setInterval(update, 100);

function update() {
if (d == "RIGHT"wink
snake.x = snake.x + 1;
else if (d == "LEFT"wink
snake.x = snake.x - 1;
else if (d == "UP"wink
snake.y = snake.y - 1;
else if (d == "DOWN"wink
snake.y = snake.y + 1;

check_borders();
check_food();
blank();
paint_cell(food.x, food.y, "grey"wink;
paint_cell(snake.x, snake.y, "green"wink;
}

function showGameOver() {

var current = $('#current').text();
$('#final').text(current);
$('#gameover').fadeIn();
}

function updateHighScore() {
var current = $("#current"wink.text();
var highest = $("#highest"wink.text();
if (parseInt(current) > parseInt(highest)) {
$('#highest').text(current)
}

}

function placeFood() {
food = {
x : Math.round(Math.random()*(w-cw)/cw),
y : Math.round(Math.random()*(h-cw)/cw)
}
}

function placeSnake() {
snake = {
x : Math.round(Math.random()*(w-cw)/cw),
y : Math.round(Math.random()*(h-cw)/cw)
}
}

function blank(){
//Paint The Canvas
ctx.fillStyle = "black";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "white";
ctx.strokeRect(0, 0, w, h);

}

function check_borders() {
if (snake.x < 0 || snake.x > (w-cw)/cw || snake.y < 0 || snake.y > (h-cw)/cw) {
clearInterval(gameloop);
showGameOver();
}
}

function paint_cell(x,y, color){
ctx.fillStyle=color;
ctx.fillRect(x*cw,y*cw,cw,cw);
ctx.strokeStyle="white";
ctx.strokeRect(x*cw,y*cw,cw,cw);
}

function check_food() {
if (food.x == snake.x && food.y == snake.y) {
var current = parseInt($('#current').text());
current += 1;
$('#current').text(current);
placeFood();
}


}

placeFood();
paint_cell(food.x, food.y, "grey"wink;
placeSnake();
paint_cell(snake.x, snake.y, "green"wink;

//Keyboard Controller
$(document).keydown(function(e){
//39: RIGHT
//37: LEFT
//38: UP
//40: DOWN
var key = e.which;
if(key == "37"wink {
snake.x -= 1;
d = "LEFT";
}
else if(key == "38"wink {
snake.y -= 1;
d = "UP";
}
else if(key == "39"wink {
snake.x += 1;
d = "RIGHT";
}
else if(key == "40"wink {
snake.y += 1;
d = "DOWN";
}

check_food();
blank();
color = "grey";
paint_cell(food.x, food.y);
color = "green";
paint_cell(snake.x, snake.y);

});

});
</script>
</head>
<body>
<div id="container">
<div id="gameover">
Game over!
<br>
Your score is <span id="final"></span>
<br>
<a onClick="window.location.reload()" href="#">Click To Play Again</a>
</div>
<canvas id="myCanvas" width="600" height="450">
Your browser does not support the canvas feature
</canvas>
<div id="score">
<div>Current Score:<span id="current">0</span>
</div>
<div>High Score:<span id="highest">3</span>
</div>
</div>
</div>



</body>
</html>

2 Likes

Programming / Using Google Recaptcha With PHP - Are You A Robot? by skptricks: 6:47am On Dec 02, 2017
post link : http://www.skptricks.com/2017/12/captcha-code-php-jquery-ajax.html

In this tutorial we are going to share some idea about "Google reCAPTCHA". Google has been introduced reCAPTCHA API called Are you a robot? This protects your website for spammers and robots. You can easily integrate the google reCAPTCHA API in you website.
What is the main purpose of using Captcha?

The technology is used mostly to block spammers and bots that try to automatically harvest email addresses or try to automatically sign up for or make use of Web sites, blogs or forums. CAPTCHA, whose users include Yahoo and Google, blocks automated systems, which can't read the distorted letters in the graphic.

Now we will discuss about reCAPTCHA V2 , which helps to validate the users with "i am not a robot" checkbox. Here we are verifying the user login form using reCAPTCHA with AJAX method.


more details :
------------------------
http://www.skptricks.com/2017/12/captcha-code-php-jquery-ajax.html

source code:
------------------------
http://www.skptricks.com/2017/12/captcha-code-php-jquery-ajax.html

Programming / Re: Jquery Timeago Plugin Implementation Using PHP. by skptricks: 5:58am On Nov 27, 2017
badmus306:
Do u have an idea of a plugin that disable past date on a datePicker, but only shows the current days or days to come

Yes....

var array = ["2017-11-14","2017-03-15","2017-03-16"]

$('input').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ array.indexOf(string) == -1 ]
}
});
Business / Learn Php With Simple Examples... by skptricks: 5:22pm On Nov 26, 2017
Visit : www.skptricks.com
www.skptricks.com/p/php.html

The following list is the table of contents of all tutorials related to PHP. PHP is a server-side scripting language designed primarily for web development but also used as a general-purpose programming language. Here you will get basic and advance level concept about php.

PHP Tutorial :

PHP Basic Concept :

Introduction to PHP
PHP Syntax
PHP Echo
PHP Print
PHP Variables
PHP Constants
PHP Comment Block
PHP Operators
PHP String

PHP Control Statements :

PHP IF-Else Statement
PHP Switch Statement
PHP For Loop
PHP While Loop
PHP Do While Loop
PHP Break Statement
PHP Continue Statement

PHP Magic Constants :
PHP Magic Constants

PHP Function Examples:

PHP Functions
PHP Parameterized Functions
PHP Anonymous functions
PHP Default Argument functions
PHP Variable Length Argument functions
PHP Recursive functions
PHP Call By Value functions
PHP Call By Reference functions

PHP Function Examples:

PHP Arrays
PHP Indexed Arrays
PHP Associative Arrays
PHP Multidimensional Arrays

PHP Control Statements :

PHP String
PHP String Functions

PHP File Handling:

PHP File Handling
PHP Open File
PHP Read File
PHP Write File
PHP Append File
PHP Delete File


PHP Mail Function:

PHP Mail Function
Send Email Using PHP Mailer Script via. Gmail SMTP Server
Send file/attachment to email address using php mail function

PHP Include File:

PHP Include File

PHP Session and Cookies:

PHP Sessions
PHP Cookies
PHP Session Vs Cookies


PHP MySQL Connection

PHP MySQL Connection Overview
PHP Create MySQL Database
PHP Create MySQL Table
PHP Insert Data Into MySQL
PHP Update Data Into MySQL Database
PHP Delete Data From MySQL Database
PHP Select Data From MySQL Database

Miscellaneous Example :
PHP Form Handling
PHP File Upload

PHP MySQL Connection using PDO

PHP MySQL Connection using PDO (CURD OPERATION)


PHP Advance Tutorials:
PHP Tutorials Demo

1 Like

Programming / Jquery Timeago Plugin Implementation Using PHP. by skptricks: 9:46am On Nov 26, 2017
Post link : http://www.skptricks.com/2017/11/timeago-jquery-script-using-php.html

Timeago is a JQuery plugin that provides a easy way to integrate timestamp update functionality in web based application. Nowadays Timeago Plugin is the most important functionality in social networking sites, it helps to update the timestamps automatically at specific interval of time.

In this post we will going to learn how to integrate and timeago Jquery plugin in web application with the help of PHP.

Why Timeago plugin ?
It's support the page caching in your web applications.
Automatically refresh the page and update the timestamp in web application.
Support the HTML5 tags.
Easy to integrate in web applications.

Lets see the below example for Timeago :
index.php
<html>
<head>
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="jquery.timeago.js" type="text/javascript"></script>
<script>
jQuery(document).ready(function() {
jQuery(".timeago"wink.timeago();
});
</script>
</head>
<body>
<?php
$time=time(); // Current timestamp eg: 1371612613
$formatedTime=date("c", $time); // Converts to date formate 2017-06-19T03:30:13+00:00
?>

<h1> You opened this page <a href='#' class='timeago' title="<?php echo $formatedTime; ?>"></a> </h1>

<h1> This page was last modified <a href='#' class='timeago' title="2017-07-17T14:06:04Z"></a> </h1>

NOTE : This will update every minute. Wait for it.

</body>
</html>

Programming / PHP Free Courses by skptricks: 9:24am On Nov 25, 2017
PHP
[url="http://www.skptricks.com/p/php.html"]skptricks php tutorials for beginners[/url]:

The following list is the table of contents of all tutorials related to PHP. PHP is a server-side scripting language designed primarily for web development but also used as a general-purpose programming language. Here you will get basic and advance level concept about php.

visit : http://www.skptricks.com/p/php.html

PHP Tutorial :

PHP Basic Concept :

Introduction to PHP
PHP Syntax
PHP Echo
PHP Print
PHP Variables
PHP Constants
PHP Comment Block
PHP Operators
PHP String

PHP Control Statements :

PHP IF-Else Statement
PHP Switch Statement
PHP For Loop
PHP While Loop
PHP Do While Loop
PHP Break Statement
PHP Continue Statement

PHP Magic Constants :
PHP Magic Constants

PHP Function Examples:

PHP Functions
PHP Parameterized Functions
PHP Anonymous functions
PHP Default Argument functions
PHP Variable Length Argument functions
PHP Recursive functions
PHP Call By Value functions
PHP Call By Reference functions

PHP Function Examples:

PHP Arrays
PHP Indexed Arrays
PHP Associative Arrays
PHP Multidimensional Arrays

PHP Control Statements :

PHP String
PHP String Functions

PHP File Handling:

PHP File Handling
PHP Open File
PHP Read File
PHP Write File
PHP Append File
PHP Delete File


PHP Mail Function:

PHP Mail Function
Send Email Using PHP Mailer Script via. Gmail SMTP Server
Send file/attachment to email address using php mail function

PHP Include File:

PHP Include File

PHP Session and Cookies:

PHP Sessions
PHP Cookies
PHP Session Vs Cookies


PHP MySQL Connection

PHP MySQL Connection Overview
PHP Create MySQL Database
PHP Create MySQL Table
PHP Insert Data Into MySQL
PHP Update Data Into MySQL Database
PHP Delete Data From MySQL Database
PHP Select Data From MySQL Database

Miscellaneous Example :
PHP Form Handling
PHP File Upload

PHP MySQL Connection using PDO

PHP MySQL Connection using PDO (CURD OPERATION)


PHP Advance Tutorials:
PHP Tutorials Demo

1 Like

Education / Live Username Availability Check Using PHP, Jquery And AJAX by skptricks: 6:23am On Nov 15, 2017
In this tutorial we are going to build Live Username Availability Check using PHP, JQuery and AJAX. This is a most common and popular feature in most of the website. Mostly this feature is integrated in Login and Registration page.

In the Registration page, When user entered the desire username in username text field and just after that AJAX call will send the request to PHP page to get the availability status of username in MySQL database. The PHP page find the exact match in the database and returns the result message based on the username availability.
Our Script returns the below message based on username availability :
When Username availability match found in database, it will return message "Username is available".
When Username availability match not found in database, it will return message "Username is not available".

For More details :
http://www.skptricks.com/2017/11/live-username-availability-check-using-php-jquery-ajax.html

Programming / Live Username Availability Check Using PHP, Jquery And AJAX by skptricks: 7:51am On Nov 12, 2017
In this tutorial we are going to build Live Username Availability Check using PHP, JQuery and AJAX. This is a most common and popular feature in most of the website. Mostly this feature is integrated in Login and Registration page.

In the Registration page, When user entered the desire username in username text field and just after that AJAX call will send the request to PHP page to get the availability status of username in MySQL database. The PHP page find the exact match in the database and returns the result message based on the username availability.
Our Script returns the below message based on username availability :
When Username availability match found in database, it will return message "Username is available".
When Username availability match not found in database, it will return message "Username is not available".

For More details :
http://www.skptricks.com/2017/11/live-username-availability-check-using-php-jquery-ajax.html

Programming / Ajax Search Box In PHP, Mysql And Jquery. by skptricks: 7:01am On Nov 11, 2017
[url="http://www.skptricks.com/2017/11/ajax-search-box-in-php-mysql-and-jquery.html"]Skptricks[/url]

In this tutorial we are going to build AJAX search box using PHP. Now a days every website has integrated this kind of search feature. This search box populate the results in real time from MySQL database based on entered text in search box.

This Search box of HTML is completely controlled by JQuery function. On key-up event of input field (e.g. Search Box), This JQuery function send the request to "controller.php" page via. AJAX technique. This request find the best match from MySQL database and display the result in "search.php" page.

Build Live Search Box Using PHP, MySQL and AJAX skptricks

Page link :
---------------------------------------
http://www.skptricks.com/2017/11/ajax-search-box-in-php-mysql-and-jquery.html

Programming / Pdo::fetch_class Vs. Pdo::fetch_props_late by skptricks: 6:55am On Oct 31, 2017

Complete details Link
: http://www.skptricks.com/2017/10/pdofetchclass-vs-pdofetchpropslate.html

PDO::FETCH_CLASS

In our last post we have discussed about PDO::FETCH_CLASS, from which I think you are able to build complete understanding on PDO::FETCH_CLASS. But in this we are going to discuss about few shortcomes about PDO::FETCH_CLASS.

Lets see the below example for PDO::FETCH_CLASS.

<?php
// < Class : user >
// class consists of userdefine functions and variables
class user{

private $USERNAME ;
private $EMAILID ;
private $AGE ;
private $COUNTRY ;
//get the username
public function getUSERNAME(){
return $this->USERNAME ;
}
//get the email id
public function getEMAILID(){
return $this->EMAILID ;
}
//get the age
public function getAGE(){
return $this->AGE ;
}
//get the country
public function getCOUNTRY(){
return $this->COUNTRY ;
}
public function __construct(){
$this->USERNAME = "sumit@gmail.com";

}

}

// < Class : DAO >
// Get the data from database...
Class DAO{

//function return the all the data from database...
public function getAllUserDetails(){

$dbhost ="localhost"; // set the hostname
$dbname ="skptricksdemo" ; // set the database name
$dbuser ="root" ; // set the mysql username
$dbpass =""; // set the mysql password

try {
$dbConnection = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$dbConnection->exec("set names utf8"wink;
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully.<br>";

$stmt = $dbConnection->prepare('SELECT * FROM `userdetails` WHERE `AGE` > 10 ');
$stmt->execute();

$Count = $stmt->rowCount();
echo " Total Records Count : $Count .<br>" ;

if ($Count > 0){
$stmt->setFetchMode(PDO::FETCH_CLASS, "user"wink;

return $obj = $stmt->fetchAll();

}

}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}

}
}


// calling the getAllUserDetails function and retrieve details
$dao = new DAO();
$allUserDetails =$dao->getAllUserDetails();

//echo print_r($allUserDetails);
foreach($allUserDetails as $user)
{
//echo print_r ($UneNews);
echo "<pre>".$user->getUSERNAME()."</pre>" ;
//echo "<pre>".$user->getEMAILID()."</pre>" ;


}

?>


OUTPUT:
-------------------------------
Connected successfully.
Total Records Count : 4 .
sumit@gmail.com
sumit@gmail.com
sumit@gmail.com
sumit@gmail.com

Programming / PDO::FETCH_CLASS Example by skptricks: 5:34pm On Oct 29, 2017
Post link : http://www.skptricks.com/2017/10/pdo-fetch-class-example.html

PDO::FETCH_CLASS helps to maintain the direct relation with class attribute. Basically Returns a new instance of the requested class, mapping the columns of the result set to named properties in the class.
Another useful mode is PDO::FETCH_CLASS, which can create an object of particular class and no need of extra line of codes.
Programming / Display Browser Notifications From Web Application by skptricks: 1:21pm On Oct 28, 2017
Browser desktop notification system helps to push the new updates notification in web application using browser. This notification system is quite bit similar to android notification. we are providing the source which helps you to integrate notification system in application and through which you get the real time updates.

Note: Use this Chrome and Firefox Browser.
Desktop Notification - Best Push Notifications Online skptricks

lets check the source code in below link :
http://www.skptricks.com/2017/10/display-browser-notifications-from-web.html

Education / Secure User Password In Login And Registration Page by skptricks: 6:39am On Oct 28, 2017
In this post, we are providing some techniques and ideas to secure you webpage login and registration page. Now a days security is more important to all of us as it protects website from unauthorized access.
Here we will share some information in which you learn how to secure user password field of login page using PHP language. To secure user password field in login and registration page, we are using two PHP functions, which are as follows :
password_hash() Function.
password_verify() Function.

for more info follow the below link :
http://www.skptricks.com/2017/10/password-hash-and-password-verify-using-user-login-page.html

Programming / Secure User Password In Login And Registration Page by skptricks: 5:28am On Oct 26, 2017
In this post, we are providing some techniques and ideas to secure you webpage login and registration page. Now a days security is more important to all of us as it protects website from unauthorized access.
Here we will share some information in which you learn how to secure user password field of login page using PHP language. To secure user password field in login and registration page, we are using two PHP functions, which are as follows :
password_hash() Function.
password_verify() Function.

for more info follow the below link :
http://www.skptricks.com/2017/10/password-hash-and-password-verify-using-user-login-page.html

Programming / Re: Can Someone Learn PHP In Four Contact by skptricks: 12:58am On Oct 26, 2017

1 Like

(1) (2) (3) (4) (5) (of 5 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 116
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.