Skip to content

Instantly share code, notes, and snippets.

Avatar
🍇

Sascha Bajonczak SBajonczak

🍇
View GitHub Profile
@SBajonczak
SBajonczak / Sensor.txt
Last active Dec 20, 2021
MailboxSensor Actions
View Sensor.txt
const postbox = "fhem.0.Postbox.state"
const deskLamp = "wled.0.84f3ebb2f0d2"
on('fhem.0.Postbox.state', _ => {
if (_.state.val == "closed") {
setState("".concat(deskLamp, ".on"), true);
setState("".concat(deskLamp, ".seg.0.fx"), 37);
setTimeout(() => {
setState("".concat(deskLamp, ".on"), false);
setState("".concat(deskLamp, ".seg.0.fx"), 0);
View gist:ec7a7dd1cbdc1fd2a546ed69d6257f39
public class RequestTool
{
readonly readonly HttpClient client;
public DbRepo(HttpClient client)
{
this.client = client;
}
@SBajonczak
SBajonczak / StartupRetryPolcyPolly
Created Dec 19, 2021
Startup configuration with Polly and retry method
View StartupRetryPolcyPolly
public class Startup : Startup
{
static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
{
var retryWithJitterPolicy = HttpPolicyExtensions
.HandleTransientHttpError()
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.Forbidden)
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.Unauthorized)
@SBajonczak
SBajonczak / CreateIndexonIndex.sql
Created Dec 16, 2021
Create an index on an INDEX Filegroup
View CreateIndexonIndex.sql
CREATE NONCLUSTERED INDEX [MyIndex] ON [dbo].[MyTable] ([Field]) INCLUDE ([Field2]) ON [INDEX]
@SBajonczak
SBajonczak / CreateTable.sql
Created Dec 16, 2021
CreateSqlTableOnPrimaryFilegroup
View CreateTable.sql
create table person
(
id bigint,
name varchar(500),
surname varchar(500)
)
on [PRIMARY]
@SBajonczak
SBajonczak / Fragmentation.sql
Created Dec 15, 2021
Insights of Index Fragmentation
View Fragmentation.sql
SELECT S.name as 'Schema',
T.name as 'Table',
I.name as 'Index',
DDIPS.avg_fragmentation_in_percent,
DDIPS.page_count
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) AS DDIPS
INNER JOIN sys.tables T on T.object_id = DDIPS.object_id
INNER JOIN sys.schemas S on T.schema_id = S.schema_id
INNER JOIN sys.indexes I ON I.object_id = DDIPS.object_id
AND DDIPS.index_id = I.index_id
@SBajonczak
SBajonczak / Index Statistics
Created Dec 15, 2021
Get statistics of all indexes
View Index Statistics
select
i.name,
s.last_system_lookup,
last_system_scan,
last_system_seek,
last_system_update,
last_user_lookup,
last_user_scan,
last_user_scan,
last_user_seek,
View IndexStatistics.sql
- Ensure a USE statement has been executed first.
SELECT [DatabaseName]
,[ObjectId]
,[ObjectName]
,[IndexId]
,[IndexDescription]
,CONVERT(DECIMAL(16, 1), (SUM([avg_record_size_in_bytes] * [record_count]) / (1024.0 * 1024))) AS [IndexSize(MB)]
,[lastupdated] AS [StatisticLastUpdated]
,[AvgFragmentationInPercent]
FROM (
@SBajonczak
SBajonczak / IndexSize.sql
Created Dec 14, 2021
Get Index Size for each table in the Database
View IndexSize.sql
SELECT i.[name] AS IndexName
,SUM(s.[used_page_count]) * 8 AS IndexSizeKB
FROM sys.dm_db_partition_stats AS s
INNER JOIN sys.indexes AS i ON s.[object_id] = i.[object_id]
AND s.[index_id] = i.[index_id]
GROUP BY i.[name]
ORDER BY i.[name]
View docker-compose.yml
version: "3"
services:
FALCON:
image: falconchristmas/fpp
container_name: falcon
restart: always
volumes:
- "/docker/fpp/media:/home/fpp/media"
- "/docker/fpp/modprobe:/etc/modprobe.d"
ports: