Skip to content

Instantly share code, notes, and snippets.

@cmatskas
cmatskas / PowershellSQLQuery.ps1
Last active January 23, 2024 17:14
PowershellSQLQuery.ps1
[string] $Server= ".\SQLEXPRESS2014"
[string] $Database = "MyDatabase"
[string] $UserSqlQuery= $("SELECT * FROM [dbo].[User]")
# declaration not necessary, but good practice
$resultsDataTable = New-Object System.Data.DataTable
$resultsDataTable = ExecuteSqlQuery $Server $Database $UserSqlQuery
# executes a query and populates the $datatable with the data
function ExecuteSqlQuery ($Server, $Database, $SQLQuery) {
@cmatskas
cmatskas / polly_python.py
Created November 15, 2023 00:13
amazon_polly_python
import boto3
import os
audiofile = 'speech.mp3'
polly_client = boto3.client('polly')
response = polly_client.synthesize_speech(VoiceId='Joanna',
OutputFormat='mp3',
Text = 'This is a sample text to be synthesized.',
Engine = 'neural')
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Protocols;
@cmatskas
cmatskas / csvUploadTest.js
Last active January 11, 2023 19:42
csvUploadTest.js
<!DOCTYPE html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// The event listener for the file upload
document.getElementById('txtFileUpload').addEventListener('change', upload, false);
@cmatskas
cmatskas / XMLHttpHandler.cs
Created September 18, 2015 16:00
XmlHttpHandler.cs
public class MySuperDuperHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var configService = new ConfigService();
var page = new OutputCachedPage(new OutputCacheParameters
{
Duration = 300, // in seconds
Location = OutputCacheLocation.Server,
VaryByParam = "None"

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@cmatskas
cmatskas / GitDeleteCommands.ps1
Last active September 22, 2022 07:59
Git Delete Branch commands
## Delete a remote branch
$ git push origin --delete <branch> # Git version 1.7.0 or newer
$ git push origin :<branch> # Git versions older than 1.7.0
## Delete a local branch
$ git branch --delete <branch>
$ git branch -d <branch> # Shorter version
$ git branch -D <branch> # Force delete un-merged branches
## Delete a local remote-tracking branch
@cmatskas
cmatskas / ExportChromePasswords.js
Created October 28, 2015 17:12
ExportChromePasswords.js
var decryptedRow="";
var pm = PasswordManager.getInstance();
var model = pm.savedPasswordsList_.dataModel;
var pl = pm.savedPasswordsList_;
for(i=0;i<model.length;i++){
PasswordManager.requestShowPassword(i);
};
setTimeout(function(){
decryptedRow += '"hostname","username","password","formSubmitURL","httpRealm","usernameField","passwordField"';
for(i=0; i<model.length; i++){
@cmatskas
cmatskas / scanIPs.ps1
Created May 5, 2022 16:10
Scan All IP Addresses on Internal Network
1..254 | ForEach-Object {
if(!(Test-Connection 192.168.153.$_ -count 1 -Quiet)) {
Write-Output "IP Address Available 192.168.153.$_"
}
else {
Write-Output "IP Address in use 192.168.153.$_"
}
}
@cmatskas
cmatskas / PowershellSqlCommandDataAdapter.ps1
Created September 22, 2015 08:58
PowershellSqlCommandDataAdapter.ps1
[string] $Server= ".\SQLEXPRESS2014"
[string] $Database = "MyDatabase"
[string] $UserSqlQuery= $("SELECT * FROM [dbo].[User]")
$resultsDatatable = ExecuteSqlQuery $Server $Database $UserSqlQuery
function GenericSqlQuery ($Server, $Database, $SQLQuery) {
$Datatable = New-Object System.Data.DataTable
$Connection = New-Object System.Data.SQLClient.SQLConnection