Skip to content

Instantly share code, notes, and snippets.

@domgreen
domgreen / gist:942168
Created April 26, 2011 12:26
tokenised scenario for automating deployment to Windows Azure in MSBuild
<Target Name="CloudDeploy" DependsOnTargets="CorePublish" Condition=" '$(DeployType)' == 'Cloud' ">
<Exec Command="$(PackageUploader) $(cspkgFile) $(AccountConnectionString)"/>
<Exec Command="$(SuspendCommand)" ContinueOnError="true"/>
<Exec Command="$(DeleteCommand)" ContinueOnError="true"/>
<Exec Command="$(CreateCommand)" ContinueOnError="true"/>
<Exec Command="$(RunCommand)" ContinueOnError="true"/>
</Target>
@gatapia
gatapia / sqlappender.sql
Created May 10, 2011 20:57
A better, faster SQL Server and Azure log appender for log4net
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using log4net.Appender;
using log4net.Core;
using log4net.Layout;
@postmodern
postmodern / comment.md
Last active January 11, 2024 15:37
Crypto Privacy Copy Pasta
@matejskubic
matejskubic / sql-restore-pregress.sql
Created May 17, 2013 12:41
SQL Server backup/restore progress
SELECT r.session_id,r.command,CONVERT(NUMERIC(6,2),r.percent_complete)
AS [Percent Complete],CONVERT(VARCHAR(20),DATEADD(ms,r.estimated_completion_time,GetDate()),20) AS [ETA Completion Time],
CONVERT(NUMERIC(10,2),r.total_elapsed_time/1000.0/60.0) AS [Elapsed Min],
CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0) AS [ETA Min],
CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0/60.0) AS [ETA Hours],
CONVERT(VARCHAR(1000),(SELECT SUBSTRING(text,r.statement_start_offset/2,
CASE WHEN r.statement_end_offset = -1 THEN 1000 ELSE (r.statement_end_offset-r.statement_start_offset)/2 END)
FROM sys.dm_exec_sql_text(sql_handle)))
FROM sys.dm_exec_requests r WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE')
@guitarrapc
guitarrapc / WindowsCredentialVault.psm1
Last active January 15, 2021 18:49
PowerShell Windows Credential Vault Module
function InitializeWindowsCredential
{
Write-Verbose ("Loading PasswordVault Class.")
[void][Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]
}
InitializeWindowsCredential
function ConvertTo-PasswordCredential
{
@JamesRandall
JamesRandall / RedirectNewtonsoftJson.ps1
Last active May 2, 2023 13:39
Powershell binding redirection
# Load your target version of the assembly
$newtonsoft = [System.Reflection.Assembly]::LoadFrom("$PSScriptRoot\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll")
$onAssemblyResolveEventHandler = [System.ResolveEventHandler] {
param($sender, $e)
# You can make this condition more or less version specific as suits your requirements
if ($e.Name.StartsWith("Newtonsoft.Json")) {
return $newtonsoft
}
foreach($assembly in [System.AppDomain]::CurrentDomain.GetAssemblies()) {
if ($assembly.FullName -eq $e.Name) {
@dotMorten
dotMorten / MSBuildCheatSheet.xml
Last active November 14, 2024 11:47
MSBuild Cheat Sheet
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
How to define a variable.
Just stick a new node in a property group.
-->
<PropertyGroup>
<!-- This node in a property group will define a variable -->
<TestVariable>Test Variable Value</TestVariable>
@rameerez
rameerez / telegram-mtproxy.md
Last active November 1, 2024 07:00
Telegram Proxy How-To: complete and up-to-date MTProxy tutorial

How to set up a Telegram Proxy (MTProxy)

This tutorial will teach you how to set up a Telegram MTProxy on an Ubuntu 22.04 sever using AWS Lightsail, although you can use any other Linux distribution and cloud provider.

Using a Telegram proxy is a safe, easy and effective way of overcoming Telegram bans. It's useful, for example, to keep using Telegram under tyrannical regimes, or to circumvent judges' decisions to block Telegram.

Telegram proxies are a built-in feature in all Telegram apps (both mobile and desktop). It allows Telegram users to connect to a proxy in just one or two clicks / taps.

Telegram proxies are safe: Telegram sends messages using their own MTProto secure protocol, and the proxy can only see encrypted traffic – there's no way for a proxy to decrypt the traffic and read the messages. The proxy does not even know which Telegram users are using the proxy, all the proxy sees is just a list of IPs.

@matejskubic
matejskubic / APIM-policy-fragment.xml
Created June 4, 2024 14:08
Get Logic App Standard workflow trigger url
<fragment>
<choose>
<when condition="@(null != context.Variables.GetValueOrDefault<string>("LaWfName", null))">
<cache-lookup-value key="@(context.Variables.GetValueOrDefault<string>("LaWfName", null))" variable-name="LAWfTriggerUri" caching-type="internal" />
<choose>
<when condition="@(string.IsNullOrEmpty(context.Variables.GetValueOrDefault<string>("LAWfTriggerUri", null)))">
<send-request mode="new" timeout="20" ignore-error="false" response-variable-name="LAWfTriggerResponse">
<set-url>@{
var laName = context.Variables.GetValueOrDefault<string>("LaName", null);
var laWfName = context.Variables.GetValueOrDefault<string>("LaWfName", null);