Skip to content

Instantly share code, notes, and snippets.

View Elnee's full-sized avatar
🍊
Have a nice day

Dmitry Elnee

🍊
Have a nice day
  • Dnipro (Ukraine)
View GitHub Profile
@Elnee
Elnee / query_history.sql
Created January 11, 2020 11:15
Query history for MS SQL
SELECT deqs.last_execution_time, dest.text
FROM sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
WHERE dest.text LIKE N'%<table_name>%'
AND deqs.last_execution_time >= '2020-01-01 00:00:00.000'
ORDER BY deqs.last_execution_time DESC
@Elnee
Elnee / circular_buffer.h
Created October 8, 2019 11:24
C++ circural buffer
#pragma once
#include <QObject>
#include <memory>
template <class T>
class circular_buffer
{
public:
explicit circular_buffer(size_t size)
@Elnee
Elnee / convert_cpp_h_to_utf8.ps1
Created July 30, 2019 12:38
PowerShell script for convert all cpp and h files in your folder to utf8
Set-Location -Path D:\Projects\SomeProject # Path to your sources
foreach ($file in Get-ChildItem)
{
if ($file -like "*.cpp" -or $file -like "*.h") {
Write-Host "Processing " -ForegroundColor Red -NoNewline
Write-Host $file
Set-Content -Encoding UTF8 -Path $file -Value (Get-Content $file)
}
}
Write-Host "All files has been recoded" -ForegroundColor Green
// LINK TO EXERCISE: https://www.hackerrank.com/challenges/2d-array/problem
#include <bits/stdc++.h>
using namespace std;
// Complete the hourglassSum function below.
int hourglassSum(vector<vector<int>> arr) {
if (arr.size() < 3 || arr[0].size() < 3) return 0;
@Elnee
Elnee / singleton.cxx
Created June 22, 2019 06:16
Simple C++ singleton
#include <iostream>
using namespace std;
class Singleton {
public:
static Singleton& instance();
int increment() { return ++x; }
private:
Singleton() = default;
@Elnee
Elnee / pnetx.py
Last active March 21, 2019 08:32
Проверка счёта PeopleNet Украина и вывод уведомления в GNOME
from bs4 import BeautifulSoup
import requests
import re
import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify
Notify.init('PeopleNet Account')
params = {'X_Username': 'your_username', 'X_Password': 'your_password'}
@Elnee
Elnee / printer.js
Last active May 21, 2018 17:27
JavaScript OOP
class Printer {
constructor(label = "Unknown", pageSize = "A4", amountOfDye = 100, amountOfPaper = 50, powerState = "off") {
this.label = label;
this.pageSize = pageSize;
this.amountOfDye = amountOfDye;
this.amountOfPaper = amountOfPaper;
this.powerState = powerState;
}
addPaper(amount) {
this.amountOfPaper += amount;