Skip to content

Instantly share code, notes, and snippets.

View devlead's full-sized avatar

Mattias Karlsson devlead

View GitHub Profile
@devlead
devlead / HelloWorld.s
Created July 31, 2019 08:30
Amiga HelloWorld
ExecBase = 4 ;location of the exec.lib
OpenLib = -552 ;offset to the openLibrary function
OpenLibVersion = 34 ;minimum version to use
CloseLib = -414 ;offset to closeLibrary function
PutString = -948 ;offset to putStr() function
MOVE.L #OpenLibVersion,D0 ;place version of lib in data reg 0
LEA DosName,A1 ;place dos.lib name into add reg 1
MOVE.L ExecBase,A6 ;point to exec.lib's jump table
JSR OpenLib(A6) ;make the jump from exec.lib jump table
TST.L D0 ;check to see if D0 equals zero (fail)
@devlead
devlead / Async.cake
Created July 9, 2017 18:43
Sample of using async await in a cake script using a AsyncHelper class to work with all async scenarios, currently needs "--Experimental" flag or to use the Cake.CoreCLR runner as a newer version of Roslyn is required for async to be recognized. Example invocation: cake .\AsyncHelper.cake -Experimental
#load "AsyncHelper.cake"
#r "System.Net.Http"
using System.Net.Http;
using System.Net.Http.Headers;
string url = "https://icanhazdadjoke.com/";
var result = AsyncHelpers.RunSync(
async ()=> {
using(var client = new HttpClient())
@devlead
devlead / csc.cake
Created May 18, 2017 07:17
Example utilize csc.exe from cake
DirectoryPath projectPath = MakeAbsolute(Directory("./cscTest"));
DirectoryPath outputPath = projectPath.Combine("bin/Debug");
FilePath asssemblyPath = outputPath.CombineWithFilePath("Test.dll"),
symbolsPath = outputPath.CombineWithFilePath("Test.pdb");
FilePath[] references = new FilePath[0]; // add any assembly dependencies
Task("Clean")
.Does(() => {
@devlead
devlead / build.cake
Created October 31, 2016 14:07
Example of a custom Cake tool utilizing the in Cake built on tool classes, settings and tool resolution
#load "./customtool.cake"
#load "./mytools.cake"
GitStatus();
GitBranch(new CustomToolSettings { ToolPath = "/bin/git.exe" });
@devlead
devlead / a.cake
Created November 2, 2016 22:59
Sample Cake Inject Task dependency
var taskA = Task("A")
.Does(()=>Information("Hello from A"));
@devlead
devlead / keybase.md
Last active April 11, 2016 14:20
keybase.md

Keybase proof

I hereby claim:

  • I am devlead on github.
  • I am devlead (https://keybase.io/devlead) on keybase.
  • I have a public key whose fingerprint is 477F E77B F054 8C1F C0CE A7F1 F678 07BF C550 2BA9

To claim this, I am signing this object:

@devlead
devlead / gist:6046575
Created July 20, 2013 22:04
Had some twitter discussions with Filip Ekberg ( @fekberg ) about a blog post he wrote (http://blog.filipekberg.se/2013/07/12/are-you-serving-files-insecurely-in-asp-net/) I didn't agrree 100% with his post and some times 140 chars isn't enough to make you point, so toke 10 minutes before bed to write an quick code example and comment more detai…
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Caching;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
using FileDownloadSecurityIdeas.Models;
@devlead
devlead / git-random-tip.ps1
Last active November 9, 2015 15:08
PowerShell scrips that displays random GIT tips
(irm https://raw.githubusercontent.com/git-tips/tips/master/tips.json)|sort {random}|select -First 1|% {"$($_.title)`r`n$($_.tip)" }
@devlead
devlead / azure.xml
Created October 17, 2015 08:18
Add new file types under system.webserver
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
@devlead
devlead / ValidateCountry.ps1
Created May 13, 2015 09:17
ValidateScript is very powerful to validate script / fucntion parameters, example below validate country based on rest service
Param(
[ValidateScript(
{
$countries = ((Invoke-RestMethod -Uri https://raw.githubusercontent.com/devlead/ISO-3166-Countries-with-Regional-Codes/master/all/all.json)| % Name)
if ( $countries -contains $_)
{
$true
}
else
{