Skip to content

Instantly share code, notes, and snippets.

View Jaskaranbir's full-sized avatar
😁
Coding fun stuff....

Jaskaranbir Dhillon Jaskaranbir

😁
Coding fun stuff....
View GitHub Profile
@Jaskaranbir
Jaskaranbir / simple_dynamic_web_editor.html
Created May 1, 2016 17:31
A simple web editor that displays results dynamically as you type
<html>
<head>
<title>Dynamic Web Editor</title>
</head>
<body>
<style>
body{
margin:0;
}
textarea{
@Jaskaranbir
Jaskaranbir / Java-String-to-Tabular-Format.java
Created May 1, 2016 18:38
A manual way to convert a given set of parallel strings in Tabular Format
public static String[] generateTable(ArrayList<String> lines){
// A list to store every single element individually
ArrayList<String> sl = new ArrayList<>();
int length = lines.get(0).split(" ").length; // Number of individual
// elements
// Create an array of every element individually
for (String line : lines) {
String[] sp = line.split(" ");
for (String semiChars : sp)
@Jaskaranbir
Jaskaranbir / html_table_generator.js
Created May 17, 2016 00:26
To generate tabular grid in html using javascript
var body = window.document.getElementsByTagName('body')[0];
// Square Grid
(function genGrid(size) {
var table = document.createElement('table');
table.setAttribute('border', '2');
table.setAttribute('cellspacing', '0');
table.setAttribute('cellpadding', '40');
// This variable isn't required.
// Just exists to make this script code friendly so the grid size can be changed
@Jaskaranbir
Jaskaranbir / JCustomTextField.java
Created October 17, 2016 14:19
JTextField extension with bunch of filtering stuff that might be useful sometime
import javax.swing.JTextField;
import javax.swing.event.UndoableEditEvent;
import javax.swing.event.UndoableEditListener;
import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;
import javax.swing.undo.UndoManager;
@Jaskaranbir
Jaskaranbir / docker-cleanup-resources.md
Created July 27, 2017 00:41 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@Jaskaranbir
Jaskaranbir / kafka_docker.yaml
Last active December 8, 2017 18:26
Kafka Docker Test
version: '3'
services:
kafka:
image: wurstmeister/kafka
environment:
- KAFKA_ADVERTISED_HOST_NAME=localhost
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
links:
- zookeeper
@Jaskaranbir
Jaskaranbir / git_delete_local_tags.sh
Created September 6, 2018 13:45
Git delete tags locally that do not exist on remote
git fetch --prune origin "+refs/tags/*:refs/tags/*"
@Jaskaranbir
Jaskaranbir / ClassLoaderLeakExample.java
Created November 4, 2018 03:58 — forked from dpryden/ClassLoaderLeakExample.java
Example of a ClassLoader leak in Java
import java.io.IOException;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
/**
* Example demonstrating a ClassLoader leak.
*
* <p>To see it in action, copy this file to a temp directory somewhere,
@Jaskaranbir
Jaskaranbir / Vagrantfile_hyper-v
Created August 17, 2019 22:17
Vagrantfile I use for Hyper-V
# -*- mode: ruby -*-
# vi: set ft=ruby :
plugin_dependencies = [
"vagrant-docker-compose",
# "vagrant-windows-hyperv"
# "vagrant-vbguest"
]
needsRestart = false
@Jaskaranbir
Jaskaranbir / puppeteer-experiment.js
Last active January 30, 2020 04:20
Some basic experimentation with Puppeteer - Prints response-body and gets screenshot.
const puppeteer = require('puppeteer');
const url = process.argv[2];
if (!url) {
throw "Please provide URL as a first argument";
}
async function run () {
const browser = await puppeteer.launch( {
headless: true