Skip to content

Instantly share code, notes, and snippets.

View Shobhit1's full-sized avatar
🎧
Remote work!

Shobhit Shobhit1

🎧
Remote work!
View GitHub Profile
export default class InfiniteLoader extends Component {
  componentDidMount() {
    window.addEventListener('scroll', this.handleScroll.bind(this))
  }

  componentWillUnMount() {
    window.removeEventListener('scroll', this.handleScroll.bind(this))
  }
@Shobhit1
Shobhit1 / readme.md
Created June 24, 2016 05:09 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

const nameToURL = name => encodeURIComponent(
name.split(' ')
.map(str => str.toLowerCase())
.join('-')
)
export const deepCompareObjects = (obj1, obj2) => {
// Create arrays of property names
const obj1Props = Object.getOwnPropertyNames(obj1)
const obj2Props = Object.getOwnPropertyNames(obj2)
// If number of properties is different, objects are not equivalent
if (obj1Props.length !== obj2Props.length) {
return false
}
for (let i = 0; i < obj1Props.length; i++) {
const propName = obj1Props[i]
@Shobhit1
Shobhit1 / garbage_collect.rb
Created April 11, 2017 15:30
Garbage collect Symbols
# Symbol GC test
require 'java'
java_import 'java.lang.System'
before = Symbol.all_symbols.size
100_000.times do |i|
"sym#{i}".to_sym
@Shobhit1
Shobhit1 / change-favicon.js
Created May 21, 2017 21:29 — forked from mathiasbynens/change-favicon.js
Dynamically changing favicons with JavaScript
/*!
* Dynamically changing favicons with JavaScript
* Works in all A-grade browsers except Safari and Internet Explorer
* Demo: http://mathiasbynens.be/demo/dynamic-favicons
*/
// HTML5™, baby! http://mathiasbynens.be/notes/document-head
document.head || (document.head = document.getElementsByTagName('head')[0]);
function changeFavicon(src) {
@Shobhit1
Shobhit1 / js-tricky-bits.md
Last active July 2, 2017 15:26 — forked from amysimmons/js-tricky-bits.md
Understanding closures, callbacks and promises in JavaScript

Understanding closures, callbacks and promises

For a code newbie like myself, callbacks, closures and promises are scary JavaScript concepts.

10 months into my full-time dev career, and I would struggle to explain these words to a peer.

So I decided it was time to face my fears, and try to get my head around each concept.

Here are the notes from my initial reading. I'll continue to refine them as my understanding improves.

@Shobhit1
Shobhit1 / spec_helper_jest.js
Created July 10, 2017 13:52 — forked from gdborton/spec_helper_jest.js
This bit of code essentially bridges the Mocha/Jest api so that Jest can be used in place of Mocha.
// There are other differences between Jest and Mocha,
// but these were the functions being used at Airbnb.
global.context = describe;
global.before = beforeAll;
global.after = afterEach;
@Shobhit1
Shobhit1 / index.html
Created August 29, 2017 18:08 — forked from anonymous/index.html
Slider using JS, HTML and CSS
<div class="slider">
<button id="previous-button">Previous</button>
<div class="item-container selected"></div>
<div class="item-container"></div>
<div class="item-container"></div>
<div class="item-container"></div>
<div class="item-container"></div>
<button id="next-button">Next</button>
</div>
</div>
call plug#begin('~/.vim/plugged')
" Syntax and language specific
Plug 'tpope/vim-git'
Plug 'tasn/vim-tsx'
Plug 'vim-ruby/vim-ruby'
Plug 'othree/html5.vim'
Plug 'othree/jsdoc-syntax.vim'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'leshill/vim-json'