Skip to content

Instantly share code, notes, and snippets.

View benyaminl's full-sized avatar
😬
Crazy with C#

Benyamin Limanto benyaminl

😬
Crazy with C#
View GitHub Profile
@benyaminl
benyaminl / record.sh
Created April 19, 2023 13:51
Recording ffmpeg toggle from xfce keyboard map. If there are running ffmpeg for it, it will be killed.
#!/bin/sh
record=$(pgrep -a ffmpeg | grep x11grab | awk "{print \$1}" | xargs -I {} echo {})
if [ -z $record ];
then
xwininfo | {
while IFS=: read -r k v; do
case "$k" in
*"Absolute upper-left X"*) x=$v;;
*"Absolute upper-left Y"*) y=$v;;
*"Border width"*) bw=$v ;;
@benyaminl
benyaminl / Dockerfile
Created November 16, 2022 01:16
Wordpress Dev Docker File (not as git repo, because, it's simpler to be gist than repo...) This docker-compose is specified for podman version >= 4.2.0, because mapping selinux context. It's better to have SELINUX than NOT!
FROM docker.io/library/wordpress:6.0.2
# See https://www.shellhacks.com/create-csr-openssl-without-prompt-non-interactive/
RUN openssl req -new -newkey rsa:2048 -days 1095 -nodes -x509 -keyout /etc/ssl/private/wp.key -out /etc/ssl/private/wp.crt -subj "/C=ID/ST=Surabaya/L=Surabaya/O=ISTTS/OU=IT Department/CN=stts.edu"
RUN a2enmod ssl
COPY ./wp-ssl.conf /etc/apache2/sites-available/wp-ssl.conf
RUN a2ensite wp-ssl
EXPOSE 80
EXPOSE 443
@benyaminl
benyaminl / gvim-toggle.sh
Created October 15, 2022 03:06
GVIM toggle view or hide based on workspace, will start gvim if on that workspace there are no gvim. Useful to mimic AHK on Linux using WMCTRL. Tested on Fedora 36
#!/bin/bash
DESKTOP=$(wmctrl -d | grep "*" | awk --field-separator=" " '{print $1}')
STATUS=$(wmctrl -l | grep " $DESKTOP " | grep -i gvim | wc -l)
WIN=$(wmctrl -l | grep " $DESKTOP " | grep -i gvim | awk '{print $4}')
# zenity --notification --text="$STATUS $DESKTOP $WIN"
if [ $STATUS -gt 0 ]
then
activeWindow=$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | cut -d '"' -f 2)
@benyaminl
benyaminl / spotify.sh
Created October 14, 2022 06:21
Show or Hide Spotify Flatpak, can be mapped to Thinkpad X220 ThinkVantage Button on XFCE
#!/bin/bash
STATUS=$(ps -aux | grep share/spotify/spotify | grep -v grep | wc -l)
if [ $STATUS -gt 0 ]
then
activeWindow=$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | cut -d '"' -f 2)
if [[ $activeWindow =~ "Spotify" ]]
then
wmctrl -r "spotify" -b toggle,hidden
@benyaminl
benyaminl / QuickLinks.ahk
Last active October 18, 2023 18:41
QuickLinks Improvement from Jason Version, added .lnk and .url on root of QuickLinks, so we can make it faster to open folder, only one shortcut and one key press, boom opened folder
@benyaminl
benyaminl / main.py
Created March 11, 2022 05:19
Python ODBC connect to SQL Server 2008 from Windows 10 21H2
import pyodbc
# Specifying the ODBC driver, server name, database, etc. directly
con = pyodbc.connect('DRIVER={SQL Server Native Client 10.0};SERVER=127.0.0.1;PORT=1433;DATABASE=coba;UID=sa;PWD=12345')
# Using a DSN, but providing a password as well
# cnxn = pyodbc.connect('DSN=test;PWD=password')
# Create a cursor from the connection
db = con.cursor()
@benyaminl
benyaminl / remap.ahk
Last active October 30, 2021 15:11
Remaping the X220 Key for some usage like Browser back and Forward into PgUp and Down to various app, like Acrobat, Mendeley, Vim, Word, 7zip, Etc
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2 ; contain
; remap global Win+E jadi Win+1
#e::#1
;#z::#!s
; Calendar
@benyaminl
benyaminl / userChrome.css
Last active May 2, 2021 01:44
userChrome.css that remove or fix proton view on windows 10, with disabling megabar. It's originate from my works and some others from reddit /r/firefox. I hope this ease your pain on your computer views especially on old small laptop
/*** Megabar Styler General - version 2020-07-27 ***/
/*** General Preferences ***/
:root {
/* Number of pixels of enlargement when URL bar is focused */
--mbarstyler-popout-pixels: 0px; /* [0px - 7px] */
/* Top Bar Display or Not */
--mbarstyler-top-bar-display: block; /* [block,none] */
@benyaminl
benyaminl / OpenWithVim-Add.reg
Last active August 18, 2022 01:26
This's a Regedit Key for Windows that's used for adding and remove Open With Vim on Windows Folder and Background Folder, and Windows Library. This make Vim works like Opening Project in Open VS Code Functionality
REGEDIT4
[HKEY_CLASSES_ROOT\Folder\shell\VimHere]
@="Open with &Vim"
"Icon"="C:\\Apps\\vim\\gvim.exe,0"
[HKEY_CLASSES_ROOT\Folder\shell\VimHere\command]
@="\"C:\\Apps\\vim\\gvim.exe\" \"%1\""
[HKEY_CLASSES_ROOT\Directory\shell\VimHere]
@="Open with &Vim"
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<form method="post" action="">