Skip to content

Instantly share code, notes, and snippets.

View pantsarny's full-sized avatar

Aliaksandr Pantsarny pantsarny

View GitHub Profile
@wtmujeebu
wtmujeebu / functions.php
Last active July 7, 2024 10:55
Speed up WP insert post by removing all post insert actions
<?php // Please do not copy this line
add_action('admin_init', 'wt_remove_all_post_insert_actions');
function wt_remove_all_post_insert_actions() {
$actions = array(
'save_post_product', // WooCommerce product insert
'wp_insert_post',
'save_post',
@keithrozario
keithrozario / on_delete.yml
Last active July 26, 2024 21:15
Get branch name on branch delete github actions
name: Serverless Delete example
on:
delete:
branches:
- actions-**
# Specify what jobs to run
jobs:
deploy:
@in4in-dev
in4in-dev / perfect.php
Last active January 7, 2024 12:39
PHP VK audio unmask (decode extras)
<?php
//(js -> php) code. letter by letter
global $n, $i, $id;
$n = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/=";
$id = 12345; //YOUR USER ID
$i = [
'v' => function($e) {
return strrev($e);
@rolinger
rolinger / gist:d6500d65128db95f004041c2b636753a
Last active April 2, 2024 03:54
PHP => FCM Push notification tutorial for Android and iOS
Below is a full tutorial on how to setup and use Googles Firebase push notification API for both Android and iOS. It is based on this
earlier implementation of Googles GCM method: https://gist.github.com/prime31/5675017 - FCM is the new method and GCM will eventually be
retired.
## THE BELOW METHOD IS THE NEWER FCM METHOD:
Register your app in the FCM Console: https://console.firebase.google.com (add project)
1. Click on the newly added project, in the upper left menu is the "Overview" and Gear Settings.
2. Click on the GEAR settings icon, and then on "Project Settings"
3. In the main screen, click on "Cloud Messaging"
@miya0001
miya0001 / cors-for-the-wordpress-rest-api.php
Last active January 31, 2023 07:42
CORS for the WordPress REST API
<?php
function my_customize_rest_cors() {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: GET' );
header( 'Access-Control-Allow-Credentials: true' );
header( 'Access-Control-Expose-Headers: Link', false );
@adzhurinskij
adzhurinskij / Documentation.md
Last active December 16, 2023 07:26
The fastest sync directory over ssh with tar

The fastest sync directory over ssh with tar

It's simple command for transfer a large number of small files over ssh.

You need to first go to directory, if you want to copy content of directory.

cd /var/www
tar cpf - ./ | ssh <user>@<dest_ip> "tar xpf - -C /var/www"

Preview speed copy with pv:

@asika32764
asika32764 / mysql-rand-between-two-values.sql
Created August 16, 2014 07:41
Mysql Rand() between 2 values
ROUND((RAND() * (max-min))+min)
@plentz
plentz / nginx.conf
Last active November 16, 2024 14:10
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@purplefish32
purplefish32 / ssh-tar
Created March 9, 2012 14:39
Compress and copy via SSH using TAR
#Compress and copy via SSH using SCP and TAR
tar -czf - /some/file | ssh [email protected] tar -xzf - -C /destination
#Switch -c for tar creates an archive and -f which tells tar to send the new archive to stdout.
#The second tar command uses the -C switch which changes directory on the target host. It takes the input from stdin. The -x switch extracts the archive.
#The second way of doing the transfer over a network is with the -z option, which compresses the stream, decreasing time it will take to transfer over the network.
#Some people may ask why tar is used, this is great for large file trees, as it is just streaming the data from one host to another and not having to do intense operations with file trees.
#If using the -v (verbose) switch, be sure only to include it on the second tar command, otherwise you will see double output.
#Using tar and piping can also be a great way to transfer files locally to be sure that file permissions are kept correctly
@kirkegaard
kirkegaard / dumpoverssh.sh
Created December 20, 2010 11:33
pipe a mysql dump through gzip and send it over ssh
mysqldump -u MYSQL_USERNAME -p YOUR_DATABASE | gzip -c | ssh USERNAME@YOUR_TO_HOST 'cat > ~/dump.sql.gz'