Skip to content

Instantly share code, notes, and snippets.

View shravankb's full-sized avatar
💤
Brain is forever a nerd

Shravan Kumar B shravankb

💤
Brain is forever a nerd
View GitHub Profile
@shravankb
shravankb / INSTRUCTIONS.md
Created September 9, 2021 16:38 — forked from franklsm1/INSTRUCTIONS.md
Auto configure pre-commit hooks for a Gradle Spring App

Steps

  1. create a file called "pre-commit" with no extension in the project directory root
  2. add the code from the pre-commit file below into that new file
  3. create a new file called "preCommit.gradle" inside of the root gradle folder
  4. add the code from the preCommit.gradle file below into that new file
  5. add the following line at the end of the build.gradle file:
    • apply from: "$projectDir/gradle/preCommit.gradle"

Now when you run the ./gradlew build command the git pre-commit hook will be automatically setup.

@shravankb
shravankb / UUID.java
Created August 24, 2021 05:18 — forked from mindhaq/UUID.java
Java validator for UUIDs
import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.Pattern;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
@shravankb
shravankb / elb-nodejs-ws.md
Created August 9, 2021 16:48 — forked from obolton/elb-nodejs-ws.md
Configuring an AWS Elastic Load Balancer for a Node.js application using WebSockets on EC2

AWS ELB with Node.js and WebSockets

This assumes that:

  • You are using Nginx.
  • You want to accept incoming connections on port 80.
  • Your Node.js app is listening on port 3000.
  • You want to be able to connect to your Node.js instance directly as well as via the load balancer.

####1. Create load balancer

@shravankb
shravankb / DateUtils.java
Created August 4, 2021 12:57 — forked from mraccola/DateUtils.java
Android DateUtils for RFC 1123 dates and ISO 8601 dates
package org.wta.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public final class DateUtils {
git restore filename
git restore -p filename (patch level)
git restore .
git commit --amend -m "change last commit"
git revert <commit hash> # creates a new commit at head that undoes a previous commit
get reset --hard --soft --mixed <hash>
git reflog # look at the history of the head pointer
git branch <name> <hash> # starts the branch at a particular hash
@shravankb
shravankb / git
Created August 3, 2021 19:06 — forked from chyld/git
git commands by use case
# updated 2017-07-16
https://github.com/nojhan/liquidprompt
# ----------------------------------------------------------------- #
REFERENCES
# ----------------------------------------------------------------- #
http://ndpsoftware.com/git-cheatsheet.html
# ----------------------------------------------------------------- #
According to Example 50 at Using @Query from spring-data documentation this is possible specifying the query itself and a countQuery, like this:
public interface UserRepository extends JpaRepository<User, Long> {
@Query(value = "SELECT * FROM USERS WHERE LASTNAME = ?1",
countQuery = "SELECT count(*) FROM USERS WHERE LASTNAME = ?1",
nativeQuery = true)
Page<User> findByLastname(String lastname, Pageable pageable);
}
solution:
@shravankb
shravankb / gist:892ffbcbcd797eeae4b80a78a54f9a9a
Created June 7, 2021 04:51 — forked from mrtns/gist:78d15e3263b2f6a231fe
Upgrade Chrome from Command Line on Ubuntu
# Install
# via http://askubuntu.com/questions/510056/how-to-install-google-chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
# Update
@shravankb
shravankb / GradleCheatsheet.md
Created April 21, 2021 05:53 — forked from jiffle/GradleCheatsheet.md
Cheatsheet of Gradle Commands and Config

Command Cheatsheet

  • Convert Maven build to gradle

    gradle init

  • Initialise new project folder structure (Java example)

    gradle init --type java-library

// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration
@SpringBootApplication
public class FooApplication {
public static void main(String[] args) {
// Bootstrap the application
SpringApplication.run(FooApplication.class, args);
}
}