Skip to content

Instantly share code, notes, and snippets.

View malipetek's full-sized avatar
🏠
Working from home

muhammet ali petek malipetek

🏠
Working from home
View GitHub Profile
@malipetek
malipetek / translate.svg
Created December 9, 2023 07:40
translatesvg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Convert this script from jquery to vanilla js. Be careful about null scenarios, for example when you convert $('.class').show() to document.querySelector('.class').style.display = 'block' keep in mind result of querySelector might be null. I solve this issue like this: (document.querySelector('.class') || { style: {}}).style.display = 'block'
Also use fetch and es6 as much as you can.
Do not make any explanations, only try to convert and comment the parts you think can not be converted easily.
Here is the script:
(() => {
Array.from(document.querySelectorAll('.description textarea')).forEach(tx => {
tx.value = tx.value.replace(/(.+)petek:(.+)/, '$2 $1petek')
.replace(/^\s*([^\[\s]+)\s/, '[$1] ');
});
const spaces = {};
let total = 0;
Array.from(document.querySelectorAll('#invoice_item_rows>tr')).forEach(row => {
const description = row.querySelector('textarea').value;
const identifier = description.match(/\[[^\]]+\]/)[0].split('-')[0].replace('[', '');
@malipetek
malipetek / CHATEAU_MEAUME.sol
Created November 30, 2022 07:52
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.17+commit.8df45f5f.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts@4.6.0/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@4.6.0/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts@4.6.0/security/Pausable.sol";
import "@openzeppelin/contracts@4.6.0/access/Ownable.sol";
import "@openzeppelin/contracts@4.6.0/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts@4.6.0/utils/Counters.sol";
import "@openzeppelin/contracts@4.6.0/token/ERC721/extensions/ERC721URIStorage.sol";
@malipetek
malipetek / video_overlay.css
Created November 1, 2022 19:05
Video overlay for hiding pixelation on webpages
video-container {
position: relative;
}
.video-container:after {
display: block;
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
@malipetek
malipetek / turkishStemmer.js
Created May 18, 2022 02:06
Turkish Stemmer extracted from snowballstem.org demo
window.turkishStemmer = function() {
var g = true;
var p = false;
function C() {
this.p = function(k) {
this.j = k;
this.cursor = 0;
this.a = this.j.length;
this.f = 0;
@malipetek
malipetek / JSONparse.js
Last active March 11, 2022 03:40
JSON parse with error visualization
function JSONparse (content) {
try{
return JSON.parse(content);
} catch (err) {
try {
const offset = parseInt(err.message.match(/position\s+(\d+)/)[1], 10);
const linesUntilError = content.slice(0, offset + 1).split('\n');
const errorLine = linesUntilError.length;
const contentLines = content.split('\n');
const lineOffset = linesUntilError[linesUntilError.length - 1].length - 1;
@malipetek
malipetek / prune-shopify-schema.md
Last active September 27, 2021 13:40
multi language schema is great but my client does not need it, I wanted to remove it to declutter section schema

open vscode paste following to find and replace, enable regexp and execute replace all, then execute second one

find: "(name|label|default|category)":\s\{\n(\s*"(?!en).+":\s*".+",?)+

replace: "$1": {

find:

@malipetek
malipetek / new-york-state-zip-codes-regex.js
Created January 25, 2020 11:05
new york state zip codes regex
/* source of zip codes is this: https://www.zipcodestogo.com/New%20York/
and automatically generated with regexgen npm module: https://npm.runkit.com/regexgen */
const nyreg = '/1(?:4(?:8(?:9[1-578]|3[016-9])|7(?:8[1-8]|7[02457-9]|6[0679]|0[126-9])|6(?:9[24]|3[89])|5(?:8[05689]|7[12]|6[013489]|0[24-8])|4(?:[78][0-25-9]|5[02-46]|4[1359]|3[02357]|1[013-68])|86[013-579]|2(?:7[0236]|6[013-579])|1(?:4[013-5]|2[05-79]|0[1-357-9])|0(?:9[12458]|8[0-356]|7[025]|0[14-689])|71[0-24-9]|46[1-46-9]|74[0-578]|60[2-9])|3(?:8(?:5[0169]|2[05-7])|7(?:9[04-7]|7[4-8])|6(?:[56][0-24-9]|0[1-35-8])|80[1-46-9]|4(?:8[02-689]|6[014589]|5[024-79]|4[0-29]|3[135-9]|2[014-68]|1[0135-8]|0[1-46-9])|3(?:6[0-578]|5[02-57]|4[0-3568]|3[1-57-9]|0[1-589])|2(?:2[0145]|1[0-2457-9])|1(?:5[2-9]|2[0-46]|0[1-478])|0(?:9[023]|5[1-467]))|423[13]|455[015-9]|307[1-46-8]|(?:488|3(?:69|03))[0-79]|308[0-47-9]|4(?:24|15)[01]|316[02-7]|402[014-9]|(?:4(?:87|72)|373)[0-46-9]|464[2-79]|484[0-35-7]|(?:442|383)[02-57-9]|2(?:9(?:9[235-8]|8[0135-79]|5[0235-9]|3[02-79]
@malipetek
malipetek / dark-slack.css
Last active November 24, 2019 04:59
Slack Dark CSS
body { background: #222; color: #e6e6e6; }
a { color: #949494; }
a:link, a:visited { color: #949494; }
a:hover, a:active, a:focus { color: #c7c7c7; }
hr { border-bottom: 1px solid #424242; border-top: 1px solid #222; }