Skip to content

Instantly share code, notes, and snippets.

View ayseff's full-sized avatar
🎯
Focusing

Avraham Seff ayseff

🎯
Focusing
  • Greater New York City Area
View GitHub Profile
@paggiogriot
paggiogriot / app.config
Created June 6, 2016 16:01 — forked from grenade/app.config
Emit log4net entries to logstash over UDP in near-realtime
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<log4net>
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
@paggiogriot
paggiogriot / gist:87036a128c60a8bb4c94fc66e80c1e9e
Created May 25, 2016 01:11
How do you perform a left outer join using linq extension methods
var qry = Foo.GroupJoin(
Bar,
foo => foo.Foo_Id,
bar => bar.Foo_Id,
(x,y) => new { Foo = x, Bars = y })
.SelectMany(
x => x.Bars.DefaultIfEmpty(),
(x,y) => new { Foo=x.Foo, Bar=y});
@paggiogriot
paggiogriot / gist:c9504226a6b157380909
Created July 19, 2015 16:35
Passing Javascript array to ASP.NET MVC Controller
You can try json.net library to solve your issue
[JsonFilter(Param = "attributes", JsonDataType = typeof(AttributeViewModel[]))]
public JsonResult Save(AttributeViewModel[] attributes)
At client:
$.ajax({
type: 'POST',
url: url,
async: true,
@dlwyatt
dlwyatt / Oops.ps1
Last active September 26, 2016 18:38
Flags Enum without explicit values
# Add an enum with All constant
Add-Type -TypeDefinition @'
using System;
[Flags]
public enum EnumSample
{
One,
Two,
Three,
@dlwyatt
dlwyatt / Test-Flags.ps1
Last active September 26, 2016 18:38
Flags Enum parameter demo
Add-Type -TypeDefinition @'
using System;
[Flags]
public enum MyEnum
{
Option1 = 0x1,
Option2 = 0x2,
Option3 = 0x4,
All = Option1 | Option2 | Option3
@dlwyatt
dlwyatt / SetupComplete.cmd
Last active September 26, 2016 18:38
Vagrant base box with Sysprep
@powershell.exe -NonInteractive -ExecutionPolicy Bypass -NoProfile -File "%~dp0\SetupComplete.ps1"
@dlwyatt
dlwyatt / ParseIt.ps1
Created May 7, 2015 00:21
Parse CSVDE-style SID string
$funky = '010500000000000515000000AA7045F3F11474788C4A5F8AE9030000'
try
{
$bytes = [byte[]]@(
for ($i = 0; $i -lt $funky.Length - 1; $i += 2)
{
[byte]::Parse($funky.Substring($i, 2), [System.Globalization.NumberStyles]::AllowHexSpecifier)
}
)
@dlwyatt
dlwyatt / ConvertTo-Hashtable.ps1
Created March 5, 2015 14:40
ConvertTo-Hashtable
function ConvertTo-Hashtable
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[psobject[]] $InputObject
)
process
{
@dlwyatt
dlwyatt / example.Tests.ps1
Created February 14, 2015 13:25
Pester Example
# Import the stuff you'll be testing. Could be dot-sourcing a ps1 file here, importing a module, whatever you need.
# If importing a mdoule, make sure you've only got one copy of it imported, or weird things can happen when you start
# to get into mocking.
Remove-Module [S]omeDscResource
Import-Module $PSScriptRoot\SomeDscResource.psm1
# All of the Pester tests in a script must go inside a Describe block; you can mave many Describe blocks in the same
# script, if you like. Make sure to put the opening brace on the same line as Describe, since this is just a function
# pretending to be a keyword; no assistance from the parser allowing us to put opening braces on their own lines.
@CADbloke
CADbloke / WindowsFormToXaml.cs
Created January 21, 2015 02:36
Windows Forms to XAML Converter
// based on http://robrelyea.wordpress.com/2007/02/10/winforms-xaml/
// converted to an Extension Method by @CADbloke
// a list: http://msdn.microsoft.com/en-us/library/ms750559(v=vs.110).aspx
// here's moar code:http://wf2wpf.codeplex.com/SourceControl/latest but it converts source files, not actual controls.
// Here's a site that does code too http://www.win2wpf.com/
// http://www.codeproject.com/Articles/25795/Creating-the-Same-Program-in-Windows-Forms-and-WPF
// ReSharper disable SpecifyACultureInStringConversionExplicitly
using System;