Skip to content

Instantly share code, notes, and snippets.

View kpunith8's full-sized avatar
🏠
Working from home

Punith K kpunith8

🏠
Working from home
View GitHub Profile
@kpunith8
kpunith8 / webdev_online_resources.md
Created July 27, 2018 10:18 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@kpunith8
kpunith8 / LoginController.js
Created August 3, 2018 08:39
Calling rest services - using axios
import axios from 'axios';
const getUsers = (id) => {
return axios.get('http://localhost:3000/users/'.concat(id));
}
const validateUser = (userName, password) => {
// if (userName.length > 0 && password.length > 0) {
// return true;
// }
@kpunith8
kpunith8 / App.js
Created August 3, 2018 08:44
Calling axios in react
import React, { Component } from 'react';
import './App.css';
import { BrowserRouter as Router } from 'react-router-dom';
import Nav from './Nav';
import LoginForm from './components/LoginForm';
import Welcome from './components/Welcome';
import { getUsers, validateUser } from './controllers/LoginController';
class App extends Component {
constructor(props) {
@kpunith8
kpunith8 / App1.js
Last active September 15, 2018 07:44
Fixing re-rendering of the links
import React, { Component } from 'react'
const sampleList = [{
name: 'Punith',
link: '[email protected]'
},
{
name: 'Rama',
link: '[email protected]'
}];
@kpunith8
kpunith8 / MockitoBehaviour.java
Created April 25, 2019 05:55 — forked from dimosr/MockitoBehaviour.java
Mockito when/thenReturn & doReturn/when patterns behaviour
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.Map;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@kpunith8
kpunith8 / terminal-git-branch-name.md
Created September 10, 2019 10:32 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@kpunith8
kpunith8 / Dockerfile
Created March 3, 2020 09:57 — forked from remarkablemark/Dockerfile
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@kpunith8
kpunith8 / showInfoTip.js
Last active July 4, 2020 05:38
React Testing Library Helpers
// A helper for RTL
export const expandSelect = selectInput => {
if (_.toLower(selectInput.tagName) !== 'input') {
selectInput = selectInput.querySelector('input')
}
fireEvent.mouseDown(selectInput)
fireEvent.focus(selectInput)
}
export const showInfoTip = async infoTip => {
@kpunith8
kpunith8 / LoginUseReducerTypeScript.tsx
Created May 15, 2020 11:34
Login useReducer with types
import React, { useReducer } from 'react';
import { login } from './utils';
const initialState: LoginState = {
username: '',
password: '',
isLoading: false,
error: '',
isLoggedIn: false,
variant: 'login',
@kpunith8
kpunith8 / Container.js
Last active June 16, 2020 12:53
Sticky Nav Bar - In react with css module using gastby
import React from "react"
import containerStyles from "./container.module.css"
const Container = ({ children }) => {
return <div className={containerStyles.container}>{children}</div>
}
export default Container