Skip to content

Instantly share code, notes, and snippets.

View RahulReddy75's full-sized avatar

Rahul RahulReddy75

View GitHub Profile
@RahulReddy75
RahulReddy75 / enzyme_render_diffs.md
Created July 8, 2019 08:44 — forked from fokusferit/enzyme_render_diffs.md
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@RahulReddy75
RahulReddy75 / Update remote repo
Created September 5, 2018 14:41 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@RahulReddy75
RahulReddy75 / web-servers.md
Created April 11, 2016 07:47 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
// Bonfire: Sum All Numbers in a Range
// Author: @rahul1992
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-numbers-in-a-range?solution=function%20sumAll(arr)%20%7B%0A%20%20var%20max%20%3D%20Math.max(...arr)%3B%0A%20%20var%20min%20%3D%20Math.min(...arr)%3B%0A%20%20%2F%2F%20The%20formulate%20to%20sum%20a%20series%20of%20integers%20is%0A%20%20%2F%2F%20n%20%3D%20(max-min)%2B1%0A%20%20%20%20%2F%2F%20n%20*%20(max%20-%20min%20%2F%202)%2C%20where%20n%20is%20the%20length%20of%20the%20series.%0A%20%20%20return%20((max-min)%2B1)%20*%20(min%20%2B%20max)%20%2F%202%3B%0A%7D%0A%0AsumAll(%5B4%2C%2010%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function sumAll(arr) {
var max = Math.max(...arr);
var min = Math.min(...arr);
// The formulate to sum a series of integers is
// n = (max-min)+1
// Bonfire: Diff Two Arrays
// Author: @rahul1992
// Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays?solution=function%20diff(arr1%2C%20arr2)%20%7B%0A%20%20var%20newArr%20%3D%20arr1.concat(arr2)%3B%0A%20%20function%20found(item)%7B%0A%20%20%20%20if(arr1.indexOf(item)%20%3D%3D%3D%20-1%20%7C%7C%20arr2.indexOf(item)%20%3D%3D%3D%20-1)%7B%0A%20%20%20%20%20%20return%20item%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20newArr.filter(found)%3B%0A%7D%0A%0Adiff(%5B1%2C%202%2C%203%2C%205%5D%2C%20%5B1%2C%202%2C%203%2C%204%2C%205%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function diff(arr1, arr2) {
var newArr = arr1.concat(arr2);
function found(item){
if(arr1.indexOf(item) === -1 || arr2.indexOf(item) === -1){
return item;