Skip to content

Instantly share code, notes, and snippets.

View chayanforyou's full-sized avatar
🤖
Learning...

Chayan Mistry chayanforyou

🤖
Learning...
View GitHub Profile
@chayanforyou
chayanforyou / atmega8_timer0.c
Created October 1, 2022 02:53 — forked from mkleemann/atmega8_timer0.c
atmega8 timer0 - use overflow interrupt
// All values/comments are valid with ATmega8 running at Fosc = 4.000MHz
#include <avr/io.h>
#include <avr/interrupt.h>
// TIMER0 with prescaler clkI/O/1024
#define TIMER0_PRESCALER (1 << CS02) | (1 << CS00)
void main()
@chayanforyou
chayanforyou / DecimalToFraction
Created September 28, 2022 04:00 — forked from jaffes2/DecimalToFraction
Decimal to Fraction Converter
/*
* Converts Decimals to Fractions
*
*/
package simpleai;
/**
*
* @author sarabeth
*/
@chayanforyou
chayanforyou / decimalToFraction.js
Created September 28, 2022 04:00 — forked from redteam-snippets/decimalToFraction.js
JavaScript: Decimal To Fraction
// Adapted from: http://bateru.com/news/2011/11/improved-code-for-javascript-decimal-to-fraction/
function gcd(a, b) {
return (b) ? gcd(b, a % b) : a;
}
var decimalToFraction = function (_decimal) {
var top = _decimal.toString().replace(/\d+[.]/, '');
var bottom = Math.pow(10, top.length);
if (_decimal > 1) {
@chayanforyou
chayanforyou / SimpleStorage Save Image.md
Created August 27, 2022 17:19
Simplify Android Storage Access Framework for file management across API levels.

Simplify Android Storage Access Framework for file management across API levels. https://github.com/anggrayudi/SimpleStorage

fun saveFile(bitmap: Bitmap, context: Context) {
    val fileDesc = FileDescription("test_image.jpg", "MyFolder", "image/*")
    val image = DocumentFileCompat.createPictureWithMediaStoreFallback(context, fileDesc)

    val fos = image?.openOutputStream(context)
 fos?.use {
@chayanforyou
chayanforyou / Discord auto start on Ubuntu.md
Created August 20, 2022 06:26
Make Discord auto start on Ubuntu 20.04 & 22.04

The Discord app on linux ubuntu desktop does not start the app. But you can make it auto start by following this steps.

  • Open Applications and search for Startup Applications

  • Then click Add an input box will open, put the following information and Save.
    Name: Discord
    

Command: /usr/bin/discord --tray

@chayanforyou
chayanforyou / AsyncTask.md
Last active February 2, 2025 16:37
Android AsyncTask is Deprecated: Here’s another way

According to the Android documentation AsyncTask was deprecated in API level 30 and it is suggested to use the standard java.util.concurrent or Kotlin concurrency utilities instead.

AsyncTasks.java

public abstract class AsyncTasks<Params, Result> {

    private final ExecutorService executors;

    public AsyncTasks() {
        this.executors = Executors.newSingleThreadExecutor();
@chayanforyou
chayanforyou / WSL 2 requires an update to its kernel component.md
Created August 2, 2022 06:12
Error: 0x800701bc WSL 2 requires an update to its kernel component.

For WSL2 you will need 2 Windows components so make sure they are already enabled: Microsoft-Windows-Subsystem-Linux VirtualMachinePlatform

Also it seems some people have problems with the installer extracting the kernel. You can always extract it manually with: msiexec /a "wsl_update_x64.msi" /qb TARGETDIR="C:\temp" and then copy the kernel file from C:\temp to C:\Windows\System32\lxss\tools

Final version shouldn't have this problem since the install comes from Windows Update.

@chayanforyou
chayanforyou / Missing Dock in Ubuntu.md
Created May 25, 2022 04:52
Restore Missing Ubuntu Dock
  1. First, install the Extensions tool (gnome-shell-extension-prefs), load it up and disable the "Ubuntu Dock" extension if it is not already disabled.
  2. Reset the configuration settings of Ubuntu Dock to the factory defaults with the following terminal command: dconf reset -f /org/gnome/shell/extensions/dash-to-dock/
  3. (Likely not needed, but to make sure: log out then back in)
  4. Reenable Ubuntu Dock in the "Extensions" tool. If you do not see Ubuntu Dock in the tool, try restarting first.

This will reset your personal dock configurations. An issue with the current configuration is most likely causing the problems. Ubuntu Dock is derived from the Dash to Dock extension, and shares the same configuration settings.

If problems persist, then there may be an issue at the system level. Then attempt a reinstall of the dock:

@chayanforyou
chayanforyou / bridging-react-native.md
Last active February 7, 2022 09:37 — forked from chourobin/0-bridging-react-native-cheatsheet.md
React Native Bridging Cheatsheet

Reason for Not Enough ROM error!:

There are several reasons for this. Also, there are solutions to them. Sometimes, little precaution will help reduce your time consumption for a project. Otherwise, it may take hours, days, weeks even months to find the problem and solve it. Let’s find the reason and ways to solve that.

1. Using too much ASCII values

Convert the ASCII into a constant value. And print each digit one by one. Let’s see!

void Lcd_COut(char row, char col, const char *cptr)