Skip to content

Instantly share code, notes, and snippets.

View mhdzli's full-sized avatar
💭
The most important and daring kind of freedom is to be what you really are.

M.Zeinali mhdzli

💭
The most important and daring kind of freedom is to be what you really are.
View GitHub Profile
@mhdzli
mhdzli / install_printer
Created October 4, 2019 17:48 — forked from notdodo/install_printer
Install a printer on Arch Linux with cups using command line
#!/bin/bash
################################################################
# Install a printer on Arch Linux with cups using command line #
# Used for a HP PSC 1510 with default driver #
################################################################
sudo pacman -S cups
sudo systemctl start org.cups.cupsd
@mhdzli
mhdzli / gist:7ee8e3b25c880cc4bc6e35bfe17f52aa
Created February 15, 2020 08:55 — forked from jasonkarns/readme.md
Git send-email using Gmail
  1. Configure Gmail in you gitconfig:
[sendemail]
  smtpserver = smtp.gmail.com
  smtpserverport = 587
  smtpencryption = tls
  smtpuser = <gmail email address>
  from = <email address for From: field>
@mhdzli
mhdzli / tlp-info
Last active February 19, 2020 20:57
Asus ZenBook 14 UX410UFR 1.0
$ sudo tlp-stat -s -b
--- TLP 1.3.1 --------------------------------------------
+++ System Info
System = ASUSTeK COMPUTER INC. 1.0 ZenBook 14 UX410UFR
BIOS = UX410UFR.201
Kernel = 5.5.3-arch1-1 #1 SMP PREEMPT Tue, 11 Feb 2020 15:35:41 +0000 x86_64
/proc/cmdline = BOOT_IMAGE=/vmlinuz-linux root=UUID=805eb372-94c7-4e8c-87b4-54b0414fa84a rw loglevel=3 quiet
Init system = systemd
Boot mode = UEFI
@mhdzli
mhdzli / getxkblayout.c
Last active January 16, 2021 18:26 — forked from fikovnik/getxkblayout.c
Get keyboard layout using X11
// compile with `gcc -I/usr/include getxkblayout.c -lX11 -lxkbfile`
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBrules.h>
int main(int argc, char **argv) {
Display *dpy = XOpenDisplay(NULL);
@mhdzli
mhdzli / sway-interactive-screenshot
Last active March 1, 2020 17:36
Easy screenshots in Sway using dmenu
#!/bin/bash
# `list_geometry` returns the geometry of the focused of visible windows. You can also get they title
# by setting a second argument to `with_description`. The geometry and the title are seperated by `\t`.
#
# Arguments:
# $1: `focused` or `visible`
# $2: `with_description` or nothing
#
# Output examples:
@mhdzli
mhdzli / neoito-hub_wasp_ni.sh
Created March 4, 2020 07:19
Nativescript Installer installs nativescript for Android development on Ubuntu.
#!/usr/bin/env bash
# Synopsis : Script for installing Nativescript on Ubuntu 16.04
# config parameters
CURR_DIR="$PWD"
# Start of functions
printBanner() {
while read; do
@mhdzli
mhdzli / VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
Created March 30, 2020 07:53 — forked from Brainiarc7/VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
This gist contains instructions on setting up FFmpeg and Libav to use VAAPI-based hardware accelerated encoding (on supported platforms) for H.264 (and H.265 on supported hardware) video formats.

Using VAAPI's hardware accelerated video encoding on Linux with Intel's hardware on FFmpeg and libav

Hello, brethren :-)

As it turns out, the current version of FFmpeg (version 3.1 released earlier today) and libav (master branch) supports full H.264 and HEVC encode in VAAPI on supported hardware that works reliably well to be termed "production-ready".

@mhdzli
mhdzli / spectrbar
Last active May 18, 2020 12:28
spectrwm
#!/bin/bash
# baraction.sh for spectrwm status bar
trap 'update' 5
## DATE
dte() {
dte="$(date +"%A, %B %d %l:%M%p")"
echo -e "$dte"
}
@mhdzli
mhdzli / toggletouch
Created August 2, 2020 06:19
Toggle touchpad in sway
#!/bin/bash
TOUCHPAD_ID="$(swaymsg -t get_inputs | grep 'identifier.*Touchpad' | cut -d'"' -f4)" #give me the touchpad identifier
STATE="$(swaymsg -t get_inputs | jq .[0].libinput.send_events)" #check if touchpad is enabled
[ "$STATE" = '"enabled"' ] && swaymsg input "$TOUCHPAD_ID" events disabled || swaymsg input "$TOUCHPAD_ID" events enabled
@mhdzli
mhdzli / persianumber.js
Created September 27, 2020 05:56
persian number with javascript
<script>
$(document).ready(function () {
ConvertNumberToPersion();
});
function ConvertNumberToPersion() {
persian = { 0: '۰', 1: '۱', 2: '۲', 3: '۳', 4: '۴', 5: '۵', 6: '۶', 7: '۷', 8: '۸', 9: '۹' };
function traverse(el) {