Skip to content

Instantly share code, notes, and snippets.

import React, { useState, useEffect } from 'react';
const ExampleComponent = () => {
const [data, setData] = useState(null);
const [count, setCount] = useState(0);
useEffect(() => {
// Fetching data from an API
fetch('https://api.example.com/data')
.then(response => response.json())
@waqasraza123
waqasraza123 / acf_sync_with_user_profile.php
Created March 22, 2023 10:11 — forked from sabrina-zeidan/acf_sync_with_user_profile.php
When you have ACF User fields like first name and last name and you need to keep that in sync with what is entered in WordPress user profile (works both ways)
//If both changed at the same time - custom field value will be applied as it fires later, set 30 to change it add_action( 'profile_update', array($this, 'update_acf_fields'), 30, 2 );
class Sync_ACF_with_User_Profile_Class {
static public $sync_pair = array(
array( 'acf' => 'member_name', 'profile_field' => 'first_name'), //add acf field name according to your setup
array( 'acf' => 'member_lastname', 'profile_field' => 'last_name')// add more rows to sync any other fields as well
);
public function __construct() {
add_action( 'profile_update', array($this, 'update_acf_fields'), 10, 2 ); //when profile is updated -> update ACF
add_action('updated_user_meta', array($this, 'update_user_profile_fields'),10,4); // when ACF is updated -> update profile
add_action('added_user_meta', array($this, 'update_user_profile_fields'),10,4); // when ACF is added -> update profile
const myString = "Hello World";
function reverse(myString){
let reversedString = ""
for(let i=myString.length - 1; i > 5; i--){
reversedString += myString.charAt(i);
}
return reversedString;
}
https://vijayasankarn.wordpress.com/2017/02/04/securely-setting-file-permissions-for-laravel-framework/
@waqasraza123
waqasraza123 / ssh-copy-id-not-working-permission-denied-publickey
Created February 21, 2019 18:58
ssh-copy-id-not-working-permission-denied-publickey
https://www.digitalocean.com/community/questions/ssh-copy-id-not-working-permission-denied-publickey
@waqasraza123
waqasraza123 / .htaccess
Created February 7, 2019 10:35
fix-page-not-found-on-reloading-angular
<IfModule mod_rewrite.c>
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html
# to allow html5 state links
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
html, body{
min-height: 101% !important;
margin-right: 0px !important;
overflow-y: visible !important;
}
<?php
namespace App\Http\Controllers;
use GuzzleHttp\Client;
class PostsAuthController extends Controller
{
//class variables
private $sessionId;
public $curl;
public function __construct()
{