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 / 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 / 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
If (!(Test-Path $CLIENT_ROOT\archive)) {
write-host "Creating archive folder $CLIENT_ROOT\archive"
New-Item -Path $CLIENT_ROOT\archive -ItemType Directory
}
@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