Skip to content

Instantly share code, notes, and snippets.

@osya
osya / smb.conf
Last active October 4, 2015 13:08
smb.conf
# 1st variant of [global] section
[global]
server string = %h server (Samba, Ubuntu)
client schannel = Yes
server schannel = Yes
map to guest = Bad User
obey pam restrictions = Yes
passdb backend = tdbsam
pam password change = Yes
passwd program = /usr/bin/passwd %u
@osya
osya / properties_vba.vba
Last active August 29, 2015 14:26
Properties in VBA #Excel #MIS #VBA
Private m_dMax# 'верхняя граница интервала
Public Property Get max() As Double
max = m_dMax
End Property
Public Property Let max(value#)
m_dMax = value
End Property
@osya
osya / sql_statistics.sql
Last active August 29, 2015 14:25
Working with SQL Server Statistics #SQL
-- Просмотреть свойства статистики
SELECT s.*
FROM sys.stats s
JOIN sys.objects o ON s.[object_id] = o.[object_id]
WHERE o.is_ms_shipped = 0
-- Скрипт по автоматическому обновлению устаревшей статистики
-- Критерий устаревания статистики в каждой конкретной ситуации может быть свой. В данном примере — 1 день
DECLARE @DateNow DATETIME
SELECT @DateNow = DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
@osya
osya / gist:00e3f332ce8f242a565d
Last active November 26, 2015 07:23
LINQ SQL-like Syntax Examples #CSharp
var query = from с шт context.Customers where c.CustomerId == 1 select c;
/*Example of INNER JOIN in LINQ SQL-like syntax*/
var transactions = from с in сcontext.Customers
join o in Context.Orders on c.CustomerId equals o.CustomerId
join op in Context.OrderProducts on o.OrderId equals op.OrderId
join p in Context.Products on op.ProductId equals p.ProductId
select new
{
CustomerName = c.CustomerName,
@osya
osya / gist:b0817f05cb5cbb0757a9
Last active August 29, 2015 14:24
Подсчет количества подчиненных узлов 1-го уровня в дереве #SQL
UPDATE [mis-dm].[DM].[D_TERRITORY]
SET ChildrenCount = (SELECT COUNT(t2.TERRITORY_ID) ChildrenCount
FROM DM.D_TERRITORY t1
LEFT JOIN DM.D_TERRITORY t2 ON t2.PARENT_ID = t1.TERRITORY_ID
WHERE t1.TERRITORY_ID = [mis-dm].[DM].[D_TERRITORY].TERRITORY_ID
GROUP BY t1.TERRITORY_ID
)
@osya
osya / gist:4cbb66b49760fbe8bbf8
Last active November 26, 2015 07:23
WinForms File Open Dialog #CSharp
public void butSelectFile_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Текстовые файлы|*.txt|Все файлы|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
fldFilePath.Text = dlg.FileName;
if (FileOpenClick != null) FileOpenClick(this, EventArgs.Empty);
@osya
osya / gist:5f5bd696f3d1a7e5b76a
Last active December 16, 2015 06:52
Singleton pattern in C# #CSharp
public class Singleton
{
private static Singleton _singleton;
static Singleton()
{
_singleton = new Singleton();
}
private Singleton()
@osya
osya / gist:1e8cc0063ee9a75def65
Last active November 26, 2015 07:24
Доработка NTS, чтобы он делал UNION для невалидных полигонов #CSharp
using System;
using GeoAPI.Geometries;
using NetTopologySuite.Geometries;
using NetTopologySuite.Simplify;
namespace NetTopologySuite.Operation.Overlay.Snap
{
/// <summary>
/// Performs an overlay operation using snapping and enhanced precision
/// to improve the robustness of the result.
@osya
osya / gist:251ee7c5d1e696d5f2aa
Last active March 1, 2023 19:40
Using the NetTopologySuite (NTS) to read and write Shapefiles in C# #CSharp
using GisSharpBlog.NetTopologySuite.Features;
using GisSharpBlog.NetTopologySuite.Geometries;
using GisSharpBlog.NetTopologySuite.IO;
using GeoAPI.Geometries;
...etc....
@osya
osya / gist:7884ccd1e7d72622850b
Last active November 26, 2015 07:25
Composition & Aggregation #CSharp
class CompositeCustomService
{
// Композиция
private readonly CustomRepository _repository
= new CustomRepository();
public void DoSomething()
{
// Используем _repository
}
}