Skip to content

Instantly share code, notes, and snippets.

View msafadieh's full-sized avatar

Mohamad Safadieh msafadieh

View GitHub Profile
@msafadieh
msafadieh / daytime.py
Created October 30, 2020 08:06
find out if it's daytime using GPS coordinates and no external libraries
"""
small function needed for a personal project of mine
"""
from datetime import datetime, timezone
import json
from urllib.parse import urlencode
from urllib.request import urlopen
# lat and lng can be int, float, or strings. wooo dynamic typing!
def is_daytime(lat, lng):

Keybase proof

I hereby claim:

  • I am msafadieh on github.
  • I am mhmdsh (https://keybase.io/mhmdsh) on keybase.
  • I have a public key whose fingerprint is 46AD A27B 4FB7 40ED 5744 BFAB 66F5 4D5A 6363 5432

To claim this, I am signing this object:

#! /bin/sh
tree="$(i3-msg -t get_tree)"
if echo "$tree" | grep '"scratchpad"'; then
if echo "$tree" | jq '.nodes[0]' | grep Alacritty; then
i3-msg "scratchpad show"
else
i3-msg '[instance="scratchpad"] move scratchpad'
fi
@msafadieh
msafadieh / pleroma_auth
Last active June 14, 2020 20:46
authenticate prosody using pleroma
#! /usr/bin/env python3
from urllib.error import URLError
from urllib.parse import urlencode
from urllib.request import urlopen
PLEROMA_SERVER = "https://otherground.party"
DELIMITER = ":"
API = {
"auth": ("/check_password", {"user": 0, "pass": 2}),
"isuser": ("/user_exists", {"user": 0}),
@msafadieh
msafadieh / zoom-web-client-auto-redirect.user.js
Last active September 23, 2021 21:41
User script that redirects Zoom meeting links to the web client automatically
// ==UserScript==
// @name Zoom Web Client Auto Redirect
// @namespace https://zoom.us
// @version 0.1
// @description Automatically redirect Zoom meetings to the web client
// @author Mohamad Safadieh
// @license GNU AGPLv3: https://www.gnu.org/licenses/agpl-3.0.en.html
// @include /https:\/\/([a-z0-9\-]+\.)?zoom\.us\/([sj])\/([0-9]+).*/
// @grant none
// ==/UserScript==
@msafadieh
msafadieh / gof.py
Last active March 23, 2020 14:37
Implementation of conway's game of life using Python and ncurses
#!/usr/bin/env python
# pylint: disable = C0103, C0116, R0912
"""
An implementation of Conways's Game of Life using ncurses.
Controls:
When playing:
p: pause
import XMonad hiding ( (|||) )
import XMonad.Actions.CycleWS
import XMonad.Util.EZConfig(additionalKeys)
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.TwoPane
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.NoBorders
{ config, pkgs, ... }:
{
systemd.services = {
"suspend@" = {
description = "i3lock";
before = [ "sleep.target" ];
environment = { DISPLAY = ":0"; };
serviceConfig = { Type = "forking"; User = "mhmd"; };
@msafadieh
msafadieh / wikisearch.js
Last active September 23, 2019 00:55
find shortest path from one wiki page to the other
import axios from 'axios'
export async function findShortestPath(firstPage, secondPage, callback, parent) {
if (state === undefined) {
state = {}
state.done = false;
state.visited = {}
state.visited[firstPage] = true;
}