Skip to content

Instantly share code, notes, and snippets.

@m1lkweed
m1lkweed / un_builtin.c
Last active April 26, 2024 14:05
Replacements for various gcc builtins using c23's `typeof` and c11's `_Generic`
// Compares types of both parameters. Returns true if the types are compatible, otherwise false.
// Parameter y may not be a variably-modified type.
// Designed to be a drop-in replacement for gcc's __builtin_types_compatible_p
#define types_compatible_p(x, y) _Generic(((typeof(x)*){}), typeof(y)*:1, default:0)
// Cast the bits of arg to type. Parameter type must be a type and must not be a literal or object with that type.
// Designed to be compatible with g++'s __builtin_bit_cast
#define bit_cast(type, ...) ( \
union{typeof(__VA_ARGS__) in; typeof(type) out; \
int enforce_type:_Generic((int(*)(int(type)))0, \
@daytonn
daytonn / .colors
Created January 28, 2014 21:50
Bash Color functions
# Colors
end="\033[0m"
black="\033[0;30m"
blackb="\033[1;30m"
white="\033[0;37m"
whiteb="\033[1;37m"
red="\033[0;31m"
redb="\033[1;31m"
green="\033[0;32m"
greenb="\033[1;32m"
@mmocny
mmocny / soft-navs.js
Last active April 26, 2024 14:04
Measure FCP/LCP + Soft Navs
const RATING_COLORS = {
"good": "#0CCE6A",
"needs-improvement": "#FFA400",
"poor": "#FF4E42",
"invalid": "#FFC0CB",
"default": "inherit", // Will default to this, anyway
};
function log(metric) {
const prettyScore = metric.value.toLocaleString(undefined, { maximumFractionDigits: 0 });
@lionwolfdev
lionwolfdev / download_slack_files.py
Last active April 26, 2024 14:03
A Python Script to download Files (e.g. images and videos) from a Slack channel.
"""
Downloads all images from a Slack channel.
Original from https://gist.github.com/igniteflow/170df9808ca5e68c3dc4ba16bb92cb64
Instructions:
=============
Visit this page and create a new application; choose "From an app manifest" in the dialogue: https://api.slack.com/apps
Paste the following manifest (everything between but without the ```) when prompted to do so.
@morteza-mori
morteza-mori / mikrotik
Created October 2, 2018 08:52
Mikrotik nslookup
put [resolve google.com server 8.8.8.8]
$exitCode = 0
if (![System.Environment]::Is64BitProcess)
{
# start new PowerShell as x64 bit process, wait for it and gather exit code and standard error output
$sysNativePowerShell = "$($PSHOME.ToLower().Replace("syswow64", "sysnative"))\powershell.exe"
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $sysNativePowerShell
$pinfo.Arguments = "-ex bypass -file `"$PSCommandPath`""
$pinfo.RedirectStandardError = $true
@mjbalcueva
mjbalcueva / password-input.tsx
Last active April 26, 2024 14:01
shadcn ui custom password input
"use client"
import { forwardRef, useState } from "react"
import { EyeIcon, EyeOffIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import { Input, InputProps } from "@/components/ui/input"
import { cn } from "@/lib/utils"
const PasswordInput = forwardRef<HTMLInputElement, InputProps>(
({ className, ...props }, ref) => {
## Step 1
Open C:\Windows\System32\drivers\etc\hosts
## Step 2
Add 1.2.3.4 account.jetbrains.com
## Step 3
Add this key to Phpstorm
``1W61R3J3UL-eyJsaWNlbnNlSWQiOiIxVzYxUjNKM1VMIiwibGljZW5zZWVOYW1lIjoi5r+A5rS75p2l5rqQIHd3d8K3YWppaHVvwrdjb20iLCJhc3NpZ25lZU5hbWUiOiIiLCJhc3NpZ25lZUVtYWlsIjoiIiwibGljZW5zZVJlc3RyaWN0aW9uIjoiIiwiY2hlY2tDb25jdXJyZW50VXNlIjpmYWxzZSwicHJvZHVjdHMiOlt7ImNvZGUiOiJEUE4iLCJwYWlkVXBUbyI6IjIwMjEtMDgtMTEifSx7ImNvZGUiOiJEQiIsInBhaWRVcFRvIjoiMjAyMS0wOC0xMSJ9LHsiY29kZSI6IlBTIiwicGFpZFVwVG8iOiIyMDIxLTA4LTExIn0seyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMjEtMDgtMTEifSx7ImNvZGUiOiJSU0MiLCJwYWlkVXBUbyI6IjIwMjEtMDgtMTEifSx7ImNvZGUiOiJHTyIsInBhaWRVcFRvIjoiMjAyMS0wOC0xMSJ9LHsiY29kZSI6IkRNIiwicGFpZFVwVG8iOiIyMDIxLTA4LTExIn0seyJjb2RlIjoiUlNGIiwicGFpZFVwVG8iOiIyMDIxLTA4LTExIn0seyJjb2RlIjoiUEMiLCJwYWlkVXBUbyI6IjIwMjEtMDgtMTEifSx7ImNvZGUiOiJSQyIsInBhaWRVcFRvIjoiMjAyMS0wOC0xMSJ9LHsiY29kZSI6IkNMIiwicGFpZFVwVG8iOiIyMDIxLTA4LTExIn0seyJjb2RlIjoiV1MiLCJwYWlkVXBUbyI6IjIwMjEtMDgtMTEifSx7ImNvZGUiOiJSRCIsInBhaWR
@max10rogerio
max10rogerio / slugify.ts
Last active April 26, 2024 14:00
Typescript slug function
// MIT License
// Copyright (c) 2023 Max Rogério
// 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:
@0xdevalias
0xdevalias / compare-diff-audio-files.md
Last active April 26, 2024 13:58
Some notes on comparing/contrasting/diffing audio files