Skip to content

Instantly share code, notes, and snippets.

@andyj
andyj / gist:11eb25b52d4d72df3f80
Last active March 17, 2016 12:45
IP4 IPTable rules
# Found on https://nodeswat.com/blog/setting-up-a-secure-node-js-web-application/
# Slightly modified
*filter
# Default policy is to drop all traffic
-P INPUT DROP
-P FORWARD DROP
-P OUTPUT DROP
@andyj
andyj / findSPByDefinition.sql
Created October 26, 2015 22:53
Searching MSSQL database for a Stored Proc by T-SQL Definition
sp_MSforeachdb 'SELECT "?" AS DB,
r.SPECIFIC_SCHEMA, r.routine_name, r.ROUTINE_DEFINITION, p.ORDINAL_POSITION, p.PARAMETER_MODE, p.PARAMETER_NAME, p.DATA_TYPE
FROM [?].INFORMATION_SCHEMA.ROUTINES r
JOIN [?].INFORMATION_SCHEMA.PARAMETERS p ON r.SPECIFIC_SCHEMA = p.SPECIFIC_SCHEMA AND r.SPECIFIC_NAME = p.SPECIFIC_NAME
WHERE
r.ROUTINE_TYPE = ''PROCEDURE''
AND left(r.ROUTINE_NAME,2) <> ''dt''
AND r.ROUTINE_DEFINITION LIKE ''%someSQLCode%''
ORDER BY r.SPECIFIC_NAME ASC, p.ORDINAL_POSITION ASC'
@andyj
andyj / findSPByName.sql
Created October 26, 2015 22:51
Searching MSSQL database for a Stored Proc by name
sp_MSforeachdb 'SELECT "?" AS DB,
r.SPECIFIC_SCHEMA, r.routine_name, r.ROUTINE_DEFINITION, p.ORDINAL_POSITION, p.PARAMETER_MODE, p.PARAMETER_NAME, p.DATA_TYPE
FROM [?].INFORMATION_SCHEMA.ROUTINES r
JOIN [?].INFORMATION_SCHEMA.PARAMETERS p ON r.SPECIFIC_SCHEMA = p.SPECIFIC_SCHEMA AND r.SPECIFIC_NAME = p.SPECIFIC_NAME
WHERE
r.ROUTINE_TYPE = ''PROCEDURE''
AND left(r.ROUTINE_NAME,2) <> ''dt''
AND r.routine_name LIKE ''%yourStoredProcName%''
ORDER BY r.SPECIFIC_NAME ASC, p.ORDINAL_POSITION ASC'
@andyj
andyj / find-MSSQL-table-on-server.sql
Created October 26, 2015 22:29
Search all MSSQL databases on a server for a table
sp_MSforeachdb 'SELECT "?" AS DB, * FROM [?].sys.tables WHERE name like ''%tableNameYouAreSearchingFor%'''
@andyj
andyj / isAddressDown-SoundAlarm.sh
Created October 26, 2015 22:25
Terminal script to sound alarm when an IP address is not reachable again
pingIpAddress=google.com
while :
do
ping -t 2 -o -c 1 $pingIpAddress || say ping to $pingIpAddress failing
sleep 2
done
@andyj
andyj / isAddressUp-SoundAlarm.sh
Created October 26, 2015 22:21
Terminal script to sound alarm when an IP address is reachable again
pingAddress=google.com
while :
do
ping -t 2 -o pingAddress && say ping $pingAddress working
sleep 2
done
@andyj
andyj / find-and-kill.sql
Created October 13, 2015 08:54
Transaction (Process ID) was deadlocked on lock - find and kill process
CREATE TABLE #Result
(
spid int,
ecid int,
status varchar(max),
loginname varchar(max),
hostname varchar(max),
blk varchar(max),
dbname varchar(max),
cmd varchar(max),
@andyj
andyj / ColdFusion-hash-in-javascript.js
Created October 8, 2015 10:05
Replicating ColdFusion hash() function in Javascript
var crypto = require('crypto');
var pwd = "Password1!";
var hash = function(str){
return crypto.createHash('sha256').update(pwd).digest('hex').toUpperCase()
}
console.log( hash(pwd) );
@andyj
andyj / ubunut-*.nix-cheat-sheet.md
Last active September 7, 2015 21:32 — forked from anonymous/ubunut-*.nix-cheat-sheet
Ubuntu / *nix cheat sheet

##File size

Display the biggest top-20 directories

du -ah . | sort -rh | head -20

Display largest files

find [directory i.e. ~/] -type f -printf "%s - %p\n" | sort -n | tail -n 100

@andyj
andyj / gist:e67a85eb8bb6ff375874
Last active August 29, 2015 14:14
stacktrace - NoClassDefFoundError
java.lang.NoClassDefFoundError "railo/loader/util/Util"
railo/loader/util/Util at railo.extension.io.log.sl4j.LoggerAdapterConsole.getStacktrace(LoggerAdapterConsole.java:119):119
at railo.extension.io.log.sl4j.LoggerAdapterConsole.log(LoggerAdapterConsole.java:64):64
at railo.extension.io.log.sl4j.LoggerAdapterConsole.error(LoggerAdapterConsole.java:54):54
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:222):222
at lucee.runtime.orm.hibernate.HibernateSessionFactory.schemaExport(Unknown Source):-1
at lucee.runtime.orm.hibernate.HibernateSessionFactory.createConfiguration(Unknown Source):-1
at lucee.runtime.orm.hibernate.SessionFactoryData.setConfiguration(Unknown Source):-1
at lucee.runtime.orm.hibernate.HibernateORMEngine.getSessionFactoryData(Unknown Source):-1