Skip to content

Instantly share code, notes, and snippets.

View hightemp's full-sized avatar
🎯
Focusing

Anton Panov hightemp

🎯
Focusing
View GitHub Profile
@hightemp
hightemp / sl2pm.rb
Last active August 29, 2015 14:00
sublime 2 package manager
#!/usr/bin/env ruby
# Commands:
# sl2pm add PACKAGE_NAME # add one of the available packages
# sl2pm add_all STRING N_PAGES # add all packages that matches string
# sl2pm add_popular FROM_PAGE N_PAGES MASK # add popular packages
# sl2pm clear_cache # clear cache
# sl2pm help [COMMAND] # Describe available commands or one spec...
# sl2pm list MASK # list all of the available packages
# sl2pm open PACKAGE_NAME # open in browser package description
class ClassA
@@class_var1 = 1
@var1 = -1
class << self
attr_accessor :attr_var1
def class_method1
puts "\t#{self.class}.class_method1"
puts "\t\t@var1: #{@var1}"
@hightemp
hightemp / gist:11185204
Created April 22, 2014 16:16
Remove PATH duplicates
PATH=$(echo "$PATH" | awk -v RS=':' -v ORS=":" '!a[$1]++')
@hightemp
hightemp / gist:11196851
Last active February 5, 2025 11:04
Convert .vdi to .img
vboxmanage clonehd image.vdi image.img --format RAW
qemu-img convert -f vdi -O raw image.vdi image.img
vbox-img convert --srcfilename image.vdi --stdout --srcformat VDI --dstformat RAW image.img
@hightemp
hightemp / gist:11204728
Created April 23, 2014 06:36
Removing Nessus
To remove Nessus, delete the following directories (including subdirectories) and files:
/Library/Receipts/Nessus*
/Library/LaunchDaemons/com.tenablesecurity.nessusd.plist
/Library/Nessus
/Library/PreferencePanes/Nessus Preferences.prefPane
/Applications/Nessus

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like:

@hightemp
hightemp / gist:11385239
Created April 28, 2014 21:57
How to securely hash passwords?

The Theory

We need to hash passwords as a second line of defence. A server which can authenticate users necessarily contains, somewhere in its entrails, some data which can be used to validate a password. A very simple system would just store the passwords themselves, and validation would be a simple comparison. But if an hostile outsider gains a simple glimpse at the contents of the file or database table which contains the passwords, then that attacker learns a lot. Unfortunately, such partial, read-only breaches do occur in practice (a mislaid backup tape, a decommissioned but not wiped out hard disk, as an aftermath of a SQL injection attack... the possibilities are numerous). See this blog post for a detailed discussion.

Since the overall contents of a server which can validate passwords are necessarily sufficient to, indeed, validate passwords, an attacker who got a read-only snapshot of the server is in position to ma

@hightemp
hightemp / applify
Last active August 29, 2015 14:14
Allows you to easily create Mac apps from shell scripts
#!/bin/bash
INSTALLPATH="/usr/local/bin"
if [ "$1" = "install" ]; then
chmod +x $0
cp $0 $INSTALLPATH/$(basename "$0" ".sh")
echo "Installed into $INSTALLPATH"
exit 0
elif [ "$1" = "createapp" -o "$1" = "installapp" ]; then
@hightemp
hightemp / gist:3862e50023b45b1b7035
Created February 2, 2015 16:38
Credit card number checker
function fnValidCreditCardNumber( objFormField )
{
var nSum = 0;
var nMultiplier = 1;
var nIndex;
var sDigit;
var nProduct;
var sCreditCardAccountNumber = objFormField.value;
var nLength = objFormField.value.length;
#!/bin/bash
# Script to convert PDF file to JPG images
#
# Dependencies:
# * pdftk
# * imagemagick
PDF=$1