Skip to content

Instantly share code, notes, and snippets.

View vslala's full-sized avatar

Varun Shrivastava vslala

View GitHub Profile
@vslala
vslala / JWTService.java
Created March 6, 2018 07:48
JWT Implementation Demo - JWTService.java
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.bma.jwt.app.vo.JWTPayload;
import com.bma.jwt.app.vo.User;
import com.google.gson.Gson;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
@vslala
vslala / SpotMemoryLeak.java
Created March 5, 2019 13:58
Spot memory leak
// Can you spot the "memory leak"?
public class Stack {
private Object[] elements;
private int size = 0;
private static final int DEFAULT_INITIAL_CAPACITY =
16;
public Stack() {
elements = new Object[DEFAULT_INITIAL_CAPACITY];
}
public void push(Object e) {
import { createStore } from 'redux';
import reducers from '../reducers';
const initialState = {tech: "React JS"};
const store = createStore(reducers, initialState);
export default store;
import * as Type from '../actions/constants';
export default (state, action) => {
console.log(action);
if (action.type === Type.SET_TECHNOLOGY) {
return {
...state,
tech: action.text
@vslala
vslala / ButtonGroup.js
Created July 6, 2019 14:05
ButtonGroup react component to render buttons
import React from "react";
import "../../actions";
import setTechnology from "../../actions";
import store from '../../store';
export default function ButtonGroup({technologies = []}) {
const dispatchAction = (e) => {
const tech = e.target.dataset.tech;
console.log("Tech: " + tech);
@vslala
vslala / HelloWorld.js
Created July 6, 2019 14:06
Hellow World component for hello world application
import React, {useState} from "react";
import { useSelector } from 'react-redux';
export default function HelloWorld() {
const tech = useSelector(state => state.tech);
return (
<h1>
Say Hello To: {tech}
@vslala
vslala / App.js
Created July 6, 2019 14:08
App - The main file that bootstraps the entire hello world react application with redux
import React from 'react';
import logo from './logo.svg';
import './App.css';
import HelloWorld from './components/HelloWorld';
import { Provider } from 'react-redux';
import store from './store';
import ButtonGroup from './components/ButtonGroup';
function App() {
return (
@vslala
vslala / Brewfile
Last active February 14, 2021 08:32
Updated frequently
brew "asdf"
brew "adr-tools"
brew "curl"
brew "diff-so-fancy"
brew "direnv"
brew "ffmpeg"
brew "git"
brew "git-secret"
brew "gnu-sed"
brew "gpg"
@vslala
vslala / application.properties
Created May 22, 2020 13:08
Configuration for running integration tests with H2 Database, Flyway, Spring Boot JPA
# Datasource configuration for jdbc h2
# this is for file based persistent storage
# spring.datasource.url=jdbc:h2:file:/data/demo
# For in-memory storage
spring.datasource.url=jdbc:h2:mem:testdb;MODE=MySQL;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE;
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=vslala
spring.datasource.password=simplepass
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
@vslala
vslala / gitlab-ci.yml
Created May 27, 2020 16:53
Step by step commands to ssh into vps and fire commands
stages:
- sshserver
variables:
REGISTRY_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
test:
image: alpine:latest
stage: sshserver
script: