Skip to content

Instantly share code, notes, and snippets.

View raspi's full-sized avatar

raspi

  • finland
  • 19:04 (UTC +03:00)
View GitHub Profile
@raspi
raspi / mv_one_file_to_parent.py
Created December 28, 2016 21:29
Move file to parent directory if it's the only one there including sub-directories.
#!/bin/env/python
# -*- encoding: utf8 -*-
# Move file to parent directory if it's the only one there including sub-directories.
# usage: script.py <directory>
# script.py /stuff/files/
import os
import sys
from shutil import move
@raspi
raspi / web.config EF6 Npgsql.EntityFramework example.xml
Last active May 12, 2023 18:39
Web.config example Entity Framework 6 & Npgsql.EntityFramework (PostgreSQL)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Culture=neutral" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
@raspi
raspi / generate-systemd-network.sh
Created May 26, 2019 10:45
Generate SystemD .network files for network interface automatically
#!/bin/bash -e
# Generate SystemD .network files for network interface automatically
# (c) Pekka Järvinen 2019-
# Check that there are arguments given
if [ "$#" -eq 0 ]; then
echo "No arguments were given. See $0 --help or $0 -h for usage instructions." 1>&2
exit 1
fi
@raspi
raspi / list-kernel-modules.py
Created March 26, 2021 22:01
List all loadable kernel modules
import json
import subprocess
import sys
from pathlib import Path
skipped_keys = [
'sig_id',
'signer',
'sig_key',
'sig_hashalgo',
@raspi
raspi / setup_namespace_network.sh
Created August 14, 2022 16:57
Setup Linux namespace network with virtual bridge
#!/bin/bash
# (C) Pekka Järvinen 2022
# Name for bridge which virtual namespaces will use to communicate with each other
BRIDGENAME="gamebr0"
# Prefix for network
NETPREFIX="192.168.255."
# Starting IP (NETPREFIX + this)
let STARTIP=10
@raspi
raspi / freebsd_dump_sysctl.sh
Last active March 21, 2023 23:44
Dump FreeBSD sysctl descriptions as markdown
#!/bin/sh
# Function for printing
p()
{
KEY=$1
TYPE=$2
DESCR=$3
# last character is '.'
@raspi
raspi / list_established_ports.ps1
Created November 29, 2018 13:10
List established IPs and ports with DNS resolved names and program names
# List established IPs and ports with DNS resolved names and program names
$nfo = @()
ForEach ($c in Get-NetTCPConnection -State Established) {
if ($c.LocalAddress -eq $c.RemoteAddress) {
# skip same IP's
Continue
}
$prog = (Get-Process -Id $c.OwningProcess)
@raspi
raspi / imagemagick_identify_json.sh
Last active March 21, 2023 23:43
Output JSON from ImageMagick magick identify command
#!/bin/bash -e
# Output JSON from ImageMagick magick identify command
if [[ $# -eq 0 ]] ; then
echo "Usage:"
echo " $0 <filename>"
echo ""
exit 0
fi
@raspi
raspi / esxi_lldp_control.sh
Last active January 11, 2023 15:35
Enable/Disable LLDP on VMWare ESXi. Requires SSH access to ESXi. Doesn't require vCenter.
#!/bin/sh
# Enable/Disable LLDP on vSwitch ports on VMWare ESXi
# Tested with ESXi 6.0.0 3620759
# Doesn't need vCenter, only SSH access to the ESXi machine
# (c) Pekka "raspi" Jarvinen 2016 http://raspi.fi/
SWITCH=$1
OPERATION=$2
if [ "$SWITCH" = "" ] || [ "$OPERATION" = "" ]; then

Settable via /etc/sysctl.conf:

integer kern.maxvnodes

Target for maximum number of vnodes

integer kern.maxfiles

Maximum number of files

integer kern.securelevel

Current secure level