Skip to content

Instantly share code, notes, and snippets.

View nicholasadamou's full-sized avatar
🤓
Working hard to make the world better with software.

Nicholas Adamou nicholasadamou

🤓
Working hard to make the world better with software.
View GitHub Profile
@nicholasadamou
nicholasadamou / pin_lock_version.js
Last active October 1, 2024 20:06
This script, version-pin-and-clean.js, automates the process of pinning and cleaning dependency versions in a package.json file. It reads version information from a pnpm-lock.yaml file and updates both dependencies and devDependencies in package.json to match the versions specified in the lock file, removing any leading version specifiers like ^…
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
console.log('Starting the version pinning and cleaning process...');
// Utility function to determine which package manager is used
const determinePackageManager = () => {
if (fs.existsSync(path.join(__dirname, 'pnpm-lock.yaml'))) {
return 'pnpm';
@nicholasadamou
nicholasadamou / pnpm-node-matcher.py
Last active October 1, 2024 20:19
A utility script that determines the appropriate pnpm version based on the Node.js version used in your project. It reads from .nvmrc, package.json, or defaults to the currently installed Node.js version, ensuring compatibility and simplifying dependency management. Optionally, it can also install the recommended pnpm version automatically.
import os
import json
import subprocess
import requests
# Compatibility table for pnpm versions based on Node.js versions (only the major versions)
pnpm_compatibility = {
'14': '6', # PNPM 6 for Node 14
'16': '7', # PNPM 7 for Node 16
'18': '8', # PNPM 8 for Node 18
@nicholasadamou
nicholasadamou / index.js
Created September 18, 2022 01:39
Convert HTML to HTML Entities
const toHTMLEntities = (html) => {
let result = '';
for (let i = 0; i < html.length; i++) {
result += "&#x" + html[i].charCodeAt(0).toString(16) + ";";
}
return result;
}
@nicholasadamou
nicholasadamou / scan.sh
Created September 2, 2019 11:56
Scan for nearby networks every 10 seconds on MacOS
#!/bin/bash
while true
do
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s
sleep 10
done
# Increase history
$MaximumHistoryCount = 10000
# Produce UTF-8 by default
$PSDefaultParameterValues["Out-File:Encoding"]="utf8"
# Show selection menu for tab
Set-PSReadlineKeyHandler -Chord Tab -Function MenuComplete
# Helper Functions
@nicholasadamou
nicholasadamou / boxstarter
Last active February 16, 2019 12:45
Base Windows Configuration
### Base Windows Configuration ###
<#
The command to run, built from the raw link of this gist
Win+R
iexplore http://boxstarter.org/package/url?<RAW GIST LINK>
OR (if you don't like the way the web launcher force re-installs everything)
Create another script like the following to install and run the gist:
@nicholasadamou
nicholasadamou / install.sh
Last active January 26, 2019 15:15
Install a DMG file via CLI.
#!/bin/bash
# see: https://apple.stackexchange.com/a/311511/291269
function install_dmg {
set -x
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Initialize a variable for the URL to the '.dmg'
@nicholasadamou
nicholasadamou / setup.sh
Last active December 14, 2018 02:06
Reset Parallels Desktop's trial and generate a casual email address to register a new user.
#!/bin/sh
# Reset Parallels Desktop's trial and generate a casual email address to register a new user
sudo rm /private/var/root/Library/Preferences/com.parallels.desktop.plist /Library/Preferences/Parallels/licenses.xml
jot -w pdu%d@gmail.com -r 1
@nicholasadamou
nicholasadamou / add-apt-repository
Last active August 21, 2018 16:33
Utility to add PPA repositories in your debian machine.
#!/bin/bash
if [ $# -eq 1 ]
NM=`uname -a && date`
NAME=`echo $NM | md5sum | cut -f1 -d" "`
then
ppa_name=`echo "$1" | cut -d":" -f2 -s`
if [ -z "$ppa_name" ]
then
echo "PPA name not found"
else
@nicholasadamou
nicholasadamou / xfce4.sh
Created May 23, 2018 12:57
Install xfce4 on Kali Linux WSL to be used with an XRDP client on Windows.
#!/bin/bash
echo "[+] Installing XFCE4, this will take a while"
sudo apt update
sudo apt dist-upgrade -y --force-yes
sudo apt --yes --force-yes install kali-desktop-xfce xorg xrdp
echo "[+] Configuring XRDP to listen on port 3390 (but not starting the service)..."
echo "[+] To start the service run: sudo /etc/init.d/xrdp start"
sudo sed -i 's/port=3389/port=3390/g' /etc/xrdp/xrdp.ini
sudo echo "alias startx=\"sudo /etc/init.d/xrdp start\"" > ~/.bash_aliases
sudo echo "alias stopx=\"sudo /etc/init.d/xrdp stop\"" > ~/.bash_aliases