Skip to content

Instantly share code, notes, and snippets.

View dr5hn's full-sized avatar
🪄
Turning ☕ into code | Full Stack Magician 🧙‍♂️✨

Darshan Gada dr5hn

🪄
Turning ☕ into code | Full Stack Magician 🧙‍♂️✨
View GitHub Profile
@dr5hn
dr5hn / README.md
Created March 25, 2023 14:16 — forked from VladimirAlexiev/README.md
How to use Google Sheets to Manage Wikidata Coreferencing

How to use Google Sheets to Manage Wikidata Coreferencing

A previous post How to Add Museum IDs to Wikidata explained how to use SPARQL to find missing data on Wikidata (Getty Museum IDs), how to create such values (from museum webpage URLs) and how to format them properly for QuickStatements.

Here I explain how to use Google sheets to manage a more advanced task. The sheet AAT-Wikidata matches about 3k AAT concepts to Wikipedia, WordNet30 and BabelNet (it restored an old mapping to Wordnet, retrieved it from BabelNet, mapped to Wikipedia).

  • For each row, it uses the following Google sheet formula (column C) to query the Wikipedia API and get the corresponding Wikidata ID (wikibase_item); split on two lines for readability:
=ImportXml(concat("https://en.wikipedia.o
@dr5hn
dr5hn / .zshrc
Created September 3, 2021 11:41
SSH Agent - Start & Load Profiles to zsh Terminal
SSH_ENV=$HOME/.ssh/environment
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
echo succeeded
chmod 600 ${SSH_ENV}
. ${SSH_ENV} > /dev/null
@dr5hn
dr5hn / .zprofile
Created September 3, 2021 11:39
Useful Aliases & .zProfile config
# Sourced upon login
eval $(/opt/homebrew/bin/brew shellenv)
# Setup Compiler paths for readline and openssl
local READLINE_PATH=$(brew --prefix readline)
local OPENSSL_PATH=$(brew --prefix [email protected])
export LDFLAGS="-L$READLINE_PATH/lib -L$OPENSSL_PATH/lib"
export CPPFLAGS="-I$READLINE_PATH/include -I$OPENSSL_PATH/include"
export PKG_CONFIG_PATH="$READLINE_PATH/lib/pkgconfig:$OPENSSL_PATH/lib/pkgconfig"
@dr5hn
dr5hn / composer.sh
Created September 3, 2021 11:33
Install composer v1.x and v2.x simultaneously
#!/bin/sh
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
@dr5hn
dr5hn / functions.php
Created September 3, 2021 11:29
Disable Gutenberg in Wordpress
add_filter('use_block_editor_for_post_type', function($use_block_editor, $post_type){
return in_array($post_type, []);
}, 10, 2);
add_action( 'wp_enqueue_scripts', function(){
wp_dequeue_style( 'wp-block-library' );
}, 100 );
@dr5hn
dr5hn / functions.php
Created September 3, 2021 10:07
Remove default Wordpress admin dashboard widgets
/**
* Remove Unwanted Dashboard Widget
*/
function remove_dashboard_meta()
{
// remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' ); // Activity
remove_meta_box('dashboard_primary', 'dashboard', 'normal'); // WordPress News
remove_meta_box('dashboard_quick_press', 'dashboard', 'side'); // Quick Draft
// remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); // At a Glance
remove_meta_box('dashboard_site_health', 'dashboard', 'normal'); // Site Health
@dr5hn
dr5hn / functions.php
Created September 2, 2021 06:57
How To Disable Widget Block Editor In WordPress 5.8+
// Ref: https://wpcodeus.com/disable-widget-block-editor-in-wordpress-5-8/
/**
* Disable Default Lazy Loading In WordPress
* In order to disable widget block editor in WordPress by default,
* you need to add the following code into your themes functions.php file.
*/
// Disables the block editor from managing widgets in the Gutenberg plugin.
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' );
@dr5hn
dr5hn / cryptography.js
Created November 11, 2020 07:47
Encrypt and Decrypt file and text using cypto-js
const fs = require('fs');
const crypto = require('crypto');
// Generated pair of public & private keys
const cryptoPubKey = fs.readFileSync('public.pem');
const cryptoPriKey = fs.readFileSync('private.pem');
const algorithm = 'aes-256-cbc';
module.exports = {
async fileEncryption (file) {
return new Promise(function (resolve) {
@dr5hn
dr5hn / csv_remove_column.py
Last active August 21, 2024 09:48
Delete column(s) from very large CSV file using pandas [How to delete columns in a CSV file?]
# Source: https://stackoverflow.com/questions/38149288/delete-columns-from-very-large-csv-file-using-pandas-or-blaze
# pip3 install pandas
import pandas as pd
cols_to_keep = [
'email',
'phonenumber',
'name'
] # columns you want to have in the resulting CSV file
@dr5hn
dr5hn / sendgrid.sh
Last active September 19, 2023 09:19
Send email from bash or shell script by using SendGrid API
#!/bin/bash
#-----------------------------
# REFERENCES
# https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html
# https://sendgrid.com/docs/for-developers/sending-email/curl-examples/
# https://sendgrid.com/docs/API_Reference/Web_API_v3/How_To_Use_The_Web_API_v3/errors.html
#-----------------------------
SUBJECT="🗄️ Backup Reports";