Skip to content

Instantly share code, notes, and snippets.

View rafalkasa's full-sized avatar

Rafal Kasa rafalkasa

View GitHub Profile
@kurtdekker
kurtdekker / JsonPlayerPrefs.cs
Created October 16, 2021 12:29 — forked from brettmjohnson/JsonPlayerPrefs.cs
A replacement for Unity's PlayerPrefs that stores data in a JSON file.
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
/// <summary>
/// A replacement for Unity's PlayerPrefs that stores data in a JSON file.
/// </summary>
[Serializable]
public class JsonPlayerPrefs
@ruzrobert
ruzrobert / Vibration.cs
Last active July 12, 2024 20:49
Android Vibration for Unity 3D. Supports all API: 1 - 29 (auto detect), Amplitudes, Predefined Effects, both Legacy and >=26 APIs.
using System.Diagnostics.CodeAnalysis;
using UnityEngine;
// Dont forget to add "using RDG;" to the top of your script!
namespace RDG
{
/// <summary>
/// Class for controlling Vibration. Automatically initializes before scene is loaded.
/// </summary>
public static class Vibration
@TigorC
TigorC / hover-class.directive.ts
Created February 23, 2017 02:56
Angular 2 hover class directive
import { Directive, Input, HostListener, Renderer, ElementRef } from '@angular/core';
@Directive({ selector: '[hoverClass]' })
export class HoverClassDirective {
@Input()
hoverClass: string;
constructor(
public elementRef: ElementRef,
@rionmonster
rionmonster / IQueryableExtensions
Last active November 9, 2022 16:39
Resolve the SQL being executed behind the scenes in Entity Framework Core
public static class IQueryableExtensions
{
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler");
private static readonly PropertyInfo NodeTypeProviderField = QueryCompilerTypeInfo.DeclaredProperties.Single(x => x.Name == "NodeTypeProvider");
private static readonly MethodInfo CreateQueryParserMethod = QueryCompilerTypeInfo.DeclaredMethods.First(x => x.Name == "CreateQueryParser");
using System.Collections.Generic;
using System.Web.Http.Description;
using Swashbuckle.Swagger;
namespace BoundedContext.Web.Swagger
{
public class LowercaseDocumentFilter : IDocumentFilter
{
public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
{
@JonCatmull
JonCatmull / file-size.pipe.ts
Last active April 14, 2024 14:27
Angular2 + TypeScript file size Pipe/Filter. Convert bytes into largest possible unit. e.g. 1024 => 1 KB
/**
* @license
* Copyright (c) 2019 Jonathan Catmull.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
@peterhurford
peterhurford / pytest-fixture-modularization.md
Created July 28, 2016 15:48
How to modularize your py.test fixtures

Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.

Turns out, however, you can define fixtures in individual files like this:

tests/fixtures/add.py

import pytest

@pytest.fixture
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ConvertBytesToKB_MB_GB_TBinCSharp
@benhysell
benhysell / WebApiPostWithProgress.cs
Last active February 13, 2024 16:51
c# web api post with progress reporting
//in setup define client and progress reporter
var httpProgressHandler = new ProgressMessageHandler();
httpProgressHandler.InnerHandler = new HttpClientHandler();
var client = new HttpClient(httpProgressHandler) { BaseAddress = new Uri(Settings.Default.ServerUrl) };
//register to use elsewhere in the application, note it is better to resuse for lifetime of application than create for every call
Mvx.RegisterSingleton(client);
Mvx.RegisterSingleton(httpProgressHandler);