Skip to content

Instantly share code, notes, and snippets.

View rocktimsaikia's full-sized avatar
🐾
Always learning

Rocktim rocktimsaikia

🐾
Always learning
View GitHub Profile
@rocktimsaikia
rocktimsaikia / README.md
Last active November 29, 2023 09:20 — forked from aidos-dev/README.md
Connect Apple AirPods to Linux (Ubuntu)

Connect Apple AirPods to Linux (Ubuntu)

# 1. Open the below file with vim
sudo vim /etc/bluetooth/main.conf

# 2. Change the value of this field to bredr
ControllerMode = bredr

# 3. Save and Exit from Vim.
@aidos-dev
aidos-dev / README.md
Last active May 2, 2024 20:36
How to connect Apple AirPods to Linux (Debian/Ubuntu/Mint)

How to connect Apple AirPods to Linux (Debian/Ubuntu/Mint)

Step 1.

Open your terminal.

In the root directory run the command:

sudo nano /etc/bluetooth/main.conf
local feline = require('feline')
local vi_mode = require('feline.providers.vi_mode')
--
-- 1. define some constants
--
-- left and right constants (first and second items of the components array)
local LEFT = 1
local RIGHT = 2
@raviagheda
raviagheda / github-action-ssh.md
Last active May 2, 2024 10:06
Github Action with EC2 using SSH
@Jaid
Jaid / migratingRules.md
Last active February 21, 2024 10:48
ESLint rules for migrating projects from CommonJS to ESM

ESLint rules

The ESM standard is considered stable in NodeJS and well supported by a lot of modern JavaScript tools.

ESLint does a good job validating and fixing ESM code (as long as you don't use top-level await, coming in ESLint v8). Make sure to enable the latest ECMA features in the ESLint config.

  • .eslint.json
{
@rocktimsaikia
rocktimsaikia / invert.js
Last active March 11, 2021 06:27
Invert an array of integers
// Inverts the integers of an array
const invert = arr => arr.map(n => -n);
invert([2,-5]); //=> [-2,5]
@sindresorhus
sindresorhus / esm-package.md
Last active May 4, 2024 09:23
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@rocktimsaikia
rocktimsaikia / paginate.md
Last active January 14, 2021 15:31
🔥 How to paginate in mongodb using mongoose

🔥 Here is how to paginate in MongoDB using mongoose :

// Here it is hardcoded for example but 
// generally the `pageNum` should come from request query param
const pageNum = 2;
const pageSize = 10;

// pagination formula
const paginate = (pageNum - 1) * pageSize; 
@rocktimsaikia
rocktimsaikia / mongodb.md
Last active January 18, 2021 08:46
🔥 A tiny mongodb command cheatsheet for my personal use. Because I tend to forget them quite often

Common mongo shell commands/methods

show dbs : Show all the databases.
use <database> : switch/move into a database.
show collections : Show all the collections in that database.
db.<collection>.find() : Show all documents in the collection.
db.<collection>.help() : Show help on collection methods.
db.<collection>.drop() : Drops or removes completely the collection.
db.<collection>.deleteMany() : Delete documents from the collection.
db.dropDatabase(): Deletes a database.

@dillonchanis
dillonchanis / example.css
Created September 20, 2020 14:44
Tailwind Utility for using gradients with text
@layer utilities {
.text-gradient {
background-clip: text;
-webkit-text-fill-color: transparent;
}
}