Skip to content

Instantly share code, notes, and snippets.

View johnpili's full-sized avatar
🎯
Focusing

John Pili johnpili

🎯
Focusing
View GitHub Profile
@johnpili
johnpili / gist:ba3a93cf9fe976991b890539214f5fb0
Created June 28, 2024 09:03
Powershell find process using port
Get-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess
@johnpili
johnpili / .gitignore
Last active March 29, 2022 08:30
My .gitignore starter template
# IDE/Settings related stuff
.idea
.project
.settings
.vscode
.history
*.metadata/
*.springBeans
*.iml
venv/
@johnpili
johnpili / file-hash-checker.py
Created March 2, 2022 03:56
Python batch file MD5 checksum generator and checker
import hashlib
import os
import sys
def generate_md5(file_path):
with open(file_path.strip(), "rb") as f:
v = f.read()
x = hashlib.new("md5", v)
return x.hexdigest()
@johnpili
johnpili / rename-startswith.py
Last active February 27, 2022 14:08
Rename files by removing the starting and matching string
import os
import sys
from os import path
parameters = sys.argv[1:]
if len(parameters) == 0:
print(f"usage: {sys.argv[0]} <startswith-string>")
sys.exit(0)
if len(parameters) > 0:
@johnpili
johnpili / gist:3fe2124c7b588a3f99d84c6e78ec0279
Last active September 26, 2022 00:21
Set solid background colors in Ubuntu 18.04 and above
gsettings set org.gnome.desktop.background picture-uri ""
gsettings set org.gnome.desktop.background picture-uri-dark ""
gsettings set org.gnome.desktop.background primary-color '#3B6EA5'
@johnpili
johnpili / remove_empty_strings.go
Last active September 26, 2022 03:23
Golang RemoveEmpty String from an array
// removeEmptyStrings - Use this to remove empty string values inside an array.
// This happens when allocation is bigger and empty
func removeEmptyStrings(s []string) []string {
var r []string
for _, str := range s {
if str != "" {
r = append(r, str)
}
}
return r
@johnpili
johnpili / gist:5cb7a46194b2df3c12c817b55639edba
Created September 25, 2017 11:25
Vue form submit template with headers
var config = {};
config.headers = {};
config.headers[document.querySelector('meta[name="_csrf_header"]').content] = document.querySelector('meta[name="_csrf"]').content;
this.form.submit("post", "https://url.test.com", config);
@johnpili
johnpili / gist:bfedc62e69654fa3840718b3ba37730f
Created September 20, 2017 15:53
My Default .gitignore
.metadata/
.idea/
.classpath
.project
.springBeans
.settings/
.iml
/target/
/bin/
src/main/webapp/WEB-INF/lib/plugin-entities.jar
@johnpili
johnpili / extractDistinctObjects.js
Last active September 10, 2017 12:09
Javascript extract distinct list of objects based on key
function extractDistinctObjects(key, items) {
var tmp = [];
items.filter(function(item){
if(tmp.findIndex(x => x[key] == item[key]) <= -1) {
tmp.push(item);
}
});
return tmp;
}