Skip to content

Instantly share code, notes, and snippets.

View DontPanic345's full-sized avatar

Alan Falloon DontPanic345

View GitHub Profile
@DontPanic345
DontPanic345 / auto update everything ubuntu
Last active April 7, 2018 01:34
Never be notified about updates again
#!/bin/bash
apt-get update
apt-get dist-upgrade -y
apt-get autoclean
#place the preceding lines into a file in your cron.daily folder e.g.
#sudo nano /etc/cron.daily/auto-dist-upgrade
#sudo chmod 755 /etc/cron.daily/auto-dist-upgrade
@DontPanic345
DontPanic345 / PreserveNewest in .net project files
Created October 11, 2016 22:51
Update C# and VB project files to only copy files to the output if the file has changed
My C# and VB.net project files contain many lines
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
and I want them to say
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
so the gist of it is
find -regex '.*\.vbproj\|.*\.csproj' -exec sed --in-place --binary 's:<CopyToOutputDirectory>Always</CopyToOutputDirectory>:<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>:' {} \;
Explaination:
@DontPanic345
DontPanic345 / VB.NETCloseProcessLockingFile
Last active August 29, 2015 14:10
Simple method for closing a the program thats locking your file you want to access in VB.NET. This wont guarantee that you'll get access to your file but its a simple method that will work most of the time (depending on situation).
Try
'Try and save your file
document_pdf.Save(FileName)
document_pdf.Dispose()
Catch ex As System.IO.IOException
'ok it failed, probably because it's open somewhere else
'starting it here will bring it to the front of whatever is running it
Process.Start(FileName)
Dim AllProcesses = Process.GetProcesses
For Each proc In AllProcesses
#!/usr/bin/python
import os
files = [f for f in os.listdir('.') if os.path.isfile(f)]
shortcut = ' - Shortcut.lnk'
for f in files:
if f[-len(shortcut):] == shortcut:
print(f, f[:-len(shortcut)]+'.lnk')
os.rename(f, f[:-len(shortcut)]+'.lnk')