Skip to content

Instantly share code, notes, and snippets.

View Cifro's full-sized avatar

Cifro Nix Cifro

View GitHub Profile
@davidfowl
davidfowl / .NET6Migration.md
Last active April 11, 2024 02:02
.NET 6 ASP.NET Core Migration
@davidfowl
davidfowl / MinimalAPIs.md
Last active May 18, 2024 18:28
Minimal APIs at a glance
using System;
using System.Threading.Tasks;
namespace System.Collections.Concurrent
{
public static class ConcurrentDictionaryExtensions
{
/// <summary>
/// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>.
/// </summary>
@eaton-sam
eaton-sam / blazor-wasm-s3-cloudfront.yml
Created June 17, 2020 21:21
Action yml for hosting a blazor wasm app on AWS s3, behind cloudfront. Build, publish, push to s3, force cloudfront cache refresh.
name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@cinnamon-msft
cinnamon-msft / settings.json
Created May 21, 2020 12:29
Windows Terminal Build Color Scheme
{
"name": "Build",
"foreground": "#f1f1f1",
"background": "#492D7C",
"cursorColor": "#FFFFFF",
"black": "#0C0C0C",
"red": "#C50F1F",
"green": "#13A10E",
"yellow": "#C19C00",
@nataliemarleny
nataliemarleny / .gitconfig
Last active October 19, 2021 09:50
Niche git commands which I won't remember aliases for
[user]
name = <ur-name>
email = <ur-email>
[core]
editor = vim -f
excludesfile = /Users/<name-of-mac>/.gitignore_global
[color]
ui = true
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit
@mattdfloyd
mattdfloyd / CreateProductJob.php
Created June 21, 2018 02:26
Laravel's firstOrCreate race conditions
<?php
namespace App\Jobs;
use App\Product;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Redis;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
@troatie
troatie / CreatesWithLock.php
Last active September 12, 2023 13:51
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
@BaronVonPerko
BaronVonPerko / gulpfile.js
Last active August 24, 2023 08:27
Gulpfile for SCSS and Tailwind
var gulp = require('gulp');
var sass = require('gulp-sass');
var postcss = require('gulp-postcss');
gulp.task('style', function () {
var tailwindcss = require('tailwindcss');
return gulp.src('sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss([
@bendc
bendc / simulate-typing.js
Created September 1, 2017 08:57
Fake typing animation
const trackTime = timing => {
const now = performance.now();
if (!timing.startTime) timing.startTime = now;
const elapsed = now - timing.startTime;
const {duration} = timing;
if (duration != null && duration <= elapsed) timing.startTime = null;
return elapsed;
};
const delay = (callback, duration) => {