Skip to content

Instantly share code, notes, and snippets.

  1. Install the Proxy Server package. Just go to Package Manager in DSM and install Proxy Server.

  2. Edit squid.conf to tell it about your ad file. Ssh to the box, and edit the file /var/packages/ProxyServer/target/squid/etc/squid.conf (vi is installed by default)

You're going to add 2 lines to this file. First, under the auth_param section, you're going to add:

acl ads dstdom_regex -i "/var/packages/ProxyServer/target/squid/etc/squid.adservers"
@nkundu
nkundu / touch.bat
Created February 19, 2018 18:38 — forked from tjbarbour/touch.bat
touch.bat Works like bash "touch" command that just updates a file's date modified time. Taken from: http://stackoverflow.com/a/923927/37207 and http://stackoverflow.com/a/659672/37207
@echo OFF
REM Need to be in current directory to touch file
pushd %~dp1
copy /b %1 +,,
popd
@nkundu
nkundu / script.ps1
Created October 20, 2017 21:13
Recursively find large files
Get-ChildItem -Path . -Filter *.whatev -Recurse | Where-Object {$_.length/1MB -gt 50} | select fullname,@{n=”Size MB”;e={$_.length/1GB}}
@nkundu
nkundu / install vnc.sh
Created August 13, 2017 13:41
Raspberry Pi Install vncserver
apt-get install vnc4server
~/.vnc/xstartup
@nkundu
nkundu / ExcelQuery.cs
Created June 5, 2017 18:13
Query a Excel File
string connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Extended Properties=\"Excel 8.0;IMEX=1\"", fullfilename);
DataSet ds = new DataSet();
using (OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString))
{
adapter.Fill(ds, "contactRecords");
}
@nkundu
nkundu / ProjectInstaller.cs
Last active June 5, 2017 15:41
Windows Service Installer
// Install: C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe xxx.exe
// Uninstall: C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /u xxx.exe
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Configuration.Install;
using System.Linq;
using (var conn = new System.Data.SqlClient.SqlConnection(connStr))
{
if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
var tran = conn.BeginTransaction();
try
{
using (var cmd = conn.CreateCommand())
{
cmd.Transaction = tran;
create table #tmpSpWho2 (
SPID bigint
, [Status] nvarchar(100)
, [Login] nvarchar(100)
, HostName nvarchar(100)
, BlkBy nvarchar(100)
, DBName nvarchar(100)
, Command nvarchar(100)
, CPUTime bigint
, DiskIO bigint
@nkundu
nkundu / TVP.cs
Created May 4, 2017 14:50
Stream records to a TVP
/*****
CREATE TYPE [dbo].[BigintCollection] AS TABLE(
[Value] [bigint] NOT NULL,
PRIMARY KEY CLUSTERED
(
[Value] ASC
)WITH (IGNORE_DUP_KEY = OFF)
)
@nkundu
nkundu / XML.cs
Created May 4, 2017 13:32
XML Document to string
public static string XmlToString(XmlDocument xmlDoc)
{
using (var stringWriter = new StringWriter())
{
using (var xmlTextWriter = XmlWriter.Create(stringWriter))
{
xmlDoc.WriteTo(xmlTextWriter);
xmlTextWriter.Flush();
return stringWriter.GetStringBuilder().ToString();
}