Skip to content

Instantly share code, notes, and snippets.

View rgsingh's full-sized avatar

Rai Singh rgsingh

View GitHub Profile
brew install vcprompt
# add to ~/.zshrc
setopt prompt_subst
export PS1='%n@%m:%~ $(vcprompt)$ '
@rgsingh
rgsingh / EntityResource.java
Created November 24, 2021 14:01 — forked from jreijn/EntityResource.java
IntelliJ Live template for Spring REST TDD demo
package ${PACKAGE_NAME};
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Resource;
public class ${NAME} extends Resource<${ENTITY}> {
public ${NAME}(${ENTITY} content, Link... links) {
super(content, links);
}
@rgsingh
rgsingh / FindUnpairedOddValue.java
Created November 8, 2021 22:04
Generates an array, copies it, shuffles the copy, joins them, adds a odd number and then finds the unpaired number
import java.util.Random;
import java.util.stream.IntStream;
class FindUnpairedOddValue {
public static void main(String[] args) {
int[] myArray = new int[100];
int max = 300;
int min = 1;
if (max % 2 == 0) --max;
if (min % 2 == 0) ++min;
@rgsingh
rgsingh / gist:cbc7f110eb8375ca9a37b376dbc03ea7
Last active March 30, 2020 20:15
Using a MapPropertySource to override spring.main.allow-bean-definition-overriding
https://github.com/spring-projects/spring-boot/issues/15037#issuecomment-502078304
@rgsingh
rgsingh / rename.py
Created September 15, 2019 20:23
rename a filename prior to extension for multiple files in a given directory
''usage: python rename.py <folder> <suffix>
import sys, os
path = sys.argv[1]
suffix = sys.argv[2]
for filename in os.listdir(path):
os.rename(os.path.join(path,filename), os.path.join(path, os.path.splitext(filename)[0] + '_' + suffix +'.jpg'))
@rgsingh
rgsingh / recipe: cherry-pick tags
Created March 22, 2019 03:23 — forked from nickfloyd/recipe: cherry-pick tags
To cherry pick from head and commit back into a tag
-from master in working branch
>> git branch [new branch] [tag]
>> git checkout [branch]
-pull commit out and add it to the commit at the top of the tag
>> git cherry-pick [commit] or git cherry-pick [firstcommit]^..[lastcommit] if you have a range
-resolve conflicts
-delete the local tag
>> git git tag -d [tag]
-add a new tag at the head of the old one
>> git tag [tag]
@rgsingh
rgsingh / save-file-local.js
Created May 6, 2018 18:20 — forked from liabru/save-file-local.js
Save a text file locally with a filename, by triggering a download in JavaScript
/*
* Save a text file locally with a filename by triggering a download
*/
var text = "hello world",
blob = new Blob([text], { type: 'text/plain' }),
anchor = document.createElement('a');
anchor.download = "hello.txt";
anchor.href = (window.webkitURL || window.URL).createObjectURL(blob);
@rgsingh
rgsingh / wlp_docker
Last active June 10, 2016 02:09
Docker WebSphere Liberty Quick Start (Windows host)
# 1. Create mapped directory to override docker container /config directory
cd c:\Users\someuser
mkdir docker\wlp\usr\server\dropins
# 2. Create server.xml under docker\wlp\usr\server allowing for remote access from host
<server description="default servlet engine">
<!-- Enable features -->
<featureManager>
<feature>servlet-3.1</feature>
@rgsingh
rgsingh / remove_class_form_jquery
Created April 20, 2016 16:04
remove a class from html form jquery
$( "form" ).each(function() {
$(this).removeClass('dirty');
});
@rgsingh
rgsingh / jquery_autologout.js
Created March 20, 2016 14:23
jQuery autologout
$(document).ready(function () {
function defineCommonLib() {
var COMMON_LIB = {};
COMMON_LIB.FALSE_FUNCTION = function () {
return false;
};
COMMON_LIB.init = function () {};