Skip to content

Instantly share code, notes, and snippets.

View kmonsoor's full-sized avatar
:octocat:

Khaled Monsoor kmonsoor

:octocat:
View GitHub Profile
@kmonsoor
kmonsoor / RPi-install-wifi.sh
Last active February 19, 2024 05:46
install wifi adapter drivers on Raspberry Pi; origin: http://www.fars-robotics.net/install-wifi
#!/bin/bash
#set -e
# origin-source: http://www.fars-robotics.net/install-wifi
# install-wifi - v9.4 - by MrEngman.
# After downloading this script:
# $ sudo mv ./install-wifi /usr/bin/install-wifi
# $ sudo chmod +x /usr/bin/install-wifi
# $ sudo install-wifi -h
#
@kmonsoor
kmonsoor / get_yt_video_id.py
Last active February 15, 2024 17:15
Extract Video-ID from a Youtube url
# initial version: http://stackoverflow.com/a/7936523/617185 \
# by Mikhail Kashkin(http://stackoverflow.com/users/85739/mikhail-kashkin)
def get_yt_video_id(url):
"""Returns Video_ID extracting from the given url of Youtube
Examples of URLs:
Valid:
'http://youtu.be/_lOT2p_FCvA',
'www.youtube.com/watch?v=_lOT2p_FCvA&feature=feedu',
@kmonsoor
kmonsoor / getScript.js
Created July 3, 2018 14:12
jquery $.getScript() replacement with vanilla JavaScript
"use strict";
// src: https://stackoverflow.com/a/28002292
const getScript = (source, callback) => {
var script = document.createElement('script');
var prior = document.getElementsByTagName('script')[0];
script.async = 1;
script.onload = script.onreadystatechange = (_, isAbort) => {
if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
@kmonsoor
kmonsoor / UploadWithProgress.cs
Created August 3, 2016 14:23
C#.NET : WebClient : Upload file to web API while monitoring progress
using System;
using System.IO;
using System.Net;
using System.Web;
public class UploadWithProgress
{
public static double PercentUploaded;
public static string FilePath;
public static string Result;
@kmonsoor
kmonsoor / pep8_tonizer.py
Created April 28, 2014 15:07
pep8_tonizer : PEP8-fixer plugin (well, kind of) for Notepad++
"""
===============
pep8_tonizer.py
===============
This script can be used to make python code, that is being edited on Notepad++, \
to comply with infamous PEP8 coding style [http://bit.ly/pep8]
By default, autopep8 only makes whitespace changes. So does this script.
However, this script depends on following:
@kmonsoor
kmonsoor / parallel_rss_download.py
Last active February 5, 2022 20:30
Download contents by grabbing links from a given RSS-feed. Works over HTTP,FTP,HTTPS protocol transparently. Currently, works on Linux, Mac OSX, and possibly on other Unix as well. But, _NOT_ on Windows yet
#!/usr/bin/env python2.7
"""
Parallel RSS-Feed Downloader
----------------------------
Download contents by grabbing links from a given RSS-feed.
Works over HTTP,FTP,HTTPS protocol transparently.
Currently, works on Linux, Mac OSX, and possibly on other Unix as well.
But, _NOT_ on Windows * yet.
@kmonsoor
kmonsoor / beautify_bash.py
Created March 23, 2018 09:31
Beautify your Bash code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#**************************************************************************
# Copyright (C) 2011, Paul Lutus *
# *
# This program is free software; you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published by *
# the Free Software Foundation; either version 2 of the License, or *
# (at your option) any later version. *
@kmonsoor
kmonsoor / url-forwarder-worker-cloudflare.js
Created May 25, 2021 03:38
Core worker code for url-forwarder based on Cloudflare Worker-KV
// This is the companion code for the linked blog
// https://blog.kmonsoor.com/on-edge-shortlink-server-cloudflare-kv-worker
// Please check the blog to get the context
// author : Khaled Monsoor (@kmonsoor)
// last updated: 25-May-2021
const failsafeURL = "https://kmonsoor.com" // replace it with yours ;)
const defaultStatusCode = 301 // standard HTTP code for redirection, don't change
addEventListener("fetch", (event) => {
@kmonsoor
kmonsoor / grafana.ini
Created August 2, 2017 15:23
Sample SMTP configuration for Grafana with Gapps account
#### other settings ...
[smtp]
enabled = true
host = smtp.gmail.com:465
user = grafana-bot@organization.com
password = """PASSWORD"""
from_address = grafana-bot@organization.com
from_name = Grafana Bot
;cert_file =
@kmonsoor
kmonsoor / create-version.py
Created May 24, 2019 19:01
Jira-Python : Create versions for project
# replce server address with actual Jira host for your case
options = {'server': 'https://jira.atlassian.com'}
#login
jira = JIRA(options, basic_auth=(os.environ['JIRA_USERNAME'], os.environ['JIRA_PASSWORD']))
#get currently available version names
project = jira.project('PROJECT-KEY')
versions = jira.project_versions(project)
current_versions = [v.name for v in reversed(versions)]