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 / unzip.ps1
Created February 1, 2017 09:34
Powershell v3 unzip
function Expand-ZIPFile($file, $destination) {
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
Expand-ZIPFile –File testfile.zip –Destination c:\temp
If (!(Test-Path $CLIENT_ROOT\archive)) {
write-host "Creating archive folder $CLIENT_ROOT\archive"
New-Item -Path $CLIENT_ROOT\archive -ItemType Directory
}
@alst74
alst74 / read_file_until.sh
Created March 22, 2017 15:35
Read a file (log) until the word elapsed occur (also print the file)
#!/bin/sh
EXPECTED_NO_LINES=1
i=0
echo "exp lines: ${EXPECTED_NO_LINES}"
echo "lines: ${ACTUAL_NO_LINES}"
while [ $i -eq 0 ]; do
ACTUAL_NO_LINES=$(cat asdf3.log | wc -l)
if ! [[ $ACTUAL_NO_LINES -eq $EXPECTED_NO_LINES ]]; then
sed -n "${EXPECTED_NO_LINES},${ACTUAL_NO_LINES}p" asdf3.log
EXPECTED_NO_LINES=$ACTUAL_NO_LINES
@alst74
alst74 / cntlm.ini
Created June 21, 2017 14:07
cntlm.ini config example file
Username myusername
Domain mydomain
Proxy my_proxy_server.com:80
NoProxy 127.0.0.*, 192.168.*
Listen 127.0.0.1:5865
Gateway yes
SOCKS5Proxy 5866
@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}"
@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 / 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 / .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 / 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 / .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"