Skip to content

Instantly share code, notes, and snippets.

View SBajonczak's full-sized avatar
🍇

Sascha Bajonczak SBajonczak

🍇
View GitHub Profile
@SBajonczak
SBajonczak / checkPermission.cs
Created December 28, 2021 09:28
Generate Bitmask Check
public bool HasAccessTo(int profileValue, ApplicationRole roleToCheck){
return (profileValue & roleToCheck) === roleToCheck
}
// Will result true
bool result= HasAccesTo(21,ApplicationRole.Contributor);
// Will result false
bool result= HasAccesTo(21,ApplicationRole.Administrator);
@SBajonczak
SBajonczak / BItmaskEnum.cs
Last active December 27, 2021 18:43
BistmaskEnumeration Definitions
public enum ApplicationRole
{
Visitor=1,
Reader=2,
Contributor=4,
Administrator=8,
Owner=16
}
@SBajonczak
SBajonczak / non-clustered-vs.md
Created December 27, 2021 17:33
Differences between Clustered Index and NonClustered Index
Parameters Clustered Non-clustered
Use for You can sort the records and store clustered index physically in memory as per the order. A non-clustered index helps you to creates a logical order for data rows and uses pointers for physical data files.
Storing method Allows you to stores data pages in the leaf nodes of the index. This indexing method never stores data pages in the leaf nodes of the index.
Size The size of the clustered index is quite large. The size of the non-clustered index is small compared to the clustered index.
Data accessing Faster Slower compared to the clustered index
Additional disk space Not Required Required to store the index separately
Type of key By Default Primary Keys Of The Table is a Clustered Index. It can be used with unique constraint on the table which acts as a composite key.
Main feature A clustered index can improve the performance of data retrieval. It should be created on columns which are used in joins.
@SBajonczak
SBajonczak / MyConfig.json
Last active December 22, 2021 10:00
OhMyPosh Configuration
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"console_title_template": "{{.Folder}}{{if .Root}} :: root{{end}} :: {{.Shell}}",
"tooltips": [
{
"type": "git",
"tips": [
"git",
"gi",
@SBajonczak
SBajonczak / Sensor.txt
Last active December 20, 2021 14:08
MailboxSensor Actions
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);
@SBajonczak
SBajonczak / gist:ec7a7dd1cbdc1fd2a546ed69d6257f39
Created December 19, 2021 19:19
GetRequest With HttpFactory
public class RequestTool
{
readonly readonly HttpClient client;
public DbRepo(HttpClient client)
{
this.client = client;
}
@SBajonczak
SBajonczak / StartupRetryPolcyPolly
Created December 19, 2021 19:10
Startup configuration with Polly and retry method
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 December 16, 2021 11:45
Create an index on an INDEX Filegroup
CREATE NONCLUSTERED INDEX [MyIndex] ON [dbo].[MyTable] ([Field]) INCLUDE ([Field2]) ON [INDEX]
@SBajonczak
SBajonczak / CreateTable.sql
Created December 16, 2021 10:02
CreateSqlTableOnPrimaryFilegroup
create table person
(
id bigint,
name varchar(500),
surname varchar(500)
)
on [PRIMARY]
@SBajonczak
SBajonczak / Fragmentation.sql
Created December 15, 2021 11:35
Insights of Index Fragmentation
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