Skip to content

Instantly share code, notes, and snippets.

@turovskiy
turovskiy / api.php
Created February 20, 2025 05:36 — forked from igorbenic/api.php
How to use PHP Namespaces in WordPress Plugins | https://www.ibenic.com/php-namespaces-wordpress-plugins
<?php
namespace My_Plugin\API;
/**
* API Functions
*/
if( ! defined( 'ABSPATH' ) ) {
return;
}
@turovskiy
turovskiy / edit.js
Created February 20, 2025 05:32 — forked from igorbenic/edit.js
Gutenberg Components: ServerSideRender https://ibenic.com/gutenberg-components-server-side-render
/**
* WordPress dependencies
* https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/archives/edit.js
*/
// ... hidden code for tutorial purposes
import ServerSideRender from '@wordpress/server-side-render';
export default function ArchivesEdit( { attributes, setAttributes } ) {
const { showPostCounts, displayAsDropdown } = attributes;
@turovskiy
turovskiy / 01 - Setup Nextjs site on Ubuntu Server - Terminal commands
Created September 21, 2024 08:19 — forked from oelbaga/01 - Setup Nextjs site on Ubuntu Server - Terminal commands
Setup NextJS app on Digital Ocean Ubuntu server Full Terminal Commands Step by Step
#Setup NextJS on Ubuntu server (Digital Ocean, EC2,...) Terminal Commands
#based on my YouTube video
#Recommended: An ubuntu server with at least 2 GB memory to handle npm run build
#login to server
ssh root@ip_address
#Upgrade Server - may take a few minutes
sudo apt update
sudo apt upgrade
@turovskiy
turovskiy / submit.md
Created December 12, 2023 07:11 — forked from tanaikech/submit.md
Downloading Google Spreadsheet as XLSX and PDF file by Clicking Button

Downloading Google Spreadsheet as XLSX and PDF file by Clicking Button

This is a sample script for downloading Google Spreadsheet to the local PC as a XLSX file and a PDF file when a button on the side bar and the dialog is clicked. This is created with Google Apps Script and HTML&Javascript.

Sample script

Please create new Google Spreadsheet and copy and paste the following scripts to the script editor. And please run openSidebar(). By this, the side bar is opened to the Spreadsheet.

@turovskiy
turovskiy / README.md
Created December 4, 2023 13:20 — forked from manzoorwanijk/README.md
Google Script to bypass the blockage of Telegram Bot API from by webhost

WPTelegram Google Script

You can use this script to bypass the bans on Telegram API by different hosts. Simply send the request to this script instead of the Telegram Bot API after deploying it as a web app and allowing anonymous access.

Params

It accepts bot GET and POST requests with the following params

name type Description

Frameworks like React require that when you change the contents of an array or object you change its reference. Or push another way that you don't change arrays but instead create new arrays with updated values (i.e. immutability).

There are older array methods that are incompatible with immutability because they alter the array in place and don't change the array reference. These are mutable (or destructive) methods.

Shown below are replacements for the array destructive methods (e.g. push, pop, splice, sort, etc.) that will create new array references with the updated data.

Solutions are provided using the spread operator and also the newer "change array by copy" methods (toSpliced, toSorted, toReversed and with).

Setting Value At Index

@turovskiy
turovskiy / interval.hook.ts
Created October 12, 2023 05:28 — forked from Danziger/interval.hook.ts
✨ Declarative useTimeout (setTimeout), useInterval (setInterval) and useThrottledCallback (useCallback combined with setTimeout) hooks for React (in Typescript)
import React, { useEffect, useRef } from 'react';
/**
* Use setInterval with Hooks in a declarative way.
*
* @see https://stackoverflow.com/a/59274004/3723993
* @see https://overreacted.io/making-setinterval-declarative-with-react-hooks/
*/
export function useInterval(
callback: React.EffectCallback,
@turovskiy
turovskiy / 1-easy.js
Created August 15, 2023 00:09 — forked from elclanrs/1-easy.js
3 examples of using Async Generators and Async Iteration in JavaScript!
// Create a Promise that resolves after ms time
var timer = function(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
// Repeatedly generate a number starting
// from 0 after a random amount of time
var source = async function*() {
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@turovskiy
turovskiy / dabblet.css
Last active May 6, 2020 20:53 — forked from csssecrets/dabblet.css
Diamond images — via transforms
/**
* Diamond images — via transforms
*/
.diamond {
width: 250px;
height: 250px;
transform: rotate(45deg);
overflow: hidden;
margin: 100px;