Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ron4stoppable's full-sized avatar
😎

Rohan Shewale ron4stoppable

😎
View GitHub Profile
@ron4stoppable
ron4stoppable / freeport.sh
Created December 22, 2021 16:49
A script to clear any running process on given port number
#!/bin/bash
touch 34_temp.text
lsof -n -i4TCP:$1 | awk '{print $2}' > 34_temp.text
pidToStop=`(sed '2q;d' 34_temp.text)`
> 34_temp.text
if [[ -n $pidToStop ]]
then
kill -9 $pidToStop
echo "Port $1 is now clear."
else

Keybase proof

I hereby claim:

  • I am ron4stoppable on github.
  • I am rohanonly (https://keybase.io/rohanonly) on keybase.
  • I have a public key ASDF_NZ3kpA0_hbP_tma0Fz-c8UlIvOxVDIHmzVD-K6eego

To claim this, I am signing this object:

@ron4stoppable
ron4stoppable / fillJSON.tsx
Created August 20, 2020 14:54
Deep JSON object to flat JSON object preserving the nested structure with a delimiter
/*
Deep JSON object to flat JSON object preserving the nested structure with a delimiter.
Can use for dynamic forms
*/
function jsonToSSFlatmap (obj: any, prefix: string) {
let list: any = {};
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const element = obj[key];
@ron4stoppable
ron4stoppable / fillJSON.tsx
Created August 20, 2020 14:52
Deep JSON object to flat JSON object preserving the nested structure with a delimiter.
function jsonToSSFlatmap (obj: any, prefix: string) {
let list: any = {};
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const element = obj[key];
if (typeof element === "object") {
const li = jsonToSSFlatmap( element, (prefix ? prefix + "||" : "") + key);
list = {
...list,
...li
@ron4stoppable
ron4stoppable / scrollTop.js
Last active December 23, 2018 15:09
Get proper scroll/page-offset value, works in all browsers, over all platforms (as far as I have tested)
// to get proper scroll/page-offset value
// works in all browsers, over all platforms (as far as I have tested)
// this basically is for the different property in iOS browser & Safari
const scrollTop = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop);
@ron4stoppable
ron4stoppable / SpaceTokenizer.java
Created November 10, 2018 12:50
A tokenizer class for MultiAutoCompleteTextView, with text seperated with space.
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.widget.MultiAutoCompleteTextView;
public class SpaceTokenizer implements MultiAutoCompleteTextView.Tokenizer {
@Override
public int findTokenStart(CharSequence text, int cursor) {
int i = cursor;
@ron4stoppable
ron4stoppable / moveElementLocationInArray.js
Created October 26, 2018 08:42
The function move's an element in array `arr` from index `fromIndex` to index `toIndex`
function arraymove(arr, fromIndex, toIndex) {
var element = arr[fromIndex];
arr.splice(fromIndex, 1);
arr.splice(toIndex, 0, element);
}
@ron4stoppable
ron4stoppable / moz-webkit.css
Created July 30, 2018 18:53 — forked from nathansmith/moz-webkit.css
Target Firefox and WebKit via hacky CSS.
/*
Read more here:
https://developer.mozilla.org/en/CSS/@-moz-document
For more browser-specific hacks:
http://paulirish.com/2009/browser-specific-css-hacks
*/
@-moz-document url-prefix() {
/* Put your Firefox specific code here. */
@ron4stoppable
ron4stoppable / toUp.html
Created April 6, 2017 14:40
Simple "Scroll to Up" button with jQuery
<!--
CSS style to make the button stick to bottom of page
-->
<style>
#toUp {
position: fixed;
right: 5px;
bottom: 15px;
display:none;
}