Skip to content

Instantly share code, notes, and snippets.

View stsrki's full-sized avatar
🏢
Working from office

Mladen Macanović stsrki

🏢
Working from office
View GitHub Profile
@ebicoglu
ebicoglu / command-prompt.reg
Last active April 22, 2024 02:45
Useful developer Windows right click items (context menu)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Command Prompt *]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Command Prompt *\command]
@="cmd.exe /s /k pushd \"%V\""
public static class EventUtil
{
// The repetition in here is because of the four combinations of handlers (sync/async * with/without arg)
public static Action AsNonRenderingEventHandler(Action callback)
=> new SyncReceiver(callback).Invoke;
public static Action<TValue> AsNonRenderingEventHandler<TValue>(Action<TValue> callback)
=> new SyncReceiver<TValue>(callback).Invoke;
public static Func<Task> AsNonRenderingEventHandler(Func<Task> callback)
=> new AsyncReceiver(callback).Invoke;
public static Func<TValue, Task> AsNonRenderingEventHandler<TValue>(Func<TValue, Task> callback)
@Merott
Merott / tailwind-colors-as-css-variables.md
Last active June 10, 2024 14:42
Expose Tailwind colors as CSS custom properties (variables)

This is a simple Tailwind plugin to expose all of Tailwind's colors, including any custom ones, as custom css properties on the :root element.

There are a couple of main reasons this is helpful:

  • You can reference all of Tailwind's colors—including any custom ones you define—from handwritten CSS code.
  • You can define all of your colors within the Tailwind configuration, and access the final values programmatically, which isn't possible if you did it the other way around: referencing custom CSS variables (defined in CSS code) from your Tailwind config.

See the Tailwind Plugins for more info on plugins.

@SteveSandersonMS
SteveSandersonMS / blazor-auth.md
Created June 11, 2019 10:49
Blazor authentication and authorization

Authentication and Authorization

Authentication means determining who a particular user is. Authorization means applying rules about what they can do. Blazor contains features for handling both aspects of this.

It worth remembering how the overall goals differ between server-side Blazor and client-side Blazor:

  • Server-side Blazor applications run on the server. As such, correctly-implemented authorization checks are both how you determine which UI options to show (e.g., which menu entries are available to a certain user) and where you actually enforce access rules.
  • Client-side Blazor applications run on the client. As such, authorization is only used as a way of determining what UI options to show (e.g., which menu entries). The actual enforcement of authorization rules must be implemented on whatever backend server your application operates on, since any client-side checks can be modified or bypassed.

Authentication-enabled templates for Server-Side Blazor

@therightstuff
therightstuff / RSAKeys.cs
Last active May 24, 2024 14:20
Import and export RSA Keys between C# and PEM format using BouncyCastle
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Security.Cryptography;
namespace MyProject.Data.Encryption
{
@remarkablemark
remarkablemark / README.md
Last active June 8, 2024 21:48
Classes - ES5 vs ES6

JavaScript Classes - ES5 vs ES6

An example that shows the difference between creating a JavaScript class and subclass in ES5 and ES6.

Reference

@briancavalier
briancavalier / serialize-function.js
Created February 10, 2015 18:34
Serializing / deserializing JavaScript functions *with free variables*
var a = 123, b = 'hello';
function test(x, y) {
console.log(this);
return a + x + b + y;
}
// Serialize a function *with its captured environment*
var sf = serialize(test, { a: a, b: b });
// Deserialize with captured environment
@magicznyleszek
magicznyleszek / css-selectors.md
Last active March 29, 2024 01:12
CSS Selectors Cheatsheet

CSS Selectors Cheatsheet

Hi! If you see an error or something is missing (like :focus-within for few years :P) please let me know ❤️

Element selectors

Element -- selects all h2 elements on the page

h2 {
@lamberta
lamberta / parseFunction.js
Created September 23, 2012 03:57
Parse a JavaScript string function definition and return a function object. Does not use eval.
/* Parse a string function definition and return a function object. Does not use eval.
* @param {string} str
* @return {function}
*
* Example:
* var f = function (x, y) { return x * y; };
* var g = parseFunction(f.toString());
* g(33, 3); //=> 99
*/
function parseFunction (str) {