Posts

Showing posts from August, 2023

php plugin dev

vite config export default defineConfig({   plugins: [react()],   build: {     rollupOptions: {       output: {         entryFileNames: `assets/[name].js`,         chunkFileNames: `assets/[name].js`,         assetFileNames: `assets/[name].[ext]`       }     }   } })  

WP query posts

 Find by title $args = array(             'post_per_page' => -1,             'post_type' => 'acf_webhook',             'title' => $post_type         );

Nextjs essencials

Server component query params props type type Props = {      params: {},     searchParams: { [key: string]: string | string[] | undefined }, }

PHP nested json into 1-D array

   $data = array();          flatit('',$source);          function flatit($name,$object){         global $data;         foreach($object as $key => $value){             if(is_array($value)){                 flatit($name."_".$key,$value);             }else{                  $name = $name."_".$key;                  echo $name;                  echo "\n";                  echo $value;                  echo "\n";                 $data[substr($name, 1)] = $value;             }        ...

JS random string for api key

Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);

Coinbase commerce api sample code and common errors in Node

The followings are some code relevant to the title. Create Charge A charge is something that the frontend needs to send users to the payment page. Just add the following code to your nodejs route: import CoinbaseCommerce from 'coinbase-commerce-node'; const Charge = CoinbaseCommerce.resources.Charge; CoinbaseCommerce.Client.init(process.env.COINBASE_API_KEY);  if (req.method === 'POST') {         try {             const { amount, currency, user_id,user_email} = req.body;             // create a charge             const chargeData = {                 name: 'Your Awesome Comany',                 description: 'Deposit to Your Awesome Comany',                 local_price: {                     amount,   ...

Useful powershell commands

List all environment variables ls env:\ Set environment variables $Env:NODE_ENV= "development"

MongoDB local machine connection error with nodjs (mongoose)

mongoose.connect("mongodb://localhost/test"); or mongoose.connect("mongodb://localhost:27017/test"); results in  MongooseServerSelectionError: connect ECONNREFUSED ::1:27017 Solutions use MONGOURL="mongodb://127.0.0.1/test"