Skip to content

Instantly share code, notes, and snippets.

View mahmoudhossam's full-sized avatar
🏗️

Mahmoud Hanafy mahmoudhossam

🏗️
  • Berlin, Germany
  • 03:24 (UTC +02:00)
View GitHub Profile
@coolreader18
coolreader18 / segfault.py
Last active March 30, 2024 08:05
CPython segfault in 5 lines of code
class E(BaseException):
def __new__(cls, *args, **kwargs):
return cls
def a(): yield
a().throw(E)
@vvkpd
vvkpd / learnBash.sh
Created February 28, 2019 10:48
Basic bash script
#!/usr/bin/env bash
# First line of the script is the shebang which tells the system how to execute
# the script: http://en.wikipedia.org/wiki/Shebang_(Unix)
# As you already figured, comments start with #. Shebang is also a comment.
# Simple hello world example:
echo Hello world! # => Hello world!
# Each command starts on a new line, or after a semicolon:
package jwtex
import (
"encoding/base64"
"encoding/json"
"fmt"
"strings"
"testing"
)
@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@vasanthk
vasanthk / System Design.md
Last active May 6, 2024 20:21
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 6, 2024 02:17
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@dstufft
dstufft / welp.txt
Last active August 29, 2015 13:58
Python uses the os.py module as a sort of sentinel value to determine where the
stdlib is. It will look in a relative directory first. So if you have a file
structure like…
.
├── bin
│ └── python
└── lib
└── python2.6
└── os.py
@alex
alex / Original lyrics
Created October 1, 2012 04:23
I'm proud to be a unix programmer
If tomorrow all the things were gone,
I’d worked for all my life.
And I had to start again,
with just my children and my wife.
I’d thank my lucky stars,
to be livin here today.
‘ Cause the flag still stands for freedom,
and they can’t take that away.
@stingh711
stingh711 / receiver.clj
Created September 21, 2012 09:02
A simple UDP server in clojure
(import '(java.net DatagramSocket DatagramPacket))
(def socket (DatagramSocket. 5200))
(def running (atom true))
(def buffer (make-array Byte/TYPE 1024))
(defn parse [packet]
(println (String. (.getData packet) 0 (.getLength packet))))
(defn start-receiver []