Skip to content

Instantly share code, notes, and snippets.

View circleupx's full-sized avatar

Yunier circleupx

  • South Florida
  • 01:43 (UTC -04:00)
View GitHub Profile
@markwhitaker
markwhitaker / MimeTypes.cs
Last active December 29, 2023 16:42
Standard MIME type constants ready to use in a C# project. Now a NuGet package: see https://github.com/markwhitaker/MimeTypes.NET
public static class MimeTypes
{
public static class Application
{
public const string AtomXml = "application/atom+xml";
public const string AtomcatXml = "application/atomcat+xml";
public const string Ecmascript = "application/ecmascript";
public const string JavaArchive = "application/java-archive";
public const string Javascript = "application/javascript";
public const string Json = "application/json";
using System.Web;
using Sitecore.StaticAssets.Infrastructure;
namespace Sitecore.StaticAssets.Html.Helpers
{
public static class StaticAssets
{
private static StaticAssetResolver _assetResolver;
public static void Initialize(StaticAssetResolver staticAssetResolver)
using System.Collections.Generic;
namespace Sitecore.StaticAssets.Infrastructure
{
public class AssetCollection : Dictionary<string, string>
{
}
}
using System.Diagnostics;
using System.IO;
using System.Web.Caching;
using Newtonsoft.Json;;
namespace Sitecore.StaticAssets.Infrastructure
{
public class StaticAssetResolver
{
private readonly string _assetsJsonPath;
using Sitecore.Pipelines;
using Sitecore.StaticAssets.Infrastructure;
namespace Sitecore.StaticAssets.Pipelines
{
public class InitializeStaticAssetsResolver
{
private readonly string _assetPath;
public InitializeStaticAssetsResolver(string assetPath)
@mikebridge
mikebridge / EventAggregator.cs
Last active March 10, 2021 02:28
A simple Event Aggregator that allows multiple subscribers per message type.
using System;
using System.Reactive.Linq;
using System.Reactive.Subjects;
// inspired by https://github.com/shiftkey/Reactive.EventAggregator/blob/master/src/Reactive.EventAggregator/EventAggregator.cs
namespace Messaging
{
public interface IEventAggregator : IDisposable
{

Status

This extension was developed as part of the jsonapi module for Drupal.

Introduction

The JSON API specification is agnostic about how a server implements filtering strategies. In fact, the spec says:

Note: JSON API is agnostic about the strategies supported by a server. The filter query parameter can be used as the basis for any number of filtering strategies.

@dvdsgl
dvdsgl / Monads for a C# dev.md
Last active January 8, 2024 06:11
Monads explained (sort of) to a C# developer

A monad is a fancy word for a generic type of the form MyMonad<T> (a generic type of arity 1).

A monad is special because it adds 'special powers' to the T that it wraps. These 'special powers' won't sound very special to an imperative programmer, so you have to squint to see them but bear with me.

  • IEnumerable<T> is a monad that gives values of type T the special power of nondeterminism, or the ability to 'be' multiple values at once.
  • Nullable<T> is a monad that gives values of type T the special power of nullability, or the ability to be absent.
  • Task<T> is a monad that gives values of type T the special power of asynchronicity, or the ability to be used before they are computed.

The trick with monads comes when you want to play with the T values, because they are inside another type. C# introduced language changes to make dealing with values inside these monads easier:

@yutelin
yutelin / String+AES.swift
Last active January 22, 2024 12:36
String+AES.swift
import Foundation
import CryptoSwift
extension String {
func aesEncrypt(key: String, iv: String) throws -> String{
let data = self.dataUsingEncoding(NSUTF8StringEncoding)
let enc = try AES(key: key, iv: iv, blockMode:.CBC).encrypt(data!.arrayOfBytes(), padding: PKCS7())
let encData = NSData(bytes: enc, length: Int(enc.count))
let base64String: String = encData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0));
@RohanBhanderi
RohanBhanderi / Git_mergetool_commands
Last active March 13, 2024 12:16
Git Mergetool and difftool with Beyond Compare 4
//Git Mergetool and difftool with Beyond Compare 4
//For Windows
//IF running this command in git bash then escape $ with \
git config --global diff.tool bc4
git config --global difftool.bc4.cmd "\"C:/Program Files (x86)/Beyond Compare 4/BCompare.exe\" \"\$LOCAL\" \"\$REMOTE\""
git config --global difftool.prompt false
git config --global merge.tool bc4
git config --global mergetool.bc4.cmd "\"C:/Program Files (x86)/Beyond Compare 4/BCompare.exe\" \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
git config --global mergetool.bc4.trustExitCode true