Skip to content

Instantly share code, notes, and snippets.

View rmdort's full-sized avatar

Vinay M rmdort

View GitHub Profile
@rmdort
rmdort / toNestedArray
Last active January 17, 2017 02:53
Solr path hierarchy to Javascript object
function toNestedArray (data, rootLevel = 0, parentNode) {
let output = []
for (var i = 0; i < data.length; i++) {
var count = data[i].count
var items = data[i].name.split('/')
var hasParent = items.length > rootLevel
if (hasParent) {
let parent = rootLevel
? items.length === rootLevel
? null
from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory, listenWS
from twisted.python import log
from autobahn.util import newid, utcnow
import Cookie
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from chatterbot.conversation import Statement
from users import Users
import sys

Open session Modal

MOM.modal.openSessionModal(options);

Options

title: 'Your session is about to expire',
message: 'You will be logged out in <strong>{time}</strong> seconds. Do you want to stay logged in?',

confirm_action: 'javascript:fnConfirmSessionExtend()',

// Create transport if the browser can provide an xhr
if ( xhrSupported ) {
jQuery.ajaxTransport(function( options ) {
// Cross domain only allowed if supported through XMLHttpRequest
if ( !options.crossDomain || support.cors ) {
var callback;
return {
<blockquote>
<p>Written with <a href="https://stackedit.io/">StackEdit</a>.</p>
</blockquote>
@rmdort
rmdort / gist:10022895
Last active August 29, 2015 13:58
Regex Pick shortcode from html
$pattern = '/(?(?=<\S*>)<\S*>|)\s*(\[[a-z|A-Z|-|\/|\s|\"|\=]*\])\s*(?(?=<\/\S*>)<\/\S*>|)/';
$html = '<p>
[highlight type="note"]You and your confinement nanny are bound by the basic Work Permit conditions. For example, the nanny cannot work for other employers in an occupation other than that stated in the Work Permit.[/highlight]</p>';
$filtered = preg_replace($pattern, '$1', $html);
// Returns
/*

The BBC has a server-side image service which provides developers with multiple sized versions of any image they request. It works in a similar fashion to http://placehold.it/ but it also handles the image ratios returned (where as placehold.it doesn't).

The original BBC News process (and my re-working of the script) follows roughly these steps...

  • Create new instance of ImageEnhancer
  • Change any divs within the page (which have a class of delayed-image-load) into a transparent GIF using a Base64 encoded string.
    • We set the width & height HTML attributes of the image to the required size
    • We know what size the image needs to be because each div has custom data-attr set server-side to the size of the image
    • We then set a class of image-replace onto each newly created transparent image
  • We use a 250ms setTimeout to unblock the UI thread and which calls a function resizeImages which enhances the image-replace images so their source is now set to a URL whe
@rmdort
rmdort / index.html
Last active December 15, 2015 15:39
A simple Sidemenu for mobile. Using translate3d
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@rmdort
rmdort / jquery.parallax.js
Created January 16, 2013 16:38
A simple jquery parallax
$window = $(window);
$('section').each(function(){
var $this = $(this); // assigning the object
var off = $this.offset().top;
$this.data("top", off);
$(window).bind('resize scroll', function() {
@rmdort
rmdort / index.html
Created June 26, 2012 01:47
A web page created at CodePen.io
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Simple Gauge &middot; CodePen</title>
<style>