Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am cteodor on github.
* I am cteodor_kb (https://keybase.io/cteodor_kb) on keybase.
* I have a public key ASDyJ9HBiUK68qUghROoJf-wMaGiVonRNJ25zPqpMSzhswo
To claim this, I am signing this object:
@cteodor
cteodor / gist:e1b9846ac50e0be47e574ecc3b228a8e
Last active July 22, 2019 21:54
execvep vs. proc/environ
#define _GNU_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/wait.h>
int main(int argc, char* argv[], char* envp[]) {
pid_t ppid = getppid();
@cteodor
cteodor / ps-mssql-sample.ps1
Created March 25, 2018 22:54
Connecting to a MSSQL db and doing a simple query
$sqlConn = New-Object System.Data.SqlClient.SqlConnection
$sqlConn.ConnectionString = 'Server=192.168.244.129;Initial Catalog=dbname;User Id=sqltest;Password=test123'
$sqlConn.Open()
$sqlcmd = $sqlConn.CreateCommand()
#$query = “SELECT name, database_id FROM sys.databases”
$query = “SELECT * from dbname"
$sqlcmd.CommandText = $query
$adp = New-Object System.Data.SqlClient.SqlDataAdapter $sqlcmd
@cteodor
cteodor / mssql-utils.ps1
Created March 25, 2018 19:43
Parse MS SQL BAK file information returned by sqlcmd
Function get-MSSQLBAKVersion {
param(
[parameter(Mandatory=$true)]
[ValidateScript({Test-Path -Path $_ -pathType leaf})]
[String]$bakfile
)
$query = "restore headeronly from disk=N'{0}' with nounload" -f $bakfile
$bakInfo = & SQLCMD.EXE -s"," -Q $query | Select-String -NotMatch '^-|\('|convertfrom-csv
$sqlVersions = @{
"869" = "SQL Server 2017"

Keybase proof

I hereby claim:

  • I am cteodor on github.
  • I am cteodor (https://keybase.io/cteodor) on keybase.
  • I have a public key ASB1-hF5OXFlqCszNKIgJ1hGUUY_8FM5Wu5eWorI7LU3Awo

To claim this, I am signing this object: