Skip to content

Instantly share code, notes, and snippets.

@bmkmanoj
bmkmanoj / frontendDevlopmentBookmarks.md
Created January 10, 2017 17:29 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
@bmkmanoj
bmkmanoj / main.js
Created January 15, 2017 05:35 — forked from cem2ran/main.js
React Getting Started - How it should be!
import React from 'react'
import ReactDOM from 'react-dom'
const Hello = ({name}) => <h1>Hello {name}!</h1>
ReactDOM.render(
<Hello name={"vjeux"}/>,
document.body.appendChild(document.createElement("div"))
)
(function($, window, undefined) {
var InfiniteScroll = function() {
this.initialize = function() {
this.setupEvents();
};
this.setupEvents = function() {
$(window).on(
'scroll',
this.handleScroll.bind(this)
@bmkmanoj
bmkmanoj / CH4.html
Created January 22, 2017 07:56 — forked from dd3141592/CH4.html
crib notes and some examples from "JavaScript Patterns" by Stoyan Stefanov //Chapter 4 Functions
<!DOCTYPE html>
<html>
<head>
<meta name="CH 4 functions" content="Javascript Patterns">
<meta charset="utf-8">
<title>JS Bin</title>
</headJavascript patterns
<body>
Javascript Patterns, by Stoyan Stefanov (O'Reilly). Copyright 2010 Yahoo!, Inc., 9780596806750.
<script id="jsbin-javascript">
@bmkmanoj
bmkmanoj / permutations.js
Created February 6, 2017 20:59 — forked from mitrakmt/permutations.js
All permutations of a set interview challenge.
function getAllPermutations(string) {
var results = [];
if (string.length === 1) {
results.push(string);
return results;
}
for (var i = 0; i < string.length; i++) {
var firstChar = string[i];
@bmkmanoj
bmkmanoj / combinations.js
Created February 6, 2017 21:04 — forked from axelpale/combinations.js
JavaScript functions to calculate combinations of elements in Array.
/**
* Copyright 2012 Akseli Palén.
* Created 2012-07-15.
* Licensed under the MIT license.
*
* <license>
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
@bmkmanoj
bmkmanoj / find-in-json.js
Created April 13, 2017 06:00 — forked from iwek/find-in-json.js
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
@bmkmanoj
bmkmanoj / eventemitter.js
Created April 17, 2017 06:43 — forked from mudge/eventemitter.js
A very simple EventEmitter in pure JavaScript (suitable for both node.js and browsers).
/* Polyfill indexOf. */
var indexOf;
if (typeof Array.prototype.indexOf === 'function') {
indexOf = function (haystack, needle) {
return haystack.indexOf(needle);
};
} else {
indexOf = function (haystack, needle) {
var i = 0, length = haystack.length, idx = -1, found = false;
@bmkmanoj
bmkmanoj / ClassLoaderLeakExample.java
Created April 23, 2017 07:33 — forked from dpryden/ClassLoaderLeakExample.java
Example of a ClassLoader leak in Java
import java.io.IOException;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
/**
* Example demonstrating a ClassLoader leak.
*
* <p>To see it in action, copy this file to a temp directory somewhere,
@bmkmanoj
bmkmanoj / what-forces-layout.md
Created April 25, 2017 17:18 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()