Skip to content

Instantly share code, notes, and snippets.

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN TRANSACTION;
Declare @counter int
select @counter = counterID from myTable order by counterID asc
select @counter = @counter + 1
INSERT INTO myTable (counterID) VALUES (@counter)
Select @counter as newCounterID
COMMIT TRANSACTION;
@alanning
alanning / dump.sh
Last active July 24, 2022 23:42
Backup script that dumps a mongo database and compresses the result. Can be run on-demand or via nightly cron job.
#!/bin/bash
# Performs a dump of target database and compresses result.
# Outputs to: $DUMPDIR/$DUMPNAME.tar.xz
# Note: Absolute paths are required for use in cron jobs
DBNAME=meteor
ROOTDIR=/Users/alanning/foo
DUMPDIR=$ROOTDIR/dumps
@evenkiel
evenkiel / gist:e218c595f76794dcc022
Created February 12, 2015 22:55
SQL Server Performance Tuning Class - Day 4

SQL Server Performance Tuning Class - Day 4

How to Measure Your Server

  • 3 Key Numbers
    • How busy is your server
    • How hard is it working
    • Ho wmuch data do you have

How Busy is Your Server

  • Perfmon SQLServer:SQL Statistics - Batch Requests/sec. Trend this on an hourly basis and break it out by Weekday/Weekend
@YujiShen
YujiShen / SQL_COOKBOOK_TABLE.sql
Created February 6, 2016 04:04
Table EMP and DEPT of SQL Cookbook for MySQL
-- Thanks to http://justinsomnia.org/2009/04/the-emp-and-dept-tables-for-mysql/
DROP TABLE IF EXISTS emp;
CREATE TABLE emp (
empno decimal(4,0) NOT NULL,
ename varchar(10) default NULL,
job varchar(9) default NULL,
mgr decimal(4,0) default NULL,
hiredate date default NULL,
@ashish2199
ashish2199 / SQL Server commands and queries.md
Last active November 8, 2024 16:30
List of Microsoft SQL Server queries and commands

To create a Table

	create table risk_clos_rank(
		id_num int IDENTITY(1,1) NOT NULL,
	    username nvarchar(100),
	    datetime_of_decision DATETIME
	);
	
	CREATE TABLE TheNameOfYourTable (
 ID INT NOT NULL IDENTITY(1,1),
@RulerOf
RulerOf / plex-streaming-quality-settings.md
Last active October 16, 2023 03:53
Adjusting Plex Media Player streaming quality defaults and per-stream

Setting a default quality in Plex Media Player desktop

The Plex Media Player desktop application's default quality setting is in different places depending on the interface you're using. The Plex Web UI is used as a point-and-click interface, whereas the Plex Media Player TV UI is used as a remote-friendly interface.

Plex Web UI Plex Media Player TV UI
# Dark Theme
$file = gi "${env:ProgramFiles(x86)}\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.pkgundef"; ($file | gc) -Replace '(.*{1ded0138-47ce-435e-84ef-9ec1f439b749})', '//$1' | Out-File $file;
# Query execution settings
$ssmsUserSettingsFile = "$($env:APPDATA)\Microsoft\SQL Server Management Studio\18.0\UserSettings.xml";
$newXml = "<Element><Key><int>-1</int></Key><Value><string /></Value></Element>
<Element><Key><int>3</int></Key><Value><string /></Value></Element>
<Element><Key><int>4</int></Key><Value><string /></Value></Element>
<Element><Key><int>5</int></Key><Value><string>USE </string></Value></Element>
<Element><Key><int>6</int></Key><Value><string>SELECT FORMAT(COUNT(*),'N0') FROM </string></Value></Element>
<Element><Key><int>7</int></Key><Value><string>SELECT TOP(100) * FROM </string></Value></Element>
@juergenhoetzel
juergenhoetzel / getstarred.ps1
Last active August 3, 2022 20:26
List starred Github repos in Powershell
$user = "juergenhoetzel"
$p = 1
do {
$full_names = Invoke-RestMethod "https://api.github.com/users/$user/starred?per_page=100&page=$p"
$full_names.ForEach({$_.full_name})
$p++
} while ($full_names.Length -gt 0)