Skip to content

Instantly share code, notes, and snippets.

View alst74's full-sized avatar

Alexander Ståhlberg alst74

  • Sandviken/Sweden
View GitHub Profile
@alst74
alst74 / .bash_profile
Created January 12, 2022 10:51
bash_profile
HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "
HISTCONTROL="ignoredups:ignorespace"
HISTIGNORE="ls *:history"
HISTSIZE=1000
@alst74
alst74 / testfile.sh
Created December 18, 2020 13:41
Bash loops and tests
#!/bin/bash
FILENAME=$1
for FILENAME in "$@"; do
if ! [ -e "$FILENAME" ]; then
echo "File not found ($FILENAME). Skipping..."
elif [ -d "$FILENAME" ]; then
ORIG_IFS=$IFS
IFS=$(echo -en "\n\b")
for F in $(find "$FILENAME" -type f); do
ls -lah $F
@alst74
alst74 / move-files.ps1
Created November 7, 2019 09:43
Move files recursivly with Powershell
$SRC = "c:\temp"
$FILES = "*.mp4", "*.jpg"
$DST = "c:\destfolder"
for ($i=0; $i -lt $FILES.length; $i++) {
Get-ChildItem -Recurse -Path "$SRC\$FILES[$i]" | Move-Item -Destination $DST -WhatIf
# Write-Host("File: ") $FILES[$i]
}
$sleep = 2 #Sleeptime in seconds between checks
$maxtry = 10 #Nr of tr
$successfile = "c:\temp\success.txt"
$failedfile = "c:\temp\fail.txt"
Write-Host "Waiting for deploy to complete"
for ($i=1; $i -le $maxtry; $i++) {
if (Test-Path "${successfile}") {
Write-Host "${successfile} found - Deploy was SUCCESSFUL!!"
Break
}
@alst74
alst74 / .tmux.conf
Created May 16, 2018 10:54
Tmux config
# make the first window number start at 1
set -g base-index 1
# start with pane 1
set -g pane-base-index 1
# screen mode
#set -g default-terminal "screen"
#set -g default-terminal "linux"
set -g default-terminal "putty-256color"
@alst74
alst74 / freerdp.sh
Created April 27, 2018 13:32
Using windows jumpstation
#!/bin/sh
echo 'alias rdp=xfreerdp /kbd:0x0000041D -sec-ext +sec-nla /u:[domain\\username] +smart-sizing /h:1648 /w:2729 /scale:180 /scale-desktop:200' >> ~/.bashrc
@alst74
alst74 / .bash_profile
Last active January 30, 2018 12:13
MAC profile
alias cd..='cd ..'
alias ..='cd ..'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias mount='mount |column -t'
alias path='echo -e ${PATH//:/\\n}'
alias now='date +"%T"'
alias nowtime=now
alias nowdate='date +"%d-%m-%Y"'
@alst74
alst74 / win2k_cleanup.cmd
Created October 30, 2017 10:12
Windows 2008 R2 disk cleanup
REM AUTHOR JAMES FOX
REM SOURCE http://technet.microsoft.com/en-us/library/ff630161(WS.10).aspx
REM '
REM COMMENTS ON BAT SCRIPT CHANGES: FIXES ADDED TO FIX AN ISSUE WHERE CLEANMGR.EXE DOES NOT EXIST
REM ON WINDOWS SERVER 2008 FIXING ALL EDITIONS LISTED BELOW
REM SUMMARY: TEST FOR EXISTENCE OF SOURCE IF EXE DOES NOT EXIST COPY FROM SOURCE (LOCAL ON SERVER)
REM THIS CAN BE RUN ON ALL SERVER EDITIONS INCLUDING SERVER 2000, 2003, & 2008 32bit, 64bit, and R2 for all
REM '
REM DECLARATIONS
SET SOURCEEXE=""
@alst74
alst74 / teamcity-agent.service
Created September 11, 2017 09:07 — forked from BenWhitehead/teamcity-agent.service
systemd service files for running TeamCity (create in /usr/lib/systemd/system)
[Unit]
Description=TeamCity Build Agent
After=network.target
[Service]
Type=forking
PIDFile=$AGENT_HOME/logs/buildAgent.pid
ExecStart=/usr/bin/sudo -u teamcity $AGENT_HOME/bin/agent.sh start
ExecStop=/usr/bin/sudo -u teamcity $AGENT_HOME/bin/agent.sh stop
@alst74
alst74 / .bashrc
Last active March 12, 2018 13:31
BASH proxy
PROXYSRV=proxy.example.com:8080
NOPROXY="localhost,127.0.0.1,.example.com"
proxy () {
case $1 in
'on')
echo -n "Enter passwd: "
read -s PASSWD
PROXY="http://${USER}:${PASSWD}@${PROXYSRV}"
export http_proxy="${PROXY}" https_proxy="${PROXY}" no_proxy="${NOPROXY}"