Skip to content

Instantly share code, notes, and snippets.

View iRajatDas's full-sized avatar
🎯
Focusing

Rajat Das iRajatDas

🎯
Focusing
View GitHub Profile
@iRajatDas
iRajatDas / sync_acf_post_title.php
Created August 25, 2022 05:32 — forked from rveitch/sync_acf_post_title.php
Update WordPress post title from an ACF field value on save. (Advanced Custom Fields)
<?php
/**
* Update Post Title from an ACF field value on post save.
*
* Triggers on save, edit or update of published posts.
* Works in "Quick Edit", but not bulk edit.
*/
function sync_acf_post_title($post_id, $post, $update) {
$acf_title = get_field('my_acf_field_name', $post_id); // NOTE: enter the name of the ACF field here
@iRajatDas
iRajatDas / wp-config.php
Created December 7, 2022 08:30 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@iRajatDas
iRajatDas / primary_category.php
Created December 7, 2022 08:41 — forked from jawinn/primary_category.php
Display Primary Category (Yoast's WordPress SEO)
<?php
/**
* Get the Yoast primary category from its post meta value, and displays it, with HTML markup.
* If there is no primary category set, it displays the first assigned category.
*
* @param boolean $useCatLink Whether to link the category, if it exists
* @return void
*/
function yourtheme_display_yoast_primary_category( $useCatLink = true ) {
@iRajatDas
iRajatDas / dosu.php
Created December 31, 2022 06:16 — forked from karthikax/dosu.php
PHP Download file to server from URL
<html>
<p style="width: 70%;margin: auto;margin-top: 5%;font-size:larger;text-align:center">
Download a file from any URL</p>
<form method="post" style="width: 70%;margin: auto;margin-top: 10%;">
<input name="url" size="50" placeholder="Source URL" style="width: 100%;height: 10%;font-size: 1.5em;padding:10px" required>
<input name="submit" type="submit" value="Download" style="width: 30%;height: 10%;margin: 5% auto; display: block;">
<p style="width: 70%;margin: auto;margin-top: 10%;font-size:larger;text-align:center">
To <?php echo getcwd(); ?></p>
<p style="width: 70%;margin: auto;font-size: smaller;text-align: center;position: fixed;bottom: 0;background: #fff;">
Powered by: <a href="https://karthikbhat.net/portfolio" target="_blank" style="color:#f60;text-decoration:none;">Karthik</a></p>
@iRajatDas
iRajatDas / SplitText3.min.js
Created December 3, 2023 14:21 — forked from nicubarbaros/SplitText3.min.js
SplitText from GSAP - not commercial use
/* eslint-disable */
!(function(D, u) {
"object" == typeof exports && "undefined" != typeof module
? u(exports)
: "function" == typeof define && define.amd
? define(["exports"], u)
: u(((D = D || self).window = D.window || {}));
})(this, function(e) {
"use strict";
var v = "";
@iRajatDas
iRajatDas / googleMaps.js
Created January 5, 2024 05:06 — forked from adrianhorning08/googleMaps.js
Scrape Google Maps
import * as cheerio from "cheerio";
import puppeteerExtra from "puppeteer-extra";
import stealthPlugin from "puppeteer-extra-plugin-stealth";
import chromium from "@sparticuz/chromium";
async function searchGoogleMaps() {
try {
const start = Date.now();
puppeteerExtra.use(stealthPlugin());
@iRajatDas
iRajatDas / react-intl.tsx
Created April 8, 2024 07:40
react telephone input
import "@/src/styles/intl-react.css";
import React, { useRef, useEffect } from "react";
import intlTelInput, { Iti, SomeOptions } from "intl-tel-input";
const IntlTelInput = ({
initialValue = "",
onChangeNumber = (): void => {},
onChangeCountry = (): void => {},
onChangeValidity = (): void => {},
onChangeErrorCode = (): void => {},
:root {
--iti-hover-color: rgba(0, 0, 0, 0.05);
--iti-text-gray: #999;
--iti-border-gray: #ccc;
--iti-spacer-horizontal: 8px;
--iti-flag-height: 15px;
--iti-flag-width: 20px;
--iti-border-width: 1px;
--iti-arrow-height: 4px;
--iti-arrow-width: 6px;
import "@/styles/react-intl.css"
import React, { useState, ReactElement } from "react";
import { createRoot } from "react-dom/client";
import IntlTelInput from "../src/intl-tel-input/react";
import utilsScriptURL from "intl-tel-input/build/js/utils";
const errorMap = [
"Invalid number",
"Invalid country code",
"Too short",