Skip to content

Instantly share code, notes, and snippets.

View rajeshpillai's full-sized avatar

Rajesh Pillai rajeshpillai

View GitHub Profile
@rajeshpillai
rajeshpillai / 00.md
Created February 11, 2020 06:48 — forked from maxivak/00.md
Selenium tests on Ruby

Selenium tests on Ruby

Install

gems:

  • gem 'capybara', '2.10.1'
  • gem 'selenium-webdriver', '3.0.3'

Selenium

Virtual DOM and diffing algorithm

There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.

However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.

@rajeshpillai
rajeshpillai / app.js
Last active October 28, 2019 10:21 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
@rajeshpillai
rajeshpillai / index.html
Created April 29, 2017 17:36 — forked from anonymous/index.html
JS Bin A better browser console log // source https://jsbin.com/qamiqiw
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="A better browser console log">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.console-container {
position: absolute;
@rajeshpillai
rajeshpillai / index.html
Created April 29, 2017 17:18 — forked from anonymous/index.html
JS Bin A better browser console log // source https://jsbin.com/qamiqiw
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="A better browser console log">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.console-container {
position: absolute;
@rajeshpillai
rajeshpillai / bench_rails_memory_usage.rb
Created January 27, 2016 18:09 — forked from brianhempel/bench_rails_memory_usage.rb
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@rajeshpillai
rajeshpillai / gear.md
Last active August 29, 2015 14:10 — forked from joelhooks/gear.md
@rajeshpillai
rajeshpillai / gesture.js
Last active August 29, 2015 14:07 — forked from eguneys/gesture.js
'use strict';
define(['phaser'], function(Phaser) {
function Gesture(game) {
this.game = game;
this.swipeDispatched = false;
this.holdDispatched = false;
this.isTouching = false;
/// <summary>
/// Extension method that turns a dictionary of string and object to an ExpandoObject
/// </summary>
public static ExpandoObject ToExpando(this IDictionary<string, object> dictionary)
{
var expando = new ExpandoObject();
var expandoDic = (IDictionary<string, object>)expando;
// go through the items in the dictionary and copy over the key value pairs)
foreach (var kvp in dictionary)