Skip to content

Instantly share code, notes, and snippets.

@arijusg
arijusg / Instructions
Created June 6, 2014 14:28
Control Windows services from an ASP.Net WebApp
Assuming your services are already installed...
First you will need SubInACL (SubInACL.exe)
SubInACL is a command-line tool that enables administrators to obtain security information about files, registry keys, and services, and transfer this information from user to user, from local or global group to group, and from domain to domain.
http://www.microsoft.com/en-us/download/details.aspx?id=23510
Second you will need to run a batch or commands manualy to give Start/Stop rights ("T and O").
Third. Publish your app and test it.
@arijusg
arijusg / gist:b54e22cf0689197dbe9e
Created June 23, 2014 13:42
DataTable convert into Csv and push to the browser
public class DataTableToCsv
{
public void Generate(DataTable dt, string fileName)
{
var sb = new StringBuilder();
IEnumerable<string> columnNames = dt.Columns.Cast<DataColumn>().
Select(column => column.ColumnName);
sb.AppendLine(string.Join(",", columnNames));
USE RedFoxAuto
DECLARE @PricelistID varchar(50), @lName varchar(50)
DECLARE cursorName CURSOR LOCAL SCROLL STATIC FOR
SELECT pricelistID, pricelistName FROM productPricelistNames
OPEN cursorName -- open the cursor
FETCH NEXT FROM cursorName INTO @PricelistID, @lName
WHILE @@FETCH_STATUS = 0
<asp:TemplateField HeaderText="More =>">
<ItemTemplate>
<asp:ImageButton ID="imgBtnExpand" runat="server" CommandName="Expand"
CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' ImageUrl="~/images/expand_button.png" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
</td></tr>
@arijusg
arijusg / SP_WHO2
Created May 21, 2015 07:47
Running SQL Queries
CREATE TABLE #sp_who2 (SPID INT,Status VARCHAR(255),
Login VARCHAR(255),HostName VARCHAR(255),
BlkBy VARCHAR(255),DBName VARCHAR(255),
Command VARCHAR(255),CPUTime INT,
DiskIO INT,LastBatch VARCHAR(255),
ProgramName VARCHAR(255),SPID2 INT,
REQUESTID INT)
INSERT INTO #sp_who2 EXEC sp_who2
SELECT *
FROM #sp_who2
@arijusg
arijusg / SqlIndexesMaintenance.sql
Created March 23, 2016 11:45
SqlI Indexes Maintenance
-- Ensure a USE <databasename> statement has been executed first.
USE <databasename>
SET NOCOUNT ON
-- adapted from "Rebuild or reorganize indexes (with configuration)" from MSDN Books Online
-- (http://msdn.microsoft.com/en-us/library/ms188917.aspx)
-- =======================================================
USE [master]
GO
/****** Object: StoredProcedure [dbo].[sp_who3] Script Date: 23/03/2016 12:09:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_who3]
(
@filter tinyint = 1,
@arijusg
arijusg / gist:32880f176b4985adc94a
Created March 23, 2016 16:19
ChangeAndNotify WPF extention
public static class ChangeAndNotifyExtention
{
public static bool ChangeAndNotify<T>(this PropertyChangedEventHandler handler,
ref T field, T value, Expression<Func<T>> memberExpression)
{
if (memberExpression == null)
{
throw new ArgumentNullException("memberExpression");
}
var body = memberExpression.Body as MemberExpression;
@arijusg
arijusg / package.json
Created June 1, 2017 07:48
Pre commit hook - the right way
{
"name": "app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-prod": "rm -rf dist && ng build --prod --output-hashing none --vendor-chunk true --extract-css false",
"test": "ng test --single-run",
@arijusg
arijusg / gist:6197e3df0e0f1b349c3bab2be7f43e04
Last active June 1, 2017 21:07
Windows 10 bash colours
cd ~
nano ~/.bashrc
paste this at bottom of file
```
LS_COLORS=$LS_COLORS:'rs=0:di=1;35:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=0