Skip to content

Instantly share code, notes, and snippets.

@mxalbert1996
mxalbert1996 / Scrollbar.kt
Last active April 25, 2024 12:48
Modifiers to draw scrollbars in Jetpack Compose
/*
* MIT License
*
* Copyright (c) 2022 Albert Chang
*
* 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
@dyaa
dyaa / ajaxerror.js
Created September 22, 2013 13:03
JQUERY AJAX ERROR HANDLING FUNCTION
$(function() {
$.ajaxSetup({
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
@wojtekmaj
wojtekmaj / jest-to-vitest.sh
Last active April 25, 2024 12:46
Automatically migrate Jest project to Vitest
#!/bin/bash
# Ensure we're working on the latest version of the main branch
git switch main
git fetch
git pull
# Create a new branch
git switch -c vitest
lambda function
----
exports.handler = async (event) => {
console.log(event)
const customerId = event.pathParameters.customerId;
const customer = {'customerId': customerId, 'customerName': "Customer " + customerId };
const response = {
statusCode: 200,
// Uncomment below to enable CORS requests
headers: {
@FUSAKLA
FUSAKLA / debugging-slow-grafana-dashboard.md
Last active April 25, 2024 12:45
Speeding up Grafana dashboard

Intro

So your dashboard is slow? We are doing our best but maybe it's time to think if the issue isn't on your side.

Some of our dashboards looks like https://www.theworldsworstwebsiteever.com/. Are you sure you really need to see all the time all the data? Or do you really need to see data for last week or month all the time? How often do you use filtering by some of those variables in your dashboard?

Let's not end up as your mother saying:

But.. but.. I might need this in future so let's leave this icon on the Desktop.

@Shubhra22
Shubhra22 / ScreenshotNow.cs
Last active April 25, 2024 12:45
Screen Capture of particular UI elements
using UnityEngine;
using System.Collections;
using System.IO;
using UnityEngine.UI;
public class ScreenshotNow : MonoBehaviour
{
public RectTransform rectT; // Assign the UI element which you wanna capture
public Image img;
int width; // width of the object to capture
int height; // height of the object to capture
private val DefaultHighlightWidth = 136.dp
private val DefaultDuration = 1200.milliseconds
private val DefaultDelay = 1.seconds
private val DefaultStartColor = Color(0x32394A00)
private val DefaultMiddleColor = Color.White
private val DefaultEndColor = DefaultStartColor
private const val DefaultAlpha = 0.2F
private val DefaultShape = RoundedCornerShape(12.dp)
@Composable
@KlassenKonstantin
KlassenKonstantin / RubberBandSlider.kt
Created January 15, 2024 17:16
Rubber Band Slider Compose
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
RubberBandSliderTheme {
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
Box(contentAlignment = Alignment.Center) {
RubberBandSlider(modifier = Modifier
.height(200.dp)
@bennewton999
bennewton999 / dailyNoteTemplate.txt
Last active April 25, 2024 12:40
My current Daily Note Template in Obsidian utilizing Templater and DataView Plugins
---
creation date: <% tp.file.creation_date() %>
tags: DailyNote <% tp.file.title.split('-')[0] %>
---
modification date: <%+ tp.file.last_modified_date("dddd Do MMMM YYYY HH:mm:ss") %> // This doesn't currently work in front matter, hoping that gets fixed.
# <% tp.file.title %>
<< [[<% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>]] | [[<% tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD") %>]]>>