Skip to content

Instantly share code, notes, and snippets.

Rahul Shetty rashtay

Block or report user

Report or block rashtay

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rashtay
rashtay / retry-api-call.js
Created Apr 25, 2019
If the API fails then this code will help in retrying the call
View retry-api-call.js
(function() {
sleep = ms => {
return new Promise(resolve => setTimeout(resolve, ms));
};
async function getTokenFromApi() {
let retries = 2;
async function poll(apiCallback) {
let response = {};
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@rashtay
rashtay / pre-commit-eslint
Last active May 23, 2019
Pre-commit hook for Linting JS with ESLint before commit.
View pre-commit-eslint
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
ESLINT="$(git rev-parse --show-toplevel)/node_modules/.bin/eslint"
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
View Flatten an array
/**
* Flatten an array
* E.g [[1,2,[3]],4] -> [1,2,3,4]
*
* @Contributor Rahul Shetty <rahulshetty@helpshift.com>
* @created Wed Feb 15 12:40:37 2017
*/
function flattenNestedArray(arr) {
var result = [];
@rashtay
rashtay / .eslintrc
Last active Nov 16, 2016
Ideal eslintrc file for projects built with JavaScript tech stack. Suggestions for improvements are most welcome. Remove react and json from plugins array if you don't wanna use it.
View .eslintrc
{
// I want to use babel-eslint for parsing!
"parser": "babel-eslint",
"extends": "airbnb",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
@rashtay
rashtay / .gitignore
Last active Jul 12, 2018
An extensive list of file and folder names to be ignored while working on a node, angular, react and similar types of project. I have referred various gists and sites to prepare this list. Feel free to provide feedbacks.
View .gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-error.log
libpeerconnection.log
# Runtime data
pids
*.pid
@rashtay
rashtay / head-room.js
Created Jun 12, 2016
Auto show hide sliding header using pure javascript
View head-room.js
import classie from 'desandro-classie';
export function SlidingHeader(options) {
this.init(options);
}
SlidingHeader.prototype.init = function(options) {
// Define the settings as an object
let settings = {
'element': options.element,
@rashtay
rashtay / head-room-with-interval.js
Last active Jun 12, 2016
Auto show hide sliding header with setInterval using pure javascript
View head-room-with-interval.js
import classie from 'desandro-classie';
export function SlidingHeader(options) {
this.init(options);
}
SlidingHeader.prototype.init = function(options) {
// Define the settings as an object
let settings = {
'element': options.element,
You can’t perform that action at this time.