Skip to content

Instantly share code, notes, and snippets.

Ian Davis idavis

Block or report user

Report or block idavis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@idavis
idavis / Jagged
Last active Jan 9, 2018
Matrix Multiplication Benchmarks
View Jagged
namespace MatrixMultiplication
{
public static class Jagged
{
public static double[][] Multiply( int N )
{
var C = new double[N][];
var A = new double[N][];
var B = new double[N][];
Util.Initialize( N, A, B, C );
@idavis
idavis / gist:ca8f67b1c1ab2f5d6fe7ab6f889a314a
Created Jul 30, 2016
Crypto Errors with .NET Command Line Tools for OS X
View gist:ca8f67b1c1ab2f5d6fe7ab6f889a314a
idavis$ brew link openssl --force
Warning: Refusing to link: openssl
Linking keg-only OpenSSL means you may end up linking against the insecure,
deprecated system version while using the headers from the Homebrew version.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
=============================================================================
=============================================================================
@idavis
idavis / ReShape.ps1
Last active May 21, 2016
Implementing APL shape/rank (⍴/⍴⍴) functions in PowerShell. This is a rough first cut.
View ReShape.ps1
# APL Rank
filter ⍴⍴ {
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$false)]
)
process {
if( -is [system.array]){
.rank
} else{
""
@idavis
idavis / gist:c16f117c0f99eb20c49f
Created Jun 12, 2015
PowerShell Module Security
View gist:c16f117c0f99eb20c49f

I was playing around with dynamic module creation and figured out how to monkey patch modules.

I then thought about how PowerShell is a Last-In-Wins language, and tried replacing private methods.

This led to the "what if" moment of pulling [secure data out of a loaded module][]. In this case, the username and password of a credential set.

This seems like a security issue to me, or am I being over sensitive?

@idavis
idavis / Monkey.psd1
Last active Aug 29, 2015
Stealing Private Data
View Monkey.psd1
@{
# Script module or binary module file associated with this manifest.
RootModule = 'Monkey.psm1'
# Version number of this module.
ModuleVersion = '1.0'
# ID used to uniquely identify this module
GUID = '4d4390dc-a8ad-4bce-8d69-f53ccf8e4163'
@idavis
idavis / gist:293022f2ebe30f726673
Created Jun 9, 2015
Replacing the private functionality of loaded module
View gist:293022f2ebe30f726673
$module = New-Module -Name "monkey" -ScriptBlock {
function Get-Stuff {
return GetStuffPrivate
}
function GetStuffPrivate {
5
}
Export-ModuleMember Get-Stuff
}
Import-Module $module # you can also just use $module = Get-Module "someName"
View Project.Euler.Problem.8.ps1
function Split-Number {
param([string]$value)
$index = 0
while($index -lt $value.Length - 12) {
$value.Substring($index++, 13)
}
}
filter Evaluate-String {
$_.ToCharArray() | % { [int]::Parse($_) } | % {$total = 1} {$total *= $_} {$total}
View FusionLog.ps1
function Enable-FusionLog {
param($logPath = "C:\Temp\Fusion")
if(!(Test-Path $logPath)) {
New-Item -ItemType Directory -Path $logPath
}
$fusionRoot = "HKLM:Software\Microsoft\Fusion"
function Set-FusionKey($name, $value, $type) {
if(!(Test-Path (Join-Path $fusionRoot $name))) {
(New-ItemProperty $fusionRoot -name $name -propertyType $type -ErrorAction Stop) | Out-Null
@idavis
idavis / gist:4192723
Created Dec 3, 2012
Fresh clone of FubuMvc, trying to build
View gist:4192723
> git clone git@github.com:idavis/fubumvc.git
Cloning into 'fubumvc'...
remote: Counting objects: 57191, done.
remote: Compressing objects: 100% (11208/11208), done.
remote: Total 57191 (delta 45719), reused 56278 (delta 44979)
Receiving objects: 100% (57191/57191), 61.02 MiB | 327 KiB/s, done.
Resolving deltas: 100% (45719/45719), done.
> cd .\fubumvc
[master]> ls
@idavis
idavis / Fizz-Buzz.ps1
Created Nov 21, 2012
FizzBuzz with PowerShell
View Fizz-Buzz.ps1
filter Fizz-Buzz {
process {
$output = switch($_) {
{$_ % 3 -eq 0} {"Fizz"}
{$_ % 5 -eq 0} {"Buzz"}
default {$_}
}
$output -join ""
}
}
You can’t perform that action at this time.