Skip to content

Instantly share code, notes, and snippets.

using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
public static class StreamUtil
{
public static async Task<byte[]> ReadAsync(this Stream stream,
int length, CancellationToken cancellationToken)
{
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
public static class ZipUtil
{
public static byte[] Compress(this Dictionary<string, byte[]> entries)
{
using (var stream = new MemoryStream())
{
#include <iostream>
#include <math.h>
using namespace std;
int StartingAt(int n);
int main()
{
cout << StartingAt(1);
using System;
using System.IO.Pipes;
using System.IO;
using System.Threading;
using System.Text;
using Microsoft.Win32.SafeHandles;
class Program
{
static PipeStream stream;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Linq;
static class Program
{
static void Main(string[] args)
@yutopio
yutopio / Location.cs
Created May 12, 2015 05:42
Google Maps Polyline encoder / decoder.
using System;
public partial struct Location
{
public static readonly Location Empty;
static Location()
{
Empty = new Location { Latitude = 0, Longitude = 0 };
}
@yutopio
yutopio / SetACL.cs
Last active July 17, 2019 09:32
Adding ACL for directory full access. (SQL Server on Azure VM can have tempdb on D Drive for performance. Allow MSSQLSERVER for full control in such case)
// See this article for the background.
// http://blogs.technet.com/b/dataplatforminsider/archive/2014/09/25/using-ssds-in-azure-vms-to-store-sql-server-tempdb-and-buffer-pool-extensions.aspx
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
using System.Security.Principal;
using System.ServiceProcess;
@yutopio
yutopio / home.html.erb
Last active August 29, 2015 14:19
Shell injection test. DO NOT DEPLOY outside the testing environment.
<h1>Exec</h1>
<%= form_tag(command_exec_url) do %>
<div class="actions">
<%= text_area_tag(:stdin, "", size: "50x20") %>
</div>
<%= submit_tag("Execute") %>
<% end %>
@yutopio
yutopio / Aes.cs
Last active August 29, 2015 14:14
AES Cryptography Sample
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
class Program
{
static void Main(string[] args)
{
string iv, key;
@yutopio
yutopio / FileHash.cs
Last active August 29, 2015 14:13
Obtain MD5 file hash for all files in subdirectories in a specified path.
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
static class Program
{
static MD5 md5;
static MemoryStream ms;
static StreamWriter sw;