Skip to content

Instantly share code, notes, and snippets.

@mnjstwins
mnjstwins / redis_cheatsheet.bash
Created September 1, 2017 13:36 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@mnjstwins
mnjstwins / InstallSqlForDev.ps1
Created October 3, 2017 19:08 — forked from LeeCampbell/InstallSqlForDev.ps1
Install SQL 2016 Dev command line (Powershell)
#Installs SQL Server locally with standard settings for Developers/Testers.
# Install SQL from command line help - https://msdn.microsoft.com/en-us/library/ms144259.aspx
$sw = [Diagnostics.Stopwatch]::StartNew()
$currentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name;
$SqlServerIsoImagePath = "???\Downloads\Microsoft\SQL Server 2016 Developer Edition\en_sql_server_2016_developer_x64_dvd_8777069.iso"
#Mount the installation media, and change to the mounted Drive.
$mountVolume = Mount-DiskImage -ImagePath $SqlServerIsoImagePath -PassThru
$driveLetter = ($mountVolume | Get-Volume).DriveLetter
$drivePath = $driveLetter + ":"
@mnjstwins
mnjstwins / TerraformCredentials.ps1
Created October 5, 2017 13:28 — forked from bobalob/TerraformCredentials.ps1
Set Environment Variables in PowerShell for Azure RM Terraform
#Set Environment Variables for Azure RM Terraform
$ENV:ARM_SUBSCRIPTION_ID = ""
$ENV:ARM_CLIENT_ID = ""
$ENV:ARM_CLIENT_SECRET = "" # This should end with an '=' symbol
$ENV:ARM_TENANT_ID = ""
@mnjstwins
mnjstwins / Export-SplunkSearch.ps1
Created November 30, 2017 20:22 — forked from halr9000/Export-SplunkSearch.ps1
Splunk export search job using PowerShell
# Conversion of http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#search.2Fjobs.2Fexport
# example using curl, to PowerShell with Invoke-RestMethod cmdlet
#
# $ curl -k -u admin:changeme https://localhost:8089/services/search/jobs/export
# --data-urlencode search="search index=_internal | stats count by sourcetype"
# -d output_mode=json -d earliest="rt-5m" -d latest="rt"
$cred = Get-Credential
# This will allow for self-signed SSL certs to work
@mnjstwins
mnjstwins / Send-SendGridMessage.ps1
Created February 8, 2018 19:27 — forked from pkskelly/Send-SendGridMessage.ps1
Sending Email from PowerShell using SendGrid (in Azure)
$Username ="azure_*********@azure.com"
$Password = ConvertTo-SecureString "********" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $Username, $Password
$SMTPServer = "smtp.sendgrid.net"
$EmailFrom = "[email protected]"
$EmailTo = "[email protected]"
$Subject = "SendGrid test"
$Body = "SendGrid testing successful"
Send-MailMessage -smtpServer $SMTPServer -Credential $credential -Usessl -Port 587 -from $EmailFrom -to $EmailTo -subject $Subject -Body $Body
@mnjstwins
mnjstwins / UseServiceBusFromPowershell.ps1
Created February 12, 2018 17:45 — forked from rberrelleza/UseServiceBusFromPowershell.ps1
Send and receive messages to a Service Bus queue via PowerShell
Import-Module "PATH_TO_Microsoft.ServiceBus.dll"
#Create the required credentials
$tokenProvider = [Microsoft.ServiceBus.TokenProvider]::CreateSharedSecretTokenProvider("owner", "YOUR_ISSUERSECRET")
$namespaceUri = [Microsoft.ServiceBus.ServiceBusEnvironment]::CreateServiceUri("sb", "YOUR_NAMESPACE", "");
$namespaceManager = New-Object Microsoft.ServiceBus.NamespaceManager $namespaceUri,$tokenProvider
#Create a queue
$queue = $namespaceManager.CreateQueue("MyPowershellQueue");
# Step 1 - Exporting SecureString from Plain text
"P@ssword1" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File "C:\Temp 2\Password.txt"
# Step 2 - Creating PSCredential object
$User = "MyUserName"
$File = "C:\Temp 2\Password.txt"
$MyCredential=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)
# The Default Execution Policy is set to restricted, you can see it by typing:
Get-ExecutionPolicy
@mnjstwins
mnjstwins / traceroute.js
Created September 11, 2018 13:43 — forked from liamgriffiths/traceroute.js
traceroute clone in javascript
// sloppy traceroute clone
// inpired by https://blogs.oracle.com/ksplice/entry/learning_by_doing_writing_your
// and made possible by https://www.npmjs.org/package/raw-socket
var raw = require('raw-socket');
var dns = require('dns');
var target = process.argv[2] || '173.230.146.29';
var MAX_HOPS = 64;
var TIME_LIMIT = 5000;
@mnjstwins
mnjstwins / Division42NetworkToolsDemo.cs
Created October 30, 2018 14:18
Example code to show how to use Division42.NetworkTools.
class Program
{
static void Main(string[] args)
{
DemoPing();
//DemoTraceRoute();
//DemoPortScan();
//DemoWhois();
Console.WriteLine();
@mnjstwins
mnjstwins / mandrill.js
Created April 22, 2019 12:45 — forked from andris9/mandrill.js
Nodemailer using Mandrill
'use strict';
// Nodemailer: v2.0.0
// Ubuntu: 14.04
// node: v5.5.0
// npm: 3.3.12
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'Mandrill',