Skip to content

Instantly share code, notes, and snippets.

View mohnish82's full-sized avatar

Mohnish Chaudhary mohnish82

View GitHub Profile
@mohnish82
mohnish82 / keybindings.json
Created August 7, 2021 20:42
Vscode key mapping
[
{
"key": "ctrl+left",
"command": "cursorWordPartLeft",
"when": "textInputFocus"
},
{
"key": "ctrl+right",
"command": "cursorWordPartRight",
"when": "textInputFocus"
@mohnish82
mohnish82 / RegexBackref.java
Created October 17, 2020 18:02
Java regex search & replace using backreference
Strig input = "_ab__f_";
//Pattern p = Pattern.compile("_+(.)", Pattern.DOTALL);
// pattern with named backreference i.e. (?<firstElement>)
Pattern p = Pattern.compile("_+(?<firstElement>.)", Pattern.DOTALL);
Matcher m = p.matcher(input);
StringBuffer buff = new StringBuffer();
@mohnish82
mohnish82 / application.yml
Created April 13, 2020 17:41
Spring Boot Keycloak OpenID Connect config
spring:
security:
oauth2:
client:
registration:
keycloak:
client-id: xyz-app
client-secret: <insert-secret-here>
clientName: XYZ
authorization-grant-type: authorization_code
@mohnish82
mohnish82 / FileMimeTypeService.java
Created May 31, 2019 17:51
[Java] Mime type detection
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
public class FileMimeTypeService {
public String getContentType(String file) {
@mohnish82
mohnish82 / test.txt
Created October 4, 2018 12:07
Markdown file
Hello
![Some Text](static/images/image.png)
World
@mohnish82
mohnish82 / keybase.md
Created September 28, 2017 03:55
Keybase proof

Keybase proof

I hereby claim:

  • I am mohnish82 on github.
  • I am mohnish82 (https://keybase.io/mohnish82) on keybase.
  • I have a public key ASA1RN9bNoXuadvUq765ZjY1QbQ3aEuKH5beqw7RZ1KSlgo

To claim this, I am signing this object:

@mohnish82
mohnish82 / random.txt
Last active March 31, 2016 02:18
Random number generator commandfu
# Method 1
cat /dev/random | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 5
tr => translate/delete input stream
-d => delete from stream
-c => complement of SET1, SET1 being 'a-zA-Z0-9' i.e. delete all chars except the ones in SET1 from input stream
fold => wrap output into 16 column fixed width i.e. generate passwords of length 8
head => top 5 results only
Log events to file
==================
curl -H 'Authorization: Bearer <auth_token_here>' -N https://api.particle.io/v1/devices/events -o photon.log
-H => header
-N => No buffer; output in real time
-o => output to file
@mohnish82
mohnish82 / prename.pl
Last active October 21, 2015 04:05 — forked from javiermon/prename.pl
`prename` script from Debian's 'perl' package
#!/usr/bin/perl -w
#
# This script was developed by Robin Barker ([email protected]),
# from Larry Wall's original script eg/rename from the perl source.
#
# This script is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# Larry(?)'s RCS header:
# RCSfile: rename,v Revision: 4.1 Date: 92/08/07 17:20:30
@mohnish82
mohnish82 / gist:0525b7a9d4c5fbf6f346
Created February 18, 2015 23:11 — forked from nicholashagen/gist:5306330
HDHomeRun Config command line

Download Source

#> wget http://download.silicondust.com/hdhomerun/libhdhomerun_20130117.tgz
#> tar zxvf libhdhomerun_20130117.tgz 

Install Tools