Skip to content

Instantly share code, notes, and snippets.

View bijayrungta's full-sized avatar

Bijay Rungta bijayrungta

View GitHub Profile
<?php
/**
* Get upcomming match schedule
*/
function getNextMatches($referenceTime = null)
{
$matchSchedule = array(
"2014-06-13 01:30:00" => array('team1' => 'BRA', 'team2' => 'CRO', 'date' => '2014-06-13 01:30:00', 'team1Class' => 'brazil', 'team2Class' => 'croatia'),
"2014-06-13 21:30:00" => array('team1' => 'MEX', 'team2' => 'CMR', 'date' => '2014-06-13 21:30:00', 'team1Class' => 'mexico', 'team2Class' => 'cameroon'),
@bijayrungta
bijayrungta / redirection-and-page-load-time.php
Last active December 18, 2015 01:48
This Snippet demonstrates how Redirection time is also counted towards User perceived Page Load time using
<?php
if (!empty($_GET['redir']) && $_GET['redir'] < 11) {
sleep(1);
$url = '?redir=' . ($_GET['redir'] + 1);
header("Location: {$url}");
exit;
}
?><!DOCTYPE html>
<html>
<head>
<?php
if (class_exists('Memcache')) {
$server = 'localhost';
if (!empty($_REQUEST['server'])) {
$server = $_REQUEST['server'];
}
$memcache = new Memcache;
$isMemcacheAvailable = @$memcache->connect($server);
if ($isMemcacheAvailable) {
@bijayrungta
bijayrungta / tableDump.js
Created November 25, 2011 22:46
Get number of Rows for Tables from phpMyAdmin
o = document.getElementsByClassName('data')[0];
str = "";
for (i = 1; i < o.rows.length - 1; i++) {
str += o.rows[i].cells[1].getElementsByTagName('a')[0].innerHTML
+ ": " + o.rows[i].cells[8].innerHTML
+ "\n";
}
alert(str);
@bijayrungta
bijayrungta / gist:784751
Created January 18, 2011 17:02
Check all Checkboxes in a Web page.
a = document.getElementsByTagName('input');
for (i=0;i<a.length;i++) {
if (a[i].type == 'checkbox') {
a[i].checked = true;
}
}
@bijayrungta
bijayrungta / yii-ar-rules.php
Last active September 24, 2015 17:37
Validation Rules for the Model.
class MyModel {
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return array(
array(
'element',