Skip to content

Instantly share code, notes, and snippets.

Avatar
🧸
teddygang

Laim

🧸
teddygang
View GitHub Profile
@Laim
Laim / versions.ps1
Last active May 7, 2021
PowerShell, .NET and SQL Instance Versions in PowerShell
View versions.ps1
# START : Get SQL Instance Version #
cls # prevents the script itself from echoing out into ISE
"---------------------------------------------------------------------"
$inst = (get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances # Gets the installed SQL instances
$sqlInstanceCount = 0; # loop for the foreach
foreach ($i in $inst)
View backuprestoreprocess.sql
/*
Modified version of https://blog.sqlauthority.com/2017/03/12/get-status-running-backup-restore-sql-server-interview-question-week-113/
*/
SELECT r.session_id AS [Session_Id]
,r.command AS [command]
,CONVERT(NUMERIC(6, 2), r.percent_complete) AS [% Complete]
,CONVERT(VARCHAR(20), DATEADD(ms, r.estimated_completion_time, GetDate()), 20) AS [Estimated Completion Time]
,CONVERT(NUMERIC(32, 2), r.total_elapsed_time / 1000.0 / 60.0) AS [Elapsed Minutes]
@Laim
Laim / sp_who2_filter.sql
Last active May 7, 2021
sp_who2 filtering
View sp_who2_filter.sql
/*
Author: Laim McKenzie
Date: 30-04-2021
Updated: 07-05-2021
https://laim.scot
*/
/* Create temp table to populate with data */
CREATE TABLE #sp_who2
(
@Laim
Laim / feed.xml
Last active Feb 8, 2021
Jekyll working RSS feed.xml
View feed.xml
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ site.name | xml_escape }}</title>
<description>{{ site.description | xml_escape }}</description>
<link>{{ site.url }}</link>
<atom:link href="{{ site.url }}/feed.xml" rel="self" type="application/rss+xml" />
{% for post in site.posts limit:10 %}
<item>
<title>{{ post.title }}</title>
@Laim
Laim / RestoreSQLServerDatabase.sql
Last active May 27, 2020
Restore SQL Server Database
View RestoreSQLServerDatabase.sql
-- Take the database offline before restoring
ALTER DATABASE [DatabaseName]
SET OFFLINE WITH ROLLBACK IMMEDIATE
-- Restore the database
RESTORE DATABASE DatabaseName FROM DISK = '\\FileServer\directory\servername\database\database_backup.bak'
-- Bring it back online, this should be automatic but just incase.
ALTER DATABASE [DatabaseName]
SET ONLINE
@Laim
Laim / MT.vbs
Created Apr 22, 2020
machinetype
View MT.vbs
strName = "." 'Computer name, if local just use a period.
Set objWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strName & "\root\cimv2")
For Each obj in objWMI.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each strChassisType in obj.ChassisTypes
Wscript.Echo strChassisType
Next
Next
View api.trakt.php
<?php
$user = "laim";
$key = "";
$type = "history"; //history or watching
// You need to register an API app here https://trakt.tv/oauth/applications to get the API Key (ClientID)
function traktAPI($user, $key, $type) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.trakt.tv/users/$user/$type");
@Laim
Laim / style.css
Created Dec 29, 2019
Dark Mode based on System
View style.css
body {
font-family: monospace;
background-color: #1d1f21;
color: #FFF;
}
a:link {
text-decoration:none;
color:#CC3300;
}
@Laim
Laim / form.vb
Last active Oct 24, 2019
Get Subkeys in registry
View form.vb
Imports YourApp.Registry
Public Class frmMain
Private Sub btnRegGet_Click(sender As Object, e As EventArgs) Handles btnRegGet.Click
Try
lbKeys.Items.Clear()
For Each i In getKeys("SOFTWARE\Google")
lbKeys.Items.Add(i.ToString)
Next
View #4.html
<script>
function SearchEnabled() {
if(document.getElementById("ext_search_txt").value==="") {
document.getElementById('ext_search').disabled = true;
} else {
document.getElementById('ext_search').disabled = false;
}
}
</script>