Skip to content

Instantly share code, notes, and snippets.

@mihirsoni
mihirsoni / setup-kubernetes-ubuntu-16.md
Created June 23, 2019 00:51 — forked from ruanbekker/setup-kubernetes-ubuntu-16.md
Install a 3 Node Kubernetes Cluster on Ubuntu 16

Master: Dependencies

apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
padding:0;
}
@mihirsoni
mihirsoni / app.js
Created September 14, 2016 07:43 — 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) {
getComponent().then(Component => {
@mihirsoni
mihirsoni / Sublime Settings.md
Last active July 28, 2019 09:26
My Sublime Text Config

A fresh Installation for Sublime Text

  • Download and install Sublime Text 3

Install Package Control

Install Package Control for easy package management.

  1. Open the console with Ctrl+`
  2. Paste in the following:
@mihirsoni
mihirsoni / slim-redux.js
Created April 20, 2016 08:52 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@mihirsoni
mihirsoni / WishThankyou.py
Created August 31, 2013 14:54
This is python script to thank people on your wall whoever wished you on your birthday. I patched up this script and make it work :-) Thanks to Quora ;)
import requests
import datetime
import time
import json
#Get the access token from https://developers.facebook.com/tools/explorer with publish permission & paste it here :)
TOKEN = ''
BIRTH_DATE = '08/30/1989'
def get_posts():