Skip to content

Instantly share code, notes, and snippets.

@sachithrrra
sachithrrra / managing_multiple_github_accounts_on_macos.md
Created April 9, 2025 15:11
Managing Multiple GitHub Accounts on macOS

Managing Multiple GitHub Accounts on macOS

1. Create SSH keys

cd ~/.ssh
ssh-keygen -t rsa -C "my@personal" -f "github-personal"
ssh-keygen -t rsa -C "my@work" -f "github-work"
@sachithrrra
sachithrrra / gist:7f65742df5dd604dde5aa291263f60d2
Last active March 14, 2025 05:00
regex to delete all things on vscode
// console messages
console\.(log|warn|error|info|debug|trace|time|timeEnd|timeLog|table|count|countReset|group|groupEnd|groupCollapsed|assert|clear|dir|dirxml)\([\s\S]*?\);?
// comments
// .*$|/\*[\s\S]*?\*/
@sachithrrra
sachithrrra / gist:f05bfb4b5387fb4436bccfe71edc8649
Created January 30, 2025 07:05
remove all tailwind classes from project in vscode with regex
// removes all rounded classes
(^\s*|\s+)rounded(-[a-z]+)?
@sachithrrra
sachithrrra / functions.php
Created June 4, 2024 05:51
Remove Image Links in WordPress
////////// 1. Blank link
function remove_links_around_images($content) {
// Use regex to remove anchor tags around image tags
$pattern = '/<a[^>]*>(\s*<img[^>]*>\s*)<\/a>/i';
$replacement = '$1'; // Keep the image tag and remove the anchor tag
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
@sachithrrra
sachithrrra / next.config.mjs
Created May 12, 2024 10:25
nextjs chaining multiple plugins with configs
import { paraglide } from "@inlang/paraglide-next/plugin";
import createMDX from "@next/mdx";
// Define paraglide configuration
const paraglideConfig = {
paraglide: {
project: "./project.inlang",
outdir: "./src/paraglide",
},
basePath: "",
@sachithrrra
sachithrrra / kaggle-to-google-drive-google-colab.py
Created January 26, 2024 07:43
Download dataset from Kaggle to Google Drive on Google Colab
# Credits: https://www.kaggle.com/discussions/general/74235#2193182
# Step 1:
# Use below code to upload your kaggle.json to colab environment (you can download kaggle.json from your Profile->Account->API Token)
from google.colab import files
files.upload()
# Step 2:
# Below code will remove any existing ~/.kaggle directory and create a new one. It will also move your kaggle.json to ~/.kaggle
@sachithrrra
sachithrrra / colab-to-drive.py
Created January 24, 2024 09:43
Save directory from Google colab to your Google drive
from google.colab import drive
drive.mount('/content/drive')
!cp <output-directory-name> -r /content/drive/MyDrive/<destination-directory-name>
# !cp whale-data -r /content/drive/MyDrive/whale-data-unzipped
@sachithrrra
sachithrrra / functions.php
Created April 27, 2022 10:32
Remove child categories from Wordpress permalink
/*
Remove child categories from Wordpress permalink (https://example.com/%category%/%postname%/ custom structure)
https://example.com/category/sub-category/post-name to https://example.com/category/post-name
*/
function remove_child_categories_from_permalinks( $category ) {
while ( $category->parent ) {
$category = get_term( $category->parent, 'category' );
}
@sachithrrra
sachithrrra / functions.php
Created July 4, 2021 09:16
Change Wordpress excerpt length
function custom_excerpt_length( $length ) {
return 45; // Use any integer per your requirement.
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
@sachithrrra
sachithrrra / functions.php
Created June 10, 2021 12:41
Enable SVG support on Wordpress
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');