Skip to content

Instantly share code, notes, and snippets.

View sahildave's full-sized avatar
👨‍💻
I may be slow to respond.

Sahil Dave sahildave

👨‍💻
I may be slow to respond.
View GitHub Profile
@dgrebb
dgrebb / getHighContrastColor.js
Created January 20, 2024 04:13
Forget about your worries and your strife — have a contrast calculator figure out the best color to use against another (black or white).
/**
* Calculates and returns a high-contrast color (either black or white)
* for optimal readability when displayed on top of the provided color.
* The function uses the luminance formula to determine the brightness
* of the input color and returns either black or white based on a
* luminance threshold.
*
* @param {string} hexColor - The hex code of the background color.
* Should be a valid hex color code starting with '#'
* and followed by six hexadecimal characters.
@dgrebb
dgrebb / README.md
Last active April 12, 2024 02:49
Strapi CMS Custom Dashboard (Almost) Replacement Plugin

For brevity, filenames include parent directory(s). - substitutes /.

If installing Strapi fresh, and you're a filthy, untyped rotten scoundrel, remember to add compilerOptions.jsx = "react" as shown below in jsconfig.json to avoid the IDE SquiggleMonster.

  1. npx create-strapi-app@latest --quickstart --no-run strapi-dashbored
  2. npm run strapi generate
  3. choose "middleware"
  4. choose "Add middleware to root of project"
  5. edit src/middlewares/redirect.js
  6. edit config/middlewares.js
@dominikjasek
dominikjasek / @strapi+admin+4.4.6.patch
Last active December 31, 2023 15:11
Responsive @strapi/admin patch
diff --git a/node_modules/@strapi/admin/admin/src/components/LeftMenu/index.js b/node_modules/@strapi/admin/admin/src/components/LeftMenu/index.js
index 23b936b..8042d01 100644
--- a/node_modules/@strapi/admin/admin/src/components/LeftMenu/index.js
+++ b/node_modules/@strapi/admin/admin/src/components/LeftMenu/index.js
@@ -39,7 +39,7 @@ const LinkUser = styled(RouterNavLink)`
&:hover {
background: ${({ theme, logout }) =>
- logout ? theme.colors.danger100 : theme.colors.primary100};
+ logout ? theme.colors.danger100 : theme.colors.primary100};
package com.drawers.myapplication;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.util.AttributeSet;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
@jamesmacwhite
jamesmacwhite / ffmpeg_mkv_mp4_conversion.md
Last active May 5, 2024 15:42
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

@kaushikgopal
kaushikgopal / pre-commit
Last active April 19, 2023 09:22
pre-commit git hook - no "hacking"
#!/usr/bin/env ruby
# This pre-commit hook will prevent any commit to forbidden branches
# (by default, "staging" and "production").
# Put this file in your local repo, in the .git/hooks folder
# and make sure it is executable.
# The name of the file *must* be "pre-commit" for Git to pick it up.
def current_branch()
branches = `git branch --no-color`.split(/\n/)
@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@shkschneider
shkschneider / Log
Last active November 21, 2021 03:51
Android Log helper (automatic class, method and line) replacing android.util.Log
package me.shkschneider.skeleton.helper;
import android.text.TextUtils;
import android.util.Log;
/**
* Improved android.util.Log.
*
* Logs class and method automatically:
* [MyApplication onCreate():34] Hello, world!
@chrisbanes
chrisbanes / CollapsingTitleLayout.java
Last active March 26, 2023 11:58
CollapsingTitleLayout
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package trikke.gists;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;