Skip to content

Instantly share code, notes, and snippets.

@ismits
ismits / Oracle.psm1
Last active May 1, 2019 19:46
PowerShell module for Oracle DB
<#
.NOTES
Name: Oracle.psm1
Author: Immanuel Smits
Version History:
1.0 - 7/12/2016 - Initial Release.
.SYNOPSIS
Module to provide database access to PowerShell
.DESCRIPTION
Expanded description of what the script does.
@ismits
ismits / Invoke-ShellCommand.ps1
Created May 1, 2019 19:41
PowerShell invoke shell command
function Invoke-ShellCommand
{
param (
$Command,
$Arguments,
$WorkingDirectory
)
$psi = New-object System.Diagnostics.ProcessStartInfo
@ismits
ismits / Is-Elevated.ps1
Created May 1, 2019 19:40
PowerShell function to test whether the current script is running as an elevated admin
function Is-Elevated
{
$wid = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$prp = New-Object System.Security.Principal.WindowsPrincipal($wid)
$adm = [System.Security.Principal.WindowsBuiltInRole]::Administrator
$IsAdmin = $prp.IsInRole($adm)
return $IsAdmin
}
function Exit-WithPause($errlevel) {
Write-Host "Press any key to continue..."
$anykey = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Exit $errLevel
}
@ismits
ismits / Write-CertificateToTempFile.ps1
Created April 26, 2019 18:35
Dump SSL certificate to a temp file from URI
function Write-CertificateToTempFile($uri) {
$http = [Net.WebRequest]::Create($uri)
try {
$resp = $http.GetResponse()
$cert = $http.ServicePoint.Certificate
$byte = $cert.Export([Security.Cryptography.X509Certificates.X509ContentType]::Cert)
}
catch {
Write-Warning "Errors encoutered during connection attempt:`n$_"
Write-Warning "Cannot continue. Quitting."
@ismits
ismits / index.js
Created February 26, 2019 16:58
Lambda http get using aws-sdk
'use strict';
const AWS = require('aws-sdk');
// define our target API as a "service"
const svc = new AWS.Service({
// the API base URL
endpoint: 'https://www.metaweather.com/api',
// don't parse API responses
@ismits
ismits / oracleselectregex.sql
Last active August 22, 2017 15:47
Oracle select with regex
SELECT first_name, last_name
FROM employees
WHERE REGEXP_LIKE (first_name, '^Ste(v|ph)en$');
final Configuration antlrConfiguration = project.getConfigurations().create(ANTLR_CONFIGURATION_NAME)
.setVisible(false)
.setDescription("The Antlr libraries to be used for this project.")
antlrConfiguration.defaultDependencies(new Action<DependencySet>() {
@Override
public void execute(DependencySet dependencies) {
dependencies.add(project.getDependencies().create("antlr:antlr:2.7.7@jar"))
}
})
@ismits
ismits / Ping.groovy
Last active May 12, 2017 21:13
Ping a remote host in groovy
import org.slf4j.Logger
import org.slf4j.LoggerFactory
class Ping
{
public static Boolean isReachable(String hostname) {
Logger logger = LoggerFactory.getLogger('com.example.utils.system.ping')
logger.debug("[Ping.isReachable] isReachable called with hostname: {}", hostname)
if (! hostname?.trim()) {