This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// Simple example (for similar situations I suggest to use sql-queries instead of js-based migrations) | |
// | |
// migrationUtils.js should be in [strapi-project]/database folder for this example. But it's up to you. | |
// Below the content of file: [strapi-project]/database/migrations/2023.01.15.correct-hotel-stars.js | |
const { prepareMigration } = require('../migrationUtils') | |
const path = require('path') | |
const migration = (knex) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const targetDir = 'D:\\FTP\\'; | |
const patternToExcludeInName = 'text_to_delete_in_name_of_dir_or_file'; | |
const fileNameToDeletePattern = 'file_to_delete_if_found' | |
const walkSync = function (dir, filelist) { | |
var files = fs.readdirSync(dir, {withFileTypes: true}); | |
filelist = filelist || []; | |
files.forEach(function (file) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// script that resize | |
// npm install -g sharp | |
// npm install -g cyrillic-to-translit-js | |
const targetWidth = 900; // null - if need to fit size by height | |
const targetHeight = null; // null - if need to fit size by width | |
const targetFolder = 'output'; | |
const withTransparentTrim = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
package_upgrade: true | |
package_reboot_if_required: true | |
runcmd: | |
- apt-get update | |
- curl -fsSL https://get.docker.com/ | sh | |
- curl -fsSL https://get.docker.com/gpg | sudo apt-key add - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lastIndexOfTwo(str, value1, value2) { | |
return Math.max(str.lastIndexOf(value1), s.lastIndexOf(value2)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deepCopy(obj) { | |
let result = {}; | |
for (var key in obj) { | |
if (typeof obj[key] === 'object') { | |
result[key] = deepCopy(obj[key]); | |
} else { | |
result[key] = obj[key]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkBraces(str) { | |
let temp = str.replace(/[^()\{\}<>[\]]/g, ''); | |
let rule = /\(\)|\[\]|\{\}|<>/g; | |
while(rule.test(temp)) { | |
temp = temp.replace(rule, ''); | |
} | |
return +(temp != ''); |