Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View elmehalawi's full-sized avatar

Hassan El-Mehalawi elmehalawi

  • Houston
View GitHub Profile
@hjertnes
hjertnes / doom.txt
Created April 6, 2018 08:28
Doom Emacs Cheatsheet
SPC
SPC: find file
, switch buffer
. browse files
: MX
; EX
< switch buffer
` eval
u universal arg
x pop up scratch
@veuncent
veuncent / docker_debugging.md
Last active February 21, 2024 00:58
Debugging Django apps running in Docker using ptvsd - Visual Studio (Code)

Remote debugging in Docker (for Django apps)

In order to enable debugging for your Django app running in a Docker container, follow these steps using Visual Studio (Code):

  1. Add ptvsd to your requirements.txt file
ptvsd == 4.3.2
  1. To your launch.json, add this:
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@mattd
mattd / gist:1006398
Created June 3, 2011 14:12
nginx try_files with a proxy_pass
server {
root /var/www/example.com/static;
server_name example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
try_files /maintenance.html @proxy;
location @proxy {
proxy_pass http://127.0.0.1:10001;
@aubricus
aubricus / License
Last active June 20, 2023 01:19
Python Progress Bar
Copyright 2020 Aubrey Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTH
@superseb
superseb / cleanup.sh
Last active June 19, 2023 10:03
Cleanup host added as custom to Rancher 2.0
#!/bin/sh
# OUTDATED: please refer to the link below for the latest version:
# https://github.com/rancherlabs/support-tools/blob/master/extended-rancher-2-cleanup/extended-cleanup-rancher2.sh
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke"
for dir in $cleanupdirs; do
echo "Removing $dir"
rm -rf $dir
done
@lrhache
lrhache / python-selenium-open-tab.md
Last active June 10, 2023 13:49
Python Selenium - Open new tab / focus tab / close tab

On a recent project, I ran into an issue with Python Selenium webdriver. There's no easy way to open a new tab, grab whatever you need and return to original window opener.

Here's a couple people who ran into the same complication:

So, after many minutes (read about an hour) of searching, I decided to do find a quick solution to this problem.

@jizhang
jizhang / md5.clj
Created December 18, 2012 07:14
Clojure - Calculate MD5 hash of a given string.
(import 'java.security.MessageDigest
'java.math.BigInteger)
(defn md5 [s]
(let [algorithm (MessageDigest/getInstance "MD5")
size (* 2 (.getDigestLength algorithm))
raw (.digest algorithm (.getBytes s))
sig (.toString (BigInteger. 1 raw) 16)
padding (apply str (repeat (- size (count sig)) "0"))]
(str padding sig)))
@pjullah
pjullah / clojurescript_notes.cljs
Last active September 16, 2021 07:26
Notes on Clojurescript
; Clojure strings are Javascript strings
(def s "This is a string")
; Can access Javascript functions, using dot-prefixed notation
(.toUpperCase s)
; To retrieve an object property
(.-length s)
; Javascript supports method-chaining. To accomplish the same in Clojurescript we would nest the function calls, or better still
@gorsuch
gorsuch / gist:1418850
Created December 1, 2011 18:37
clojure uuid
(defn uuid [] (str (java.util.UUID/randomUUID)))