Skip to content

Instantly share code, notes, and snippets.

View raspi's full-sized avatar

raspi

  • finland
  • 04:18 (UTC +03:00)
View GitHub Profile
@raspi
raspi / gettext_update.sh
Created July 1, 2014 17:03
Shell script for updating Gettext .po files in a PHP project. Create new languages simply by copying base.pot to <language code>.po. For example: cp base.pot fi.po. Then just edit fi.po with poedit or some other editor.
#!/bin/bash -e
# generate file list
echo -e "" > files.txt
find ../application -type f \( -iname "*.php" -or -iname "*.phtml" \) -exec readlink -f "{}" \; > files.txt
# scan files
xgettext --force-po --add-comments --from-code=UTF-8 --language=php --package-name=app --package-version=1.0 --msgid-bugs-address=noreply@example.com -o base.pot -f files.txt
# base pot -> <lang>.po update
def is_vatnum(num):
if len(num) > 9:
return False
if "-" not in num:
return False
n,check = num.split("-")
try:
@raspi
raspi / RemoteMachineSetup.md
Last active October 22, 2015 09:43
Remote desktop

Environment

  • All machines are local
  • Multiple cheap "stupid" viewer client machines
  • One hypervisor which is used by these client machines

Techs

  • RDP
  • VNC
  • PCoIP
  • Direct video stream
@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
@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 / rm_files_by_dir.py
Created January 31, 2017 15:40
Remove files recursively based on file list in a file
#!/bin/env/python
# -*- encoding: utf8 -*-
# usage: script.py --file my_filelist.txt --directory /mnt/storage/
# (c) Pekka Järvinen 2017-
import logging
import os
import sys
from argparse import ArgumentParser
@raspi
raspi / enable-all-advanced-power-settings.ps1
Last active May 5, 2024 22:24
Enable all advanced power settings in Windows.
# List all possible power config GUIDs in Windows
# Run: this-script.ps1 | Out-File powercfg.ps1
# Then edit and run powercfg.ps1
# (c) Pekka "raspi" Järvinen 2017
$powerSettingTable = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerSetting
$powerSettingInSubgroubTable = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerSettingInSubgroup
Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerSettingCapabilities | ForEach-Object {
$tmp = $_.ManagedElement
@raspi
raspi / windows-advanced-power-settings-to-markdown.ps1
Created June 14, 2017 22:10
List Windows advanced power settings as MarkDown
# List Windows advanced power settings as MarkDown
# Use:
# this-script.ps1 | Out-File power.md
# Use powercfg to show hidden settings:
# powercfg -attributes <Group GUID> <GUID> -ATTRIB_HIDE
# example:
# powercfg -attributes 54533251-82be-4824-96c1-47b60b740d00 06cadf0e-64ed-448a-8927-ce7bf90eb35d -ATTRIB_HIDE
# (c) Pekka "raspi" Järvinen 2017-
$powerSettingSubgroubTable = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerSettingSubgroup | Where-Object {$_.ElementName -ne $null}
@raspi
raspi / nvidia-driver-install.ps1
Last active November 17, 2017 19:54
Install nVidia drivers without extra stuff
# Install nVidia drivers without extra stuff
#
# Extract nvidia 385.69-desktop-win10-64bit-international-whql.exe to a directory and run:
# ./this-script.ps1 385.69-desktop-win10-64bit-international-whql
#
# (c) Pekka Järvinen 2017-
param (
[Parameter(Mandatory=$true)][string]$unpackDir
)
@raspi
raspi / pacman-auto-update.service
Last active December 1, 2023 10:01
Arch Linux Pacman auto download updated packages
# Download new packages but don't install them
# Save in /etc/systemd/system/
[Unit]
Description=Pacman Automatic Download (no install) service
After=network-online.target
[Service]
# Wait time if process hangs
TimeoutStopSec=5m