Skip to content

Instantly share code, notes, and snippets.

View davutg's full-sized avatar
🎯
Focusing

Davut GÜRBÜZ davutg

🎯
Focusing
View GitHub Profile
@davutg
davutg / escapeHtmlTagFilter.js
Last active November 1, 2016 19:18
Escape html tags filter for angular 1.x
myApp.filter('escapeHtml', function () {
var entityMap = {
"&": "&",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;'
};
@davutg
davutg / onEnterDirective.js
Created November 1, 2016 19:17
evaluate something bound to onEnter attrib on enter
myApp.directive('onEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.onEnter);
});
event.preventDefault();
@davutg
davutg / moveItIfZeroByte
Created September 26, 2017 10:10
Move 0 byte files to another directory, helpful gist for folder integrations
for %%i in (*.txt) do (
echo %%i %%~z%i
if %%~z%i LSS 1 (
echo.move %%i
move "%%i" "C:\EmptyFiles\%%i"
)
)
@davutg
davutg / SQL_ConnectBy_StartWith
Created March 15, 2018 14:03
Hierarchical query with Connect by
SELECT *
FROM tree t, item m
WHERE M.ID = RT.PARENTID
CONNECT BY PRIOR t.parentid = t.childid
START WITH t.chilid = 123456789
ORDER BY T.PARENTID
@ECHO ON
FOR /F "tokens=5" %%T IN ('netstat -a -n -o ^| findstr ":8081" ') DO (
SET /A ProcessId=%%T)
If not defined ProcessId (call 8081.bat) else (echo %date% %time% AlreadyRunning PID %ProcessId%)
@davutg
davutg / installXrdp_ubuntu.sh
Created February 9, 2022 09:07
Install xrdp/xfce4 on ubuntu
ssh username@your_server_ip
sudo apt-get update
sudo apt-get install xrdp
sudo apt-get install xfce4
#Optional
sudo apt-get install xfce4-terminal
sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n xfce-session \n' /etc/xrdp/startwm.sh
sudo adduser xrdp ssl-cert
sudo adduser 'username' ssl-cert
sudo ufw allow 3389/tcp
@davutg
davutg / Auto_restart.bat
Created May 21, 2023 13:03
windows batch script for automatically restarting a process when a certain port is not attached to any process
@ECHO OFF
FOR /F "tokens=7 delims=: " %%G in ('netstat -ano ^| findstr 48823') DO SET PID=%%G
IF [%PID%]==[] (goto kill_pid) ELSE (ECHO "A process is already running with the ID: " %PID% && goto check_status)
:kill_pid
for /f "usebackq tokens=1" %%A in (`wmic process where "CommandLine like '%%ABC_PROCESS%%'" get ProcessId`) do taskkill /f /PID %%A
ECHO %DATE% %TIME% ABC_PROCESS process restarted >> RESET_LOG.txt
goto start_new
goto:eof