Skip to content

Instantly share code, notes, and snippets.

@jrdmb
jrdmb / github_gist_tips
Last active August 29, 2015 14:18
GitHub and Gist Tips
To list remote Git branches (from: http://rakhesh.com/coding/list-remote-branches/):
git ls-remote
git remote show origin
Create and delete local and remote Git branches
http://rakhesh.com/coding/creating-and-delete-remote-git-branches/
Move the .git folder out of the working tree
http://rakhesh.com/coding/how-to-move-separate-the-git-folder-out-of-your-working-tree/
@jrdmb
jrdmb / vba-sha-512.md
Last active June 5, 2020 05:24
VBA Code for SHA-512 hash using mscorlib.dll

Other links to creating SHA-512 hashes in various Windows apps:

The code below is adapted from: http://stackoverflow.com/questions/11394811/compute-sha512-on-vba-excel-2003

64-bit MS Access VBA code to calculate an SHA-512 or SHA-256 hash in VBA.  This requires a VBA reference to the .Net Framework 4.0 mscorlib.dll.  The hashed strings are calculated using calls to encryption methods built into mscorlib.dll.  The calculated hash strings are the same values as those calculated with jsSHA, a Javascript SHA implementation (see htt
@jrdmb
jrdmb / tsql schema queries.sql
Last active August 29, 2015 14:18
T-SQL Schema Queries
SELECT * FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = N'PROCEDURE' and ROUTINE_SCHEMA = N'dbo'
and SPECIFIC_NAME like 'usp%'
select TABLE_NAME from INFORMATION_SCHEMA.TABLES
#tsql
@jrdmb
jrdmb / SHA-256 VBScript.vbs
Last active April 20, 2023 06:46
VBScript code for SHA-256 hash
'also see: https://gist.github.com/anonymous/573a875dac68a4af560d
Option Explicit
Dim intValid
Dim objMD5, objSHA256
Dim strAlgorithm, strHash, strString
intValid = 0
@jrdmb
jrdmb / Powershell_String_Hashes.ps1
Last active February 11, 2020 21:50
Hash a string in Powershell with various encryption algorithms
#Here is a simple script to hash a string using your chosen cryptography algorithm.
#Usage Examples:
#Get-StringHash "My String to hash" "MD5"
#Get-StringHash "My String to hash" "RIPEMD160"
#Get-StringHash "My String to hash" "SHA1"
#Get-StringHash "My String to hash" "SHA256"
#Get-StringHash "My String to hash" "SHA384"
#Get-StringHash "My String to hash" "SHA512"
#http://jongurgul.com/blog/#Get-StringHash-get-filehash/
@jrdmb
jrdmb / SqlServer_DB_Role_Members.sql
Last active August 29, 2015 14:18
Sql Server database role members
-- Database Role Members
SELECT Users.name AS UserName, Roles.name AS RoleName,
'EXEC sp_droprolemember '+QUOTENAME(Roles.name,'''')+','+QUOTENAME(Users.name,'''')+';' AS Drop_Script,
'EXEC sp_addrolemember '+QUOTENAME(Roles.name,'''')+','+QUOTENAME(Users.name,'''')+';' AS Add_Script
FROM sys.database_role_members RoleMembers
JOIN sys.database_principals Users
ON RoleMembers.member_principal_id = Users.principal_id
JOIN sys.database_principals Roles
ON RoleMembers.role_principal_id = Roles.principal_id
--WHERE Users.name LIKE '%MyUserName%'
@jrdmb
jrdmb / SqlServer Query DB Permissions.sql
Last active August 29, 2015 14:18
For the current database, query permissions to objects (show all objects even if no permissions)
--All relevant db objects and permissions
;With CTE As
(
select o.name, o.type, o.type_desc, p.permission_name, p.state_desc, p.state, u.name as 'users'
from sys.objects o
left outer join sys.database_permissions p On o.object_id = p.major_id
left outer JOIN sys.sysusers u ON p.grantee_principal_id = u.uid
where o.type Not In ('D', 'F', 'IT', 'PK', 'S', 'SQ', 'UQ')
)
select distinct name, type, type_desc, permission_name, state_desc, state,