Skip to content

Instantly share code, notes, and snippets.

#install chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
#generate list of installed applications with exact version
choco list -lo -r -y | % { "choco install " + $_.Replace("|", " ") + " -y" }
#generate list of installed application without version.
choco list -lo --id-only -y | % { "choco install " + $_.Replace("|", " ") + " -y" }
@drasticactions
drasticactions / jsonnet.workbook
Created March 16, 2017 17:13
JSON.NET Deserialize Example
uti platforms packages
com.xamarin.workbook
Console
id version
Newtonsoft.Json
9.0.1

JSON.NET Deserialize Example

@kiquenet
kiquenet / gist:4964f650fe70c3180ea6
Created November 19, 2015 08:39
SSRS analytics Queries
Use ReportServer
go
/* Performance Tips
1. High TimeDataRetriveal
* Removed unused datasets
* Analyze the dataset query in SQL Profiler
* Combine Datasets where possible
2. High TimeProcessing
* Use less report parts (tables, charts...)
* Do Grouping and Sorting on the SQL Side
@tcaddy
tcaddy / check_student_planning.js
Last active March 16, 2018 08:14
A PhantomJS script to monitor Ellucian Student Planning / Self-Service for unresponsiveness. A PowerShell script to run the PhantomJS script and recycle the app pool, send an email.
/*
Student Planning goes down randomly and we have to recycle the app pool to fix it.
This script will try to login to Student Planning and make an AJAX request. It will
return text output (console.log() output) about whether it is working or not.
NOTE: this script relies on PhatomJS, which you can download here:
http://phantomjs.org/download.html
NOTE: change the values of the host, user, and pass variables. Optionally change the timeout variable.
*/
#Requires -RunAsAdministrator
#Requires -Version 3.0
#References:
#Getting Started with Nano Server <https://technet.microsoft.com/en-us/library/mt126167.aspx>
#Quick Guide - Deploying Nano Server using PowerShell <http://deploymentresearch.com/Research/Post/479/Quick-Guide-Deploying-Nano-Server-using-PowerShell>
param (
#[ValidateScript({ Test-Path $_ })]
$ConvertWindowsImageScriptPath = 'D:\work\NanoServerSetup\Convert-WindowsImage.ps1'
@hongymagic
hongymagic / Interval.cs
Last active December 15, 2023 13:09
Representing Intervals in C# with Generics support `Interval<T>`
using System;
namespace Hongy
{
/// <summary>
/// Represents vectorless interval of the form [a, b] or (a, b) or any
/// combination of exclusive and inclusive end points.
/// </summary>
/// <typeparam name="T">Any comparent type</typeparam>
/// <remarks>
@haeky
haeky / encryption.cs
Created June 17, 2013 14:34
Encrypt, decrypt and generate a key in C# using AES256.
#region Encryption
/// <summary>
/// Generate a private key
/// From : www.chapleau.info/blog/2011/01/06/usingsimplestringkeywithaes256encryptioninc.html
/// </summary>
private static string GenerateKey(int iKeySize)
{
RijndaelManaged aesEncryption = new RijndaelManaged();
aesEncryption.KeySize = iKeySize;
aesEncryption.BlockSize = 128;
@haf
haf / gist:5629584
Last active January 23, 2019 20:59
Finding the private key of a Windows certificate from PowerShell/C#.
namespace PKI
{
class Results : IEquatable<Results>
{
internal static readonly Results NotFound = new Results
{
Directory = "",
KeyName = ""
};
@craigrbruce
craigrbruce / ApiClient.cs
Last active April 26, 2022 23:06
An example REST API client for C#
/*
Call the api client like this:
var client = new ApiClient<SEnvelope>("https://baseurl.com/api/v1");
//you would overload and add an auth_token param here
client.GetDtoAsync("envelopes", "object_id", (response) => //callback
{
this.SEnvelope = response.Data;//should be an envelope from the server
});
@haacked
haacked / FormatAllFiles.ps1
Created May 21, 2011 08:06
Format all CS files in a Visual Studio solution (UGLY VERSION)
// Open up the NuGet Package Manager in Visual Studio and paste the following line to format every file in the solution.
// I'll write a not-so-ugly version later. ;)
// BUG! This doesn't recursively grab all files from the project. :(
$dte.Solution.Projects | ForEach-Object {$_.ProjectItems | ForEach-Object { if ($_.Name.EndsWith('.cs')) {$window = $_.Open('{7651A701-06E5-11D1-8EBD-00A0C90F26EA}'); if ($window){Write-Host $_.Name;[System.Threading.Thread]::Sleep(100);$window.Activate();$_.Document.DTE.ExecuteCommand('Edit.FormatDocument');$_.Document.DTE.ExecuteCommand('Edit.RemoveAndSort');$window.Close(1);}} }}