Skip to content

Instantly share code, notes, and snippets.

View searope's full-sized avatar

Sea Rope searope

View GitHub Profile
Pushd C:\git\folder\to\copy
set share=\\path\to\a\share
del /s /f /q %share%\*.*
for /f %%f in ('dir /ad /b %share%\') do rd /s /q %share%\%%f
for /f "usebackq tokens=*" %%A in (`git ls-files --modified --others --exclude-standard`) do echo FA|xcopy "%%~fA" "%share%\%%A"
using System.Collections.Generic;
public class SortComparer<T, R> : Comparer<T> where R : IComparable<R>
{
public readonly Func<T, R> GetComparableProperty;
private SortComparer(){}
private SortComparer(Func<T, R> func)
{
GetComparableProperty = func;
$TotalNumberVersionsToKeep=100
$BackupFolder = "\\osgdesign\Studio\Windows\Users\v-senefe\Backup" # make sure there is no ending \
$ProjectFolder = "C:\DesignDepot.Git" # make sure there is no ending \
$ProjectFolderName = [System.IO.Path]::GetFileName($ProjectFolder)
Push-Location -Path $ProjectFolder
$changes = CMD.EXE /C git ls-files --modified --others --exclude-standard | Out-String
if ($changes.Length -eq 0){
Exit
}
@searope
searope / GetSidOfSecurityGroup.ps
Last active November 9, 2016 00:21
Get SID (security id) of a security group with PowerShell
(New-Object System.Security.Principal.NTAccount("Security Group Name")).Translate([System.Security.Principal.SecurityIdentifier]).Value
@searope
searope / gist:34e787b49683d9ee725a3f7c07f944c3
Created July 14, 2017 17:59 — forked from istepura/gist:9222616
Generating permutations of arr in lexicographic order in C#
public IEnumerable<int[]> Permut(int[] arr){
while (true){
yield return arr;
var j = arr.Length - 2;
while (j >= 0 && arr[j] >= arr[j+1]) j--;
if (j < 0) break;
var l = arr.Length -1;
while (arr[j] >= arr[l]) l--;
@searope
searope / gist:cb6742acaa0b17a844f00d208f4071e7
Created July 14, 2017 17:59 — forked from istepura/gist:9222616
Generating permutations of arr in lexicographic order in C#
public IEnumerable<int[]> Permut(int[] arr){
while (true){
yield return arr;
var j = arr.Length - 2;
while (j >= 0 && arr[j] >= arr[j+1]) j--;
if (j < 0) break;
var l = arr.Length -1;
while (arr[j] >= arr[l]) l--;
@searope
searope / matplotlib.pyplot.py
Created June 25, 2019 15:42
matplotlib.pyplot tips and tricks
import matplotlib.pyplot as plt
fig, (ax1, ax2, ax3) = plt.subplots(ncols=3, figsize=(9, 5))
ax1.set_title('Before Scaling')
sns.kdeplot(x['x1'], ax=ax1)
sns.kdeplot(x['x2'], ax=ax1)
ax2.set_title('After Robust Scaling')
sns.kdeplot(robust_scaled_df['x1'], ax=ax2)
sns.kdeplot(robust_scaled_df['x2'], ax=ax2)
ax3.set_title('After Min-Max Scaling')
@searope
searope / Helper.cs
Created December 18, 2019 20:20
Finds file or folder in parents folder
public static string FindUpperFileOrFolder(string name, DirectoryInfo dir = null)
{
dir = dir ?? new DirectoryInfo(Directory.GetCurrentDirectory());
var dirInfo = dir.GetDirectories(name).FirstOrDefault();
var fileInfo = dir.GetFiles(name).FirstOrDefault();
if (fileInfo == null && dirInfo == null)
{
return FindUpperFileOrFolder(name, dir.Parent);
}
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Extensions
{
public static class Extensions
{
static void PrintTypes(LambdaExpression expr)
{
Console.WriteLine(expr);
ConstantExpression cexpr = expr.Body as ConstantExpression;
if (cexpr != null)
{
Console.WriteLine("\t{0}", cexpr.Type);
return;
}
BinaryExpression bexpr = expr.Body as BinaryExpression;