Skip to content

Instantly share code, notes, and snippets.

View petarvucetin's full-sized avatar

Petar Vučetin petarvucetin

  • Clear Lines
  • Los Angeles
View GitHub Profile
@petarvucetin
petarvucetin / VisitorPattern.cs
Last active January 4, 2016 07:59
Using a visitor pattern to build a log message out of parameters passed to WCF.
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@petarvucetin
petarvucetin / PrivateReflectionDynamicObject.cs
Created May 12, 2014 17:11
Using dynamic to simplify reflection via David Ebb
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
namespace Core.Common
{
namespace AzManWrapperLib
{
using AZROLESLib;
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
public class AzManAccessControlChecker : IAccessControlChecker, IDisposable
{
#region Private Fields
using System;
using log4net;
using PostSharp.Laos;
// http://exceptionalcode.wordpress.com/2010/02/17/centralizing-vsto-add-in-exception-management-with-postsharp/
namespace Helpers.Vsto.ErrorHandling
{
[Serializable]
public sealed class ExecutionEntryPointAttribute : OnExceptionAspect
public class SelectionList<T> :
ObservableCollection<SelectionItem<T>> where T : IComparable<T>
{
public event EventHandler OnItemSelectionChange;
#region Properties
/// <summary>
/// Returns the selected items in the list
/// </summary>
@petarvucetin
petarvucetin / Validate-Credentials.ps1
Created April 2, 2015 16:02
PS: Validate-Credentials
function Validate-Credentials([System.Management.Automation.PSCredential]$credentials)
{
$ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$nc = $credentials.GetNetworkCredential()
$principal = $nc.Domain.ToString() + "\"+ $nc.UserName.Tostring()
$pctx = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($ct, "axaros.com")
return $pctx.ValidateCredentials($nc.UserName, $nc.Password)
}
@petarvucetin
petarvucetin / CrmEntityExtensions.cs
Created March 31, 2016 02:34
Useful extension methods for strongly typed access to CRM Entites
public static class CrmEntityExtensions
{
public static OptionSetValue ToOptionSetValue(this Enum e)
{
if (e.GetTypeCode() != TypeCode.Int32)
return null;
var val = (int)Convert.ChangeType(e, e.GetTypeCode());
return new OptionSetValue(val);
@petarvucetin
petarvucetin / MemberOf.cs
Created April 18, 2017 03:57
Using reflection to get property name expressed as lambda
using System;
using System.Linq.Expressions;
using System.Reflection;
namespace Infrastructure
{
/// <summary>
/// Class for easily getting information about a type member,
/// and referencing the member by name, or getting it as a
#Downloads latest paket.bootstrapper.exe from github
$urlbase = "https://github.com"
$latestPage="$urlbase/fsprojects/Paket/releases/latest"
$exe = "paket.bootstrapper.exe"
Write-Host "Parsing latest release page: $latestPage"
$urlRegex = '<a\s+(?:[^>]*?\s+)?href=(["''])(.*?)paket.bootstrapper.exe\1'
$wc=new-object net.webclient
@petarvucetin
petarvucetin / github_repo.py
Created June 8, 2019 18:22 — forked from toast38coza/github_repo.py
An Ansible module for managing github repos
#!/usr/bin/python
DOCUMENTATION = '''
---
module: github_repo
short_description: Manage your repos on Github
'''
EXAMPLES = '''
- name: Create a github Repo