Skip to content

Instantly share code, notes, and snippets.

View bantya's full-sized avatar
🎯
Focussing

Rahul Thakare bantya

🎯
Focussing
  • http://127.0.0.1:4200
  • http://127.0.0.1:8080
  • 07:45 (UTC +05:30)
  • X @rkkth
View GitHub Profile
@bantya
bantya / html5-data.js
Created June 9, 2016 12:56 — forked from remy/html5-data.js
data-* support
(function () {
var forEach = [].forEach,
regex = /^data-(.+)/,
dashChar = /\-([a-z])/ig,
el = document.createElement('div'),
mutationSupported = false,
match
;
function detectMutation() {
(function () {
function detectMutation() {
mutationSupported = true;
this.removeEventListener('DOMAttrModified', detectMutation, false);
}
var forEach = [].forEach,
regex = /^data-(.+)/,
el = document.createElement('div'),
mutationSupported = false;
// Loads js files
function loadScripts(urlArray,cb) {
var scriptLoadCount = scriptLoadedCount = 0;
loadScript();
function loadScript() {
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
var url = (urlArray[scriptLoadCount].indexOf('?') == -1) ? urlArray[scriptLoadCount] + '?d=' + Math.random() : urlArray[scriptLoadCount] + '&d=' + Math.random()
@bantya
bantya / gist:b73316c3e44f0540c9661f74f43b86b1
Created June 18, 2016 11:50
JavaScript: Check if ghost click
//check if click event firing twice on same position.
var last_click_time = new Date().getTime();
function gc(e){
var click_time = e['timeStamp'];
if (click_time && (click_time - last_click_time) < 1000) {
e.stopImmediatePropagation();
return false;
}
last_click_time = click_time;
return true;
@bantya
bantya / gist:982557e77c4923325cb538bd5d7f3724
Created June 18, 2016 11:50
JavaScript: Event type, returns appropriate event type for device based on the parameter passed to it
// Function returns appropriate event type for device based
// on the parameter passed to the function
var et = function(t) {
var msPointer = window.navigator.msPointerEnabled;
var isTouchDevice = (typeof(window.ontouchstart) != 'undefined') ? true : false;
var clickArray = ['c','click','mousedown','down','touchstart'];
var releaseArray = ['r','release','up','mouseup','touchend'];
var moveArray = ['m','move','mousemove','touchmove','drag'];
var eventType = '';
@bantya
bantya / extend_array.js
Last active August 13, 2016 17:59
Extending Array with a Getter
var X = function () {
var self = this;
Object.defineProperty(self, 'abc', {get: function () { return 1; }});
};
// Extending & closing the loop
X.prototype = Array.prototype;
X.prototype.constructor = X;
// Works as you'd expect
@bantya
bantya / VideoStream.php
Created October 14, 2016 17:58 — forked from ranacseruet/VideoStream.php
PHP VideoStream class for HTML5 video streaming
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@bantya
bantya / hacks.css
Created October 21, 2016 04:01 — forked from sepehr/hacks.css
CSS: Selector Hacks
/**
* CSS Selector Hacks.
*/
/* IE6 and below */
* html #uno { color: red }
/* IE7 */
*:first-child+html #dos { color: red }
@bantya
bantya / example.php
Created October 21, 2016 04:04 — forked from niksudan/example.php
Region categorizer [PHP]
<?php
$regions = new Regions('General');
$regions->add('North', 54.5742270, -1.2349560);
$regions->add('North West', 53.9690089, -2.6276908);
$regions->add('East Anglia', 52.6308859, 1.2973550);
$regions->add('Midlands', 52.6368778, -1.1397592);
$regions->add('Wales', 52.1306607, -3.7837117);
$regions->add('South East', 50.7680350, 0.2904720);
$regions->add('Scotland', 56.4906712, -4.2026458);
$regions->add('South West', 50.7772135, -3.9994610);
@bantya
bantya / index.php
Created October 21, 2016 04:10 — forked from xeoncross/index.php
Tiny, SMTP client in PHP
<?php
/*
This is a very tiny proof-of-concept SMTP client. Currently it's over 320 characters (if the var names are compressed). Think you can build one smaller?
*/
ini_set('default_socket_timeout', 3);
$user = '[email protected]';
$pass = '';
$host = 'ssl://smtp.gmail.com';