Skip to content

Instantly share code, notes, and snippets.

View gsscoder's full-sized avatar
💭
obsessive coding disorder

coder (π³) gsscoder

💭
obsessive coding disorder
View GitHub Profile
@johnazariah
johnazariah / LinqExtensions.cs
Last active March 28, 2024 08:50
Maybe Monad in C#
public static partial class LinqExtensions
{
public static Maybe<C> SelectMany<A, B, C>(this Maybe<A> ma, Func<A, Maybe<B>> f, Func<A, B, C> select) => ma.Bind(a => f(a).Map(b => select(a, b)));
}
@swlaschin
swlaschin / effective-fsharp.md
Last active March 8, 2024 03:10
Effective F#, tips and tricks

Architecture

  • Use Onion architecture

    • Dependencies go inwards. That is, the Core domain doesn't know about outside layers
  • Use pipeline model to implement workflows/use-cases/stories

    • Business logic makes decisions
    • IO does storage with minimal logic
    • Keep Business logic and IO separate
  • Keep IO at edges

@subhodi
subhodi / QuickSort.sol
Created December 14, 2017 08:31
Quick sort in Solidity for Ethereum network
pragma solidity ^0.4.18;
contract QuickSort {
function sort(uint[] data) public constant returns(uint[]) {
quickSort(data, int(0), int(data.length - 1));
return data;
}
function quickSort(uint[] memory arr, int left, int right) internal{
@bryanbarnard
bryanbarnard / SimpleHttpClient.cs
Created December 23, 2013 19:15
Simple C# .NET 4.5 HTTPClient Request Using Basic Auth and Proxy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net;
namespace HTTP_Test
@niik
niik / CryptoRandom.cs
Created June 9, 2011 21:48
Buffered CryptoRandom implementation based on Stephen Toub and Shawn Farkas' CryptoRandom
/*
* Original version by Stephen Toub and Shawn Farkas.
* Random pool and thread safety added by Markus Olsson (freakcode.com).
*
* Original source: http://msdn.microsoft.com/en-us/magazine/cc163367.aspx
*
* Some benchmarks (2009-03-18):
*
* Results produced by calling Next() 1 000 000 times on my machine (dual core 3Ghz)
*
@frankhu-2021
frankhu-2021 / PrettifyJSON
Last active January 19, 2023 13:19
PrettyPrint JSON with .NET using Newtonsoft.Json
using Newtonsoft.Json;
public static string JsonPrettify(string json)
{
using (var stringReader = new StringReader(json))
using (var stringWriter = new StringWriter())
{
var jsonReader = new JsonTextReader(stringReader);
var jsonWriter = new JsonTextWriter(stringWriter) { Formatting = Formatting.Indented };
jsonWriter.WriteToken(jsonReader);
@Tofunmi1
Tofunmi1 / README.md
Created July 31, 2022 20:22
Bubble sort algorithm in yul

Recursive Implementation Of Bubble Sort in solidity and yul

***credit -> geekforgeeks -> https://www.geeksforgeeks.org/bubble-sort/

The idea is to place the largest element at their position and keep doing the same for every other elements.

Approach:

Place the largest element at their position, this operation makes sure that first largest element will be placed at the end of array. Recursively call for rest n – 1 elements with same operation and placing the next greater element at their position. Base condition for this recursion call would be, when number of elements in the array becomes 0 or 1 then, simply return (as they are already sorted).

@aidapsibr
aidapsibr / nuget-cache-projects.yml
Created January 20, 2020 10:47
Example using actions/cache to create a cache for all nuget packages based on project files (assumes PackageReference is used)
- uses: actions/cache@v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files
restore-keys: |
${{ runner.os }}-nuget-
@devhawk
devhawk / colorconsole.fs
Created August 4, 2016 17:19
F# Color Console Functions
open System
// helper function to set the console collor and automatically set it back when disposed
let consoleColor (fc : ConsoleColor) =
let current = Console.ForegroundColor
Console.ForegroundColor <- fc
{ new IDisposable with
member x.Dispose() = Console.ForegroundColor <- current }
// printf statements that allow user to specify output color
@teeaich
teeaich / sp_logout
Created September 2, 2013 08:01
sharepoint logout url
http://yoursite/_layouts/closeConnection.aspx?loginasanotheruser=true