Skip to content

Instantly share code, notes, and snippets.

View vslala's full-sized avatar

Varun Shrivastava vslala

View GitHub Profile
import { createStore } from 'redux';
import reducers from '../reducers';
const initialState = {tech: "React JS"};
const store = createStore(reducers, initialState);
export default store;
@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) {
@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 / build.gradle
Created March 6, 2018 07:46
JWT Implementation Demo Gradle Dependencies
// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
@vslala
vslala / clear_wordpress_weird_chars.sql
Last active May 27, 2025 21:36
You might have seen weird characters in your WordPress post recently. This is because of bad character encoding. These SQL commands will update all the bad encoded texts with the correct one.
-- BeMyAficionado.com
-- Backup Database to a .sql file
mysqldump --opt --default-character-set=latin1 --skip-extended-insert --user root --password my-database-name -r exp-my-database-name-latin1.sql --log-error=log-mysqldump-my-database.txt
-- Clean up post_content
UPDATE wp_posts SET post_content = REPLACE(post_content, ' </p>', '</p>');
UPDATE wp_posts SET post_content = REPLACE(post_content, '“', '“');
UPDATE wp_posts SET post_content = REPLACE(post_content, '”', '”');
UPDATE wp_posts SET post_content = REPLACE(post_content, '’', '’');
@vslala
vslala / Gruntconfig.js
Created October 11, 2016 10:44
Stacc HMVC Backbone Boilerplate
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-webpack');
package collections.shoppingcart;
import java.util.List;
import java.util.Scanner;
/**
*
* @author Varun Shrivastava (vslala)
*/
public class UI {
/*
* Create a fully functional program to store and delete objects from the cart
*/
package collections.shoppingcart;
/**
*
* @author Varun Shrivastava
*/
public class Main {
package collections.shoppingcart;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Varun Shrivastava
*/
class Cart {
package collections.shoppingcart;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Varun Shrivastava (vslala)
*/