Skip to content

Instantly share code, notes, and snippets.

View wallymathieu's full-sized avatar

Oskar Mathieu Gewalli wallymathieu

View GitHub Profile
@wallymathieu
wallymathieu / Startup.cs
Last active March 28, 2019 13:21
HowTo register auth for swashbuckle with identity server on asp.net core
Namespace ProjectWithSwagger
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container
public void ConfigureServices(IServiceCollection services)
{
//....
services.ConfigureSwaggerGen(swaggerGen =>
{
@wallymathieu
wallymathieu / Uri_trycreate_can_do_path_combine.cs
Last active November 25, 2016 10:17
Uri try create can do path combine
using System;
using NUnit.Framework;
namespace Tests
{
[TestFixture]
public class Uri_trycreate_can_do_path_combine
{
public static Uri ToUri(string baseUrl, string path)
{
@wallymathieu
wallymathieu / fake.fsx
Created October 8, 2016 15:18
Side by side comparison of cake and fake
let verboseBuild verbosity (defaults:MSBuildParams)=
{ defaults with Verbosity = Some(verbosity) }
let quietBuild = verboseBuild Quiet
let withTargets targets (defaults:MSBuildParams)=
{ defaults with Targets = targets }
let rebuildBuild = withTargets ["ReBuild"]
let buildModeConfiguration buildMode (defaults:MSBuildParams)=
{ defaults with
Properties =
@wallymathieu
wallymathieu / Enums.cs
Created September 22, 2016 08:04
decompose into flags
/// <summary>
/// Decompose a flags enum value into the individual flags.
/// </summary>
public static T[] DeComposeFlags<T>(Enum value)
{
var defaultV = default(T);
return Enum.GetValues(typeof(T))
.Cast<Enum>()
.Where(e=> !defaultV.Equals(e) && value.HasFlag(e))
.Cast<T>()
@wallymathieu
wallymathieu / dump_with_cookies.txt
Created May 6, 2016 05:28
Trying to access api.nuget.org
Request URL:https://api.nuget.org/packages/with.1.0.8.nupkg
Request Method:GET
Status Code:504 Gateway Timeout
Remote Address:93.184.221.200:443
Response headers:
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html
Date: Fri, 06 May 2016 05:20:04 GMT
Server: ECAcc (sto/EA34)
@wallymathieu
wallymathieu / analysing_code.md
Created February 27, 2016 22:19
Analysis of source code

Global Structure

Location of code

  • Is the code located such that reading at one location is sufficient to understand it? Or is it located in many locations?
  • Is there any external documentation (wiki, onenote or word files)?
  • Use of libraries with intuitive API

How do you start reading the code?

  • wiki
  • readme
@wallymathieu
wallymathieu / fsharpi
Created October 16, 2015 05:30
Hard coded location for mono
#!/bin/sh
EXEC="exec "
MONO="/Library/Frameworks/Mono.framework/Commands/mono"
if test x"$1" = x--debug; then
DEBUG=--debug
shift
fi
if test x"$1" = x--gdb; then
@wallymathieu
wallymathieu / stitch.fsi
Created September 25, 2015 20:10
stitch
let r = [0;1;2;3]
let stitch s=
let head = s |> Seq.head
let tail = s |> Seq.skip 1
tail |> Seq.scan (fun state elem-> (snd state, elem)) (head, head)
|> Seq.skip 1
|> Seq.toList
open System.Linq
@wallymathieu
wallymathieu / rakefile.rb
Created August 26, 2015 08:15
Howto add links from one projects files into another project
require 'visual_studio_files' # https://rubygems.org/gems/visual_studio_files
desc "regenerate links in project X"
task :regen_links do
project_y = VisualStudioFiles::CsProj.new(File.open(File.join($dir,'ProjectY','ProjectY.csproj'), "r").read)
project_y_files = v.files.select do |file|
file.type=='Compile' && !file.file.end_with?('AssemblyInfo.cs')
end
project_x = VisualStudioFiles::CsProj.new(File.open(File.join($dir,'ProjectX','ProjectX.csproj'), "r").read)
project_x.clear_links
@wallymathieu
wallymathieu / gist:db05ab8dd46e0de05c11
Last active August 29, 2015 14:28 — forked from coffeejunk/gist:3827905
ruby string for xml
In Ruby 1.9.2 to escape XML special characters in Strings, use the 'encode' method.
Example, if you have:
my_string = 'this is "my" complicated <String>'
For XML attributes use:
"<node attr=#{my_string.encode(:xml => :attr)} />"
Generates: