Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄

MC Naveen mcnaveen

🦄
View GitHub Profile
@mcnaveen
mcnaveen / main.yml
Last active Jun 22, 2022
Scheduled Netlify Build with GitHub Actions
View main.yml
# .github/workflows/main.yml
name: Trigger Netlify Build
on:
schedule:
# Run at 0000 daily
- cron: '0 0 * * *'
jobs:
build:
name: Request Netlify Webhook
@mcnaveen
mcnaveen / index.php
Created Jun 6, 2022
Hide Payment gateway based on selected country
View index.php
<?php
add_filter( 'woocommerce_available_payment_gateways', 'mcnaveen_payment_gateway_based_on_country' );
function mcnaveen_payment_gateway_based_on_country( $available_gateways ) {
if ( is_admin() ) return $available_gateways;
if ( WC()->customer->get_billing_country() !== 'IN' ) {
unset( $available_gateways['wc-razorpay'] );
} else {
if ( WC()->customer->get_billing_country() === 'IN' ) {
unset( $available_gateways['stripe'] );
@mcnaveen
mcnaveen / script popup.js
Last active May 28, 2022
Autofill popup fields - personalizery
View script popup.js
<script type="text/javascript">
function personalizeryInit() {
let params = new URL(document.location).searchParams;
let name = params.get("firstname");
let email = params.get("email");
document.querySelector("#form-field-field_8fd15b6").value = name;
document.querySelector("#form-field-email").value = email;
}
personalizeryInit();
</script>
@mcnaveen
mcnaveen / script.js
Created May 28, 2022
Autofill Form with Personalizery
View script.js
<script type="text/javascript">
function personalizeryInit() {
let params = new URL(document.location).searchParams;
let name = params.get("firstname");
let email = params.get("email");
document.querySelector("#form-field-name").value = name;
document.querySelector("#form-field-email").value = email;
}
personalizeryInit();
@mcnaveen
mcnaveen / file.js
Created Jan 29, 2022
Persist state after a page refresh in React
View file.js
const storedValueAsNumber = Number(localStorage.getItem("limit"));
const [userLimit, setUserLimit] = useState(
Number.isInteger(storedValueAsNumber) ? storedValueAsNumber : 0
);
useEffect(() => {
localStorage.setItem("limit", String(userLimit));
}, [userLimit]);
View Snow Flakes with HTML and CSS.md
<div class="snowflakes" aria-hidden="true">
  <div class="snowflake"></div>
  <div class="snowflake"></div>
  <div class="snowflake">
View replace pipe inside double quotes with comma.md

Example Text:

Hello,"Hello | World"
Hello | How are you?,

I want to replace the pipe | which is present inside the double quotes with comma ,

Here is the command to do that.

@mcnaveen
mcnaveen / mautic.conf
Created Jul 14, 2021
Nginx Configuration for Mautic (Non Docker Installation)
View mautic.conf
server {
listen 80;
server_name YOURDOMAIN NAME;
root /var/www/mautic;
listen 443 ssl http2;
listen [::]:443 ssl http2;
access_log /var/log/nginx/mautic-access.log;
error_log /var/log/nginx/mautic-error.log;
@mcnaveen
mcnaveen / script.js
Created Apr 15, 2021
Send Data from Google Forms to External API or Webhook
View script.js
function onFormSubmit(e) {
var url = "WEBHOOKURL"; //n8n WebHook URL
var Field1 = ' ';
var Field2 = ' ';
var form = FormApp.openById("FORMID"); // Copy the Form ID from the URL
var formResponses = form.getResponses();
var formResponse = formResponses[formResponses.length - 1];
var itemResponses = formResponse.getItemResponses();
View check_authorization.php
<?php
define('BOT_TOKEN', 'XXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXX'); // place bot token of your bot here
function checkTelegramAuthorization($auth_data) {
$check_hash = $auth_data['hash'];
unset($auth_data['hash']);
$data_check_arr = [];
foreach ($auth_data as $key => $value) {
$data_check_arr[] = $key . '=' . $value;