Category : "Coding"

All kinds of Programming.

Monitor progress of long running php scripts with html5 server sent events

Server sent events When running a long serverside task inside a web application it becomes very useful, if not necessary to report the progress of that task in realtime to the clientside, that is the browser. Earlier there was no easy way to do this and hacks had to be constructed to achieve such a realtime notification. Classical solutions include ajax ...

Get the play time and bitrate of an mp3 in php

If your php application is processing media files like mp3, then it might need to find details of the mp3 file like its playtime, bitrate, encoder etc. There is a very useful php library called Getid3 that can extract information from mp3 files. Its written in pure php and does not have any dependencies. Needs php 5.0+. Get it here http://getid3.sourceforge.net/ Here is ...

Php array of iso 3316 country list

Php applications often need to present the user with a list of countries to select his home country from. The iso 3316 country list contains the name of the countries along with the 2 letter codes. Check out the following project on github that contains the uptodate list of the countries in various formats. https://github.com/umpirsky/country-list Here is a sample of the array <?php ...

Websockets with php – tutorial on basics

Websockets Websockets is a new feature available in browsers as a part of the Html5 specs that allows javascript clients to open bi directional socket connections to a server. Currently all major desktop browsers support the api. Websocket is not an independant socket protocol, but is based on the TCP protocol just like HTTP. Therefore websocket connections are basically tcp socket connections ...

Revolute joint in box2d in javascript

Revolute Joint Revolute joint is a useful joint in box2d that allows 2 bodies to be pinned together at a point without restricting rotation. Lets take an example The joint can be made between 2 dynamic bodies or between a static and dynamic body. The pendulum on left is a static circle joined to dynamic rectangle. Whereas the cart with 2 wheels ...

Weld joint in box2d in javascript

Weld joint in box2d The weld joint can be used to join to bodies tightly at a common point. Here is an example A weld joint is created like this //create distance joint between b and c var joint_def = new b2WeldJointDef(); joint_def.bodyA = b; joint_def.bodyB = c; //connect the centers - center in local coordinate - relative to body is 0,0 joint_def.localAnchorA ...

Make a rope using box2d in javascript

Rope In this experiment we shall make a rope like thing in box2d. There is no rope like structure that box2d supports directly. But if multiple small units are connected together at their edges using a revolutejoint, then it was act somewhat like a rope. Lets take a look You can move any part of the rope using your mouse. Now in this ...

Distance joint in box2d in javascript

Distance In the previous post on mouse joints we learned how to interact with box2d objects using the mouse. Now its time to take a look at another joint in box2d, the distance joint. Distance joint connects 2 bodies maintaining a fixed distance between them, its like metal wire connecting the 2 bodies, such that the wire would neither expand nor ...

Playing with the mouse joint in box2d in javascript

Mouse Joint Out of the many joints that box2d has, one is mouse joint. It is not used in physics simulations, but helps to make the physics world interactive by making a body move towards a specific point, like the mouse coordinates for example. So objects can be picked up, dragged etc by the user. Lets take an example Pickup an object by ...

Add custom functions to the html5 audio element for better functionality

Html5 Audio The html5 audio element provides a simple api to play sound files like mp3, ogg, wav etc. It can be created by putting an audio tag in the html or by creating an instance of the Audio object in javascript. Here is a quick example of using it from within javascript code. var aud = new Audio(); aud.src = 'path/to/song.ogg'; aud.play(); That much ...

Pages:«1234567...19»


Connect with us