Skip to content

Instantly share code, notes, and snippets.

View yuriitaran's full-sized avatar

Yurii Taran yuriitaran

View GitHub Profile
@yuriitaran
yuriitaran / simple-iterator.js
Created January 29, 2022 13:21
Simple iterator
const myObject = {
a: 2,
b: 3,
};
Object.defineProperty(myObject, Symbol.iterator, {
enumerable: false,
writable: false,
configurable: true,
value: function () {
@yuriitaran
yuriitaran / soft-bind.js
Last active January 25, 2022 20:13
soft (weak) bind in JS
if (!Function.prototype.softBind) {
Function.prototype.softBind = function(obj) {
var fn = this,
curried = [].slice.call(arguments, 1),
bound = function bound() {
return fn.apply(
!this ||
(typeof window !== 'undefined' && this === window) ||
(typeof global !== 'undefined' && this === global)
? obj
@yuriitaran
yuriitaran / add-multiple-ssh-keys.md
Last active January 25, 2022 20:09
Add multiple ssh keys
@yuriitaran
yuriitaran / strong-password-regex.md
Created December 13, 2020 22:40 — forked from arielweinberger/strong-password-regex.md
Strong password Regular Expression - NestJS Course
  • Passwords will contain at least 1 upper case letter
  • Passwords will contain at least 1 lower case letter
  • Passwords will contain at least 1 number or special character
  • There is no length validation (min, max) in this regex!

Regular expression for JavaScript:

/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
@yuriitaran
yuriitaran / installing-postman.md
Last active September 5, 2020 20:15 — forked from ba11b0y/installing-postman.md
Installing Postman on Ubuntu/Gnome

Since Chrome apps are now being deprecated. Download postman from https://dl.pstmn.io/download/latest/linux

Although I highly recommend using a snap

sudo snap install postman

Installing Postman

tar -xzf Postman-linux-x64-5.3.2.tar.gz
{"version":1,"resource":"file:///mnt/5d1e8061-6874-4f8c-9799-b829cc414ff9/_garbage/google/batch/batch-response.js","entries":[{"id":"r4jf.js","timestamp":1654792627530},{"id":"CG9n.js","timestamp":1654792643818},{"id":"wqVL.js","timestamp":1654792864128},{"id":"mrxv.js","timestamp":1654792885496},{"id":"3h54.js","timestamp":1654796026058},{"id":"SMA9.js","timestamp":1654796040702},{"id":"OrZ2.js","timestamp":1654797175740},{"id":"JmBw.js","timestamp":1654814162439},{"id":"7F4E.js","timestamp":1655415384180}]}
// Attaching a new function toShortFormat() to any instance of Date() class
Date.prototype.toShortFormat = function() {
const months = ["Jan","Feb","Mar", "Apr","May","Jun", "Jul","Aug","Sep", "Oct","Nov","Dec"];
const day = this.getDate();
const monthIndex = this.getMonth();
const year = this.getFullYear();
return "" + day + "-" + months[monthIndex] + "-" + year;
/*
* Add SVG to allowed file uploads
*/
add_filter( 'upload_mimes', function ( $mimes = array() ) {
// allow SVG file upload
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
});
@yuriitaran
yuriitaran / gist:f885b4c5e7b165dea84e599a448a1fbf
Last active April 20, 2019 18:19
WP: remove Visual Composer scripts from front-end
add_action('wp_print_scripts', function () {
wp_deregister_script('wpb_composer_front_js');
wp_dequeue_script('wpb_composer_front_js');
}, 100);
@yuriitaran
yuriitaran / gist:cf21203245ac19b22918635a48d6b38b
Created December 5, 2018 22:22
Opencart get all language variables in controller
$data = $this->load->language('module/latest');