Skip to content

Instantly share code, notes, and snippets.

View peeyushsrj's full-sized avatar

Peeyush Singh peeyushsrj

View GitHub Profile
@peeyushsrj
peeyushsrj / all.md
Created July 9, 2022 17:19
Awesome Lightweight Self Hosted
@peeyushsrj
peeyushsrj / pyunused.sh
Created July 19, 2021 13:57
Print unused packages in python scripts
# bash pyunused.sh filename.py
s=$(cat $1 | grep import | grep as | awk '{print $4}')
t=$(cat $1 | grep import | grep -v as | awk '{print $2}')
echo "Following unused packages"
echo "-------------------------"
for el in $s; do
count=$(cat $1 | grep $el | wc -l)
if (( ${count} == 1 )); then
@peeyushsrj
peeyushsrj / dpa.sh
Last active July 17, 2021 20:55
Delete largest files with persistence linux script
# User input variables
max_files=20 #No of files to List
scandirs="./scan-dirs.txt" #list of directories separated by newline to scan
ignore_files="./ignore-files.txt" #non-deleted files path will be stored here to avoid re-appearing
# Program Tests
test -f $scandirs || touch $scandirs
test -f $ignore_files || touch $ignore_files
@peeyushsrj
peeyushsrj / wpa_supplicant.conf
Created April 25, 2021 18:25
raspberry pi network config file
#/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=IN
network={
ssid=""
psk=""
key_mgmt=WPA-PSK
@peeyushsrj
peeyushsrj / read-write-json.php
Created March 12, 2021 18:46
Read and writing to json file in php
<?php
$filename = 'filename.json';
//decode to json as associative array
$data = json_decode(file_get_contents($filename),true);
//init condition in case of empty file
if (!is_array($data)){
$data = [];
}
@peeyushsrj
peeyushsrj / jh.txt
Last active February 25, 2021 17:07
Jekyll header
---
layout: post
title: Test
date: 2020-02-02
category: Solutions,SoftwareDiscovery,Notes
author: Peeyush Singh
---
@peeyushsrj
peeyushsrj / detect_fc.sh
Created December 19, 2019 18:27
Count function call python using bash
source="*.py"
funcs=$(cat $source | grep 'def' | sed 's/def //g' | sed 's/(.*/(/' | grep -v '#')
for f in $funcs
do
echo $f $(expr $(cat $source | grep -c $f) - 1)
done
@peeyushsrj
peeyushsrj / reboot-service.sh
Created December 18, 2019 18:45
Start a service bash
sudo nano /lib/systemd/system/sample.service
Add in the following text :
[Unit]
Description=My Sample Service
After=multi-user.target
[Service]
Type=idle
@peeyushsrj
peeyushsrj / duplicates.py
Created November 17, 2019 17:42
Finding duplicates in directory (and move them too - optional)
# python 3
import os
import hashlib
import shutil
def md5(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
invoice: 34843
date : 2001-01-23
bill-to: &id001
given : Chris
family : Dumars
address:
lines: |
458 Walkman Dr.
Suite #292
city : Royal Oak