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
  • 09:03 (UTC +05:30)
  • X @rkkth
View GitHub Profile
@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';
@bantya
bantya / bookmarked.php
Created October 21, 2016 04:21 — forked from xeoncross/bookmarked.php
Simple, PHP-based bookmark system so you can save internet pages. Uses HTTP Digest for Auth and PDO-SQLite extension (built-in).
<?php
// Place the DB files outside of the public web directory so people don't download it!
define('DB', 'links.sq3');
// Number of seconds a user must wait to post another link (false to disable)
define('WAIT', false);
// Should we enforce IP checking? (false to disable)
define('IP_CHECK', false);
@bantya
bantya / auto_relation.php
Created October 21, 2016 05:03 — forked from xeoncross/auto_relation.php
Make every record returned by PDO an ORM class that can load it's own relations. This is just a simple concept idea. The record objects can figure out what table they belong to from their keys and what we know of the schema.
<?php
define('START_TIME', microtime(TRUE));
register_shutdown_function(function() {
print dump(round(microtime(TRUE) - START_TIME, 3) . ' seconds');
print dump(round(memory_get_peak_usage() / 1024) . " kb peak usage");
print dump(DB::$q);
});
@bantya
bantya / markdown_limited.php
Last active October 21, 2016 08:47 — forked from xeoncross/example.php
Markdown Limited - a small, fast, safe markdown function in PHP
<?php
/**
* Parse the text with *limited* markdown support.
*
* @param string $text
* @return string
*/
function markdown_limited($text)
{
// Make it HTML safe for starters