Skip to content

Instantly share code, notes, and snippets.

View DmitriyRF's full-sized avatar

Dmitriy DmitriyRF

  • Vitebsk
View GitHub Profile
@DmitriyRF
DmitriyRF / pure-pipe.angular-optimization.ts
Created May 1, 2020 09:13
Angular detection optimization
@Pipe({
name: 'compile'
})
export class CompilePipe implements PipeTransform {
transform(value: string): string {
console.log('executed');
return btoa(value);
}
}
@DmitriyRF
DmitriyRF / local-pull-request.md
Last active August 5, 2019 15:11
How to fetch/checkout/pull remote pull/merge-request to local repository

Locate the section for your Bitbucket Server remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@<your repo url>

Now add the line fetch = +refs/pull-requests/*/from:refs/remotes/origin/pull-requests/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@DmitriyRF
DmitriyRF / wordpress-remove-post-type-slug
Created July 8, 2019 17:15
Remove the Post Type Slug from a Custom Post Type post's URL
<?php
/**
* Remove the slug from published post permalinks. Only affect our CPT though.
*/
function wpex_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( 'portfolio' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
@DmitriyRF
DmitriyRF / index.js
Last active February 27, 2019 22:08
Counter number for page when element gets visible
<script>
var DURATION = 3500;
var elementClassName = 'countUp';
function countEventFunc(event) {
var start = Date.now();
this.step = function () {
var progress = Date.now() - start;
@DmitriyRF
DmitriyRF / enqueue.php
Last active November 28, 2018 00:15
Work with WordPress enqueue register dependencies / print
<?php
// wp_head start after wp_enqueue_scripts hook
add_action('wp_head', 'get_enqueue_process_list');
function get_enqueue_process_list()
{
print_r( formaspace_print_scripts_styles() );
}
function formaspace_print_scripts_styles()
@DmitriyRF
DmitriyRF / index.php
Created July 21, 2018 20:43
Query for custom post type, wordpress, Query,
<?php
get_header();
$the_query = new WP_Query( array( 'post_type' => 'posttype' ) );
// The Loop
if ( $the_query->have_posts() ) {
@DmitriyRF
DmitriyRF / functions.php
Last active July 11, 2018 08:41
Remove all style and scripts for template page in wordpress
//If is loading current page template
if ( is_page_template( 'page-templates/template.php' ) ) {
global $wp_scripts;
global $wp_styles;
$styles_to_keep = array("wp-admin", "admin-bar", "dashicons", "open-sans", "avia-popup-css");
// loop over all of the registered scripts
@DmitriyRF
DmitriyRF / script.js
Created June 19, 2018 13:55
Standard js wrapper
"use strict";
document.addEventListener("DOMContentLoaded", function(event){
// - Code to execute when all DOM content is loaded.
// - including fonts, images, etc.
});
window.addEventListener('load', function() {//Update March 2017
@DmitriyRF
DmitriyRF / function.php
Created June 4, 2018 22:40
Send mail with mailgun api by PHP CURL.
<?php
define('MAILGUN_URL', 'https://api.mailgun.net/v3/DOMAIN_NAME');
define('MAILGUN_KEY', 'KEY');
function sendmailbymailgun($to,$toname,$mailfromname,$mailfrom,$subject,$html,$text,$tag,$replyto){
$array_data = array(
'from'=> $mailfromname .'<'.$mailfrom.'>',
'to'=>$toname.'<'.$to.'>',
'subject'=>$subject,
'html'=>$html,
'text'=>$text,
@DmitriyRF
DmitriyRF / mc-API-connector.php
Created May 18, 2018 08:11
MailChimp API v3.0 PHP cURL example author actuallymentor
<?php // actuallymentor ?>
<?php
$action = $_POST["action"];
$email = $_POST["email"];
$fname = $_POST["fname"];
$interest = $_POST["interest"];
$debug = isset($_POST["debug"])?$_POST["debug"]:0;
$apikey = YOURAPIKEY;
$listid = $_POST["listid"];