Skip to content

Instantly share code, notes, and snippets.

View vladutilie's full-sized avatar
🇷🇴
WFH

Vlad Ilie vladutilie

🇷🇴
WFH
View GitHub Profile
@vladutilie
vladutilie / ing.payment.service.ts
Created January 8, 2021 07:24
ING API | Get token and payment initiate @nestjs
import { HttpService, Injectable } from '@nestjs/common';
import { PaymentRepository } from './payment.repository';
import { map } from 'rxjs/operators';
import fs from 'fs';
import crypto from 'crypto';
import https from 'https';
import { User } from '../user/user.entity';
import { LessThan, MoreThan } from 'typeorm';
import { INGTokenDTO } from './payment.dto';
import { PaymentCredentials } from './payment-credentials.entity';
@vladutilie
vladutilie / bt.payment.service.ts
Created January 8, 2021 07:22
BT API | Payment initiate @nestjs
import { HttpService, Injectable } from '@nestjs/common';
import { map } from 'rxjs/operators';
import { User } from '../user/user.entity';
import { BTTokenDTO, ExchangingDataDTO, MakePaymentDTO, PaymentInfoDTO, RegisterBTClientDTO } from './payment.dto';
import { v4 as uuidv4 } from 'uuid';
import sha256 from 'crypto-js/sha256';
import Base64 from 'crypto-js/enc-base64';
import qs from 'querystring';
import { PaymentRepository } from './payment.repository';
import { PaymentCredentials } from './payment-credentials.entity';
@vladutilie
vladutilie / wp-install.sh
Last active February 9, 2023 10:43
Localhost WordPress installation bash script
#!/bin/bash
read -p 'WWW directory path [/Users/vlad/www/]: ' READ_WWW_PATH
read -p 'Sitename (without no extension): ' SITENAME
read -p 'Site locale [ro_RO]: ' READ_SITE_LOCALE
WWW_PATH=${READ_WWW_PATH:='/Users/vlad/www'}
SITE_LOCALE=${READ_SITE_LOCALE:=ro_RO}
cd $WWW_PATH
@vladutilie
vladutilie / functions.php
Created June 23, 2020 11:12
Replaces Romanian diacritics from entire WordPress installation
add_filter( 'gettext', 'remove_romanian_diacritics' );
function remove_romanian_diacritics( $translation ) {
$diacritics = [ 'ă', 'â', 'î', 'ș', 'ț', 'Ă', 'Â', 'Î', 'Ș', 'Ț' ];
$replace_with = ['a', 'a', 'i', 's', 't', 'A', 'A', 'I', 'S', 'T' ];
$translation = str_replace( $diacritics, $replace_with, $translation );
return $translation;
}
@vladutilie
vladutilie / functions.php
Created April 28, 2020 07:41
Change WordPress password form post
add_filter('the_password_form', 'change_password_form_text' );
function change_password_form_text( $post = 0 ) {
$post = get_post( $post );
$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
<p>' . __( 'Here is your text:', 'textdomain' ) . '</p>
<p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>';
return $output;
}
@vladutilie
vladutilie / create-domain.sh
Last active June 15, 2021 07:13
Create local test domain on MacOS
#!/bin/bash
read -p 'Domain name (no extension): ' DOMAIN_NAME
read -p 'Domain extension [test]: ' DOMAIN_EXT
read -p 'WWW directory path [/Users/vlad/www/]: ' READ_WWW_PATH
read -p 'SSL directory path [/Users/vlad/ssl/]: ' READ_SSL_PATH
WWW_PATH=${READ_WWW_PATH:='/Users/vlad/www'}
EXTENSION=${DOMAIN_EXT:=test}
SSL_PATH=${READ_SSL_PATH:='/Users/vlad/ssl'}
@vladutilie
vladutilie / template-hooks.php
Last active November 27, 2018 15:37
Custom logo for WP Dentist, WordPress theme: replace h1 tag from wp-dentist/inc/functions/template-hooks.php with this one
<h1 id="logo">
<?php
$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
if ( has_custom_logo() ) {
echo '<a href="'. esc_url( home_url( '/' ) ) .'" title="'. esc_attr( get_bloginfo( 'name', 'display' ) ) .'" rel="home"><img src="'. esc_url( $logo[0] ) .'"></a>';
} else {
echo '<a class="navbar-brand" href="'. esc_url( home_url( '/' ) ) .'" title="'. esc_attr( get_bloginfo( 'name', 'display' ) ) .'" rel="home">'. esc_html( bloginfo('name') ) .'</a>';
}
?>