Skip to content

Instantly share code, notes, and snippets.

View mikayelgr's full-sized avatar

Mikayel Grigoryan mikayelgr

View GitHub Profile
@mikayelgr
mikayelgr / flatten.js
Last active March 2, 2025 07:44
Perhaps one of the most useful scripts I ever made. I use this frequently to copy the contents from my phone to my HDD to back up all the photos and videos.
const fs = require('fs');
const path = require('path');
function moveContentsToParentDirectory(directoryPath) {
// Get the list of files and directories in the given directory
const contents = fs.readdirSync(directoryPath);
contents.forEach(item => {
const itemPath = path.join(directoryPath, item);
const stats = fs.statSync(itemPath);
@mikayelgr
mikayelgr / luminocity.cpp
Last active January 7, 2025 15:32
RP2040 with Adafruit NeoPixel Luminosity Detector
#include <Adafruit_NeoPixel.h>
#include <TimeLib.h>
#include <Arduino.h>
#define ADAFRUIT_NEOPIXEL_CTL_PIN 12 // Control line for the Adafruit NeoPixel
#define ADAFRUIT_NEOPIXEL_PWR_PIN 11 // Power line for the Adafruit NeoPixel
#define ADAFRUIT_NEOPIXEL_NUMPIXELS 1 // Total number of Adafruit NeoPixels
#define ADAFRUIT_NEOPIXEL_BRIGHTNESS 255 // uint8_t (0-255)
Adafruit_NeoPixel pixels(
ADAFRUIT_NEOPIXEL_NUMPIXELS,
@mikayelgr
mikayelgr / graceful.rs
Last active April 12, 2023 06:38
Graceful shutdown using raw pointers and Tokio.
use std::{fmt::Debug, future::Future};
use log::debug;
/// Custom unsafe wrapper around [Send], used for passing around pointers
/// between [tokio::task]s.
pub(crate) struct UnsafeSend<T>(T);
/// The Send trait is automatically implemented when the compiler determines it's appropriate.
/// However, for current use-case, it would not be possible, since it is not allowed to share
/// multiple mutable references between threads.
@mikayelgr
mikayelgr / 2019-https-localhost.md
Created March 6, 2021 18:42 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@mikayelgr
mikayelgr / meta-tags.md
Created February 1, 2021 14:38 — forked from whitingx/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>