Skip to content

Instantly share code, notes, and snippets.

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

Yılmaz Durmaz yilmazdurmaz

🏠
Working from home
  • Turkey
View GitHub Profile
@yilmazdurmaz
yilmazdurmaz / Weblate_Simple_Change_Highlighter.js
Last active November 18, 2023 18:22
Weblate Simple Change Highlighter
'use strict';
// ==UserScript==
// @name Weblate Simple Change Highlighter
// @description On Weblate, while checking a translation, highlight the editbox if you make any changes.
// @version 0.2
// @license MIT
// @author Yılmaz Durmaz
// @namespace https://gist.github.com/yilmazdurmaz
// @match https://hosted.weblate.org/translate/*/*/*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=weblate.org
@yilmazdurmaz
yilmazdurmaz / #JS-Modules-in-HTML-and-Nodejs
Created May 26, 2023 04:47
Use same Javascript module in both HTML and Node.js
#JS-Modules-in-HTML-and-Nodejs
@yilmazdurmaz
yilmazdurmaz / c99.l
Created February 21, 2023 10:38 — forked from codebrainz/c99.l
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>
@yilmazdurmaz
yilmazdurmaz / iptables_forward_to_hostname.md
Created November 15, 2022 01:38 — forked from rikka0w0/iptables_forward_to_hostname.md
Add/Update iptable NAT port forward rule based on hostname instead of ip address
#!/bin/bash

HostName=
PortListen=
PortTarget=

IPv4=$(ping -c1 $HostName | grep "bytes of data" | cut -d "(" -f2 | cut -d ")" -f1)
echo $IPv4
// ==UserScript==
// @name BlockAdblock Blocker
// @version 1.0
// @namespace http://tampermonkey.net/
// @description Blocks block-adblock
// @match *://**/*
// @grant none
// @run-at document-start
// ==/UserScript==
@yilmazdurmaz
yilmazdurmaz / convert-array-to-object.js
Created September 8, 2022 14:48
convert an array of data to an object with given field names
let fields= [ "id", "name" ]
let data=[
[ 1, 'ali' ],
[ 2, 'veli' ],
[ 3, 'deli' ]
]
let res=[]
@yilmazdurmaz
yilmazdurmaz / startstoppostgres.bat
Created August 8, 2022 14:03
start/stop postgresql server in windows with a simple batch file
:: postgresql is extracted into "d:\pgsql\" and data is init at "d:\pgsql\pgdata"
:: d:\pgsql\bin\initdb -D d:\pgsql\pgdata -U postgres -W -E UTF8 -A scram-sha-256
:: find postres instances running on our data folder
wmic.exe path Win32_Process where name="postgres.exe" get Commandline /format:list | find "d:/pgsql/pgdata" > null
:: stop is already running, and start if not
if errorlevel 1 (d:\pgsql\bin\pg_ctl -D d:\pgsql\pgdata -l logfile start) else (d:\pgsql\bin\pg_ctl -D d:\pgsql\pgdata -l logfile stop)
@yilmazdurmaz
yilmazdurmaz / for-of-array-of-promise.js
Last active May 31, 2022 13:41
for of array of promise
let a=[10,20,30,40]
let getit=async(ax,ix,arr)=>{
//console.log(ax,ix,arr)
let time=Math.random()*3000;
let ret=Math.random()>0.3;
console.log(ix,arr[ix],time,ret);
return new Promise((res,rej)=>{
setTimeout(()=>{
if (ret) {
@yilmazdurmaz
yilmazdurmaz / servewasm.py
Created May 3, 2022 10:31 — forked from prideout/servewasm.py
Python WASM server
#!/usr/bin/env python3
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
Handler.extensions_map.update({
'.wasm': 'application/wasm',
@yilmazdurmaz
yilmazdurmaz / clear browser history in history page.js
Created December 30, 2021 08:09
clear browser history in history page
// open history page of the browser
// open dev tools and get to console
// set sleep function and the use for loop
// change "getelements..." queries if needed
// note that it is not intended to clear thing other than history
// sleep function from https://stackoverflow.com/a/951057/9512475
// sleep time expects milliseconds
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));