Skip to content

Instantly share code, notes, and snippets.

View Temikus's full-sized avatar

Artem Yakimenko Temikus

View GitHub Profile
@Temikus
Temikus / unix_aliases.bat
Created December 7, 2012 07:32
UNIX-like aliases for Windows CLI tools.
::grep
echo findstr %1 %2 %3 %4 %5 > %systemroot%\grep.cmd
::ifconfig
echo IF "%1"=="-a" (ipconfig /all) ELSE (ipconfig %1) > %systemroot%\ifconfig.cmd
::man
echo %1 /?> %systemroot%\man.cmd
::ls
echo IF "%1"=="-a" (dir) ELSE (IF "%1"=="-al" (dir) ELSE (dir %1 %2 %3 %4 %5)) > %systemroot%\ls.cmd
@Temikus
Temikus / backup.sh
Created December 19, 2012 17:10 — forked from anonymous/backup.sh
#!/bin/bash
# incrementally backup $HOME using rsync
SOURCE="$HOME/"
DEST="/media/Dragis_HDD/homebackup/"
KEEP=5 # how many backups besides the current one should be kept
EXCLUDEFROM="$SOURCE/.backup_excludes"
NICENESS=10
LOGFILE="$DEST/.lastbackup.log"
# NOTE: some of these will be 404s (30th of February, days with no comics, etc.)
# 404s can be removed with `find . -type f -size -1000c -iname "*.gif" -exec rm {} \;`
from urllib import urlretrieve
for y in range(2000, 2013):
for m in range(1, 13):
print "starting", y, m
@Temikus
Temikus / vpnroute.sh
Created January 2, 2013 19:42
A nice way to make sure that specific application uses only a specific tunnel interface.
#!/bin/bash
groupadd vpnroute
iptables -A OUTPUT -m owner --gid-owner vpnroute \! -o tun0 -j REJECT
sudo -g vpnroute some-app &
@Temikus
Temikus / add_drive.bat
Created January 6, 2013 16:22
A set of bat files for testing drive/folder association. 1) Add a virtual drive with letter T. 2) Clean up the association record. 3) Delete the virtual drive.
@echo Creating a test empty folder...
mkdir C:\TempDriveT
subst T: C:\TempDriveT
@Temikus
Temikus / ssh-iptables
Created January 29, 2013 07:19
This iptables snippet opens port 22 globally for up to 8 unique connections on that port within the same 3-minute window per source IP, whereupon that source IP is blocked for 10 minutes. Successful or 'tripped' connections are logged. All done purely in-firewall (uses ipset)
ipset -exist create blackhole hash:ip timeout 600
-A INPUT -m set --match-set blackhole src -j DROP
-A INPUT -p tcp -m tcp --dport 22 -j SSH-ALL
-A SSH-ALL -p tcp -m recent --set --name SSH --rsource
-A SSH-ALL -p tcp -m recent --update --seconds 180 --hitcount 8 --name SSH --rsource -j SSH-BLOCKED
-A SSH-ALL -p tcp -j ULOG --ulog-nlgroup 1 --log-prefix "Accepted-ssh Event: "
-A SSH-ALL -p tcp -j ACCEPT
-A SSH-BLOCKED -p tcp -j ULOG --ulog-nlgroup 1 --log-prefix "Blocked-ssh Event: "
-A SSH-BLOCKED -p tcp -j SET --add-set blackhole src
@Temikus
Temikus / wireshark_font_fix.sh
Created February 23, 2013 12:26
Fixes Wireshark font and icon sizes in X11 on MacOSX Taken from: http://blog.tp.org/jay/archives/2010/05/wireshark-macos.html
#!/bin/bash
sed -i -e 's/gtk-font-name=\"Lucida Grande 12\"/gtk-font-name=\"Lucida Grande 9\"/g' /Applications/Wireshark.app/Contents/Resources/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/pre_gtkrc
sed -i -e 's/gtk-icon-sizes = \"gtk-menu=16,16:gtk-dialog=48,48:gtk-dnd=32,32:gtk-button=20,20:gtk-large-toolbar=24,24:gtk-small-toolbar=16,16:inkscape-decoration=12,12\"/gtk-icon-sizes = \"gtk-menu=16,16:gtk-dialog=24,24:gtk-dnd=32,32:gtk-button=20,20:gtk-large-toolbar=16,16:gtk-small-toolbar=10,10:inkscape-decoration=6,6\"/g' /Applications/Wireshark.app/Contents/Resources/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/pre_gtkrc
@Temikus
Temikus / exchange_req.ps1
Created February 28, 2013 14:41
Prepare Windows Server 2008 R2 for Exchange installation
Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy -Restart
(*
Generate and deploy Octopress site from Launchbar
Author: Collin Donnell
Website: http://collindonnell.com
Date: 01/07/2013
*)
-- Set to the location on disk of your site
set octopressLocation to ((path to home folder as text) & "Code:blog:") as alias
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative