Skip to content

Instantly share code, notes, and snippets.

View EmadMokhtar's full-sized avatar
🚀
Release often, fail fast, & always improve

Emad Mokhtar EmadMokhtar

🚀
Release often, fail fast, & always improve
View GitHub Profile
@EmadMokhtar
EmadMokhtar / AuditTrailWithoutUsername
Created November 4, 2014 15:55
AuditTrailWithoutUsername
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
namespace DataModel
{
enum EntityCommandType
@EmadMokhtar
EmadMokhtar / AuditTrailWithUsername
Created November 4, 2014 15:58
AuditTrailWithUsername
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@EmadMokhtar
EmadMokhtar / quick_sort_recursive.py
Created December 19, 2016 06:02
Python Algorithms
def partition(alist, start, end):
pos = start
for i in range(start, end):
if alist[i] < alist[end]:
alist[i], alist[pos] = alist[pos], alist[i]
pos += 1
alist[pos], alist[end] = alist[end], alist[pos]
return pos
def quicksort(alist, start, end):
@EmadMokhtar
EmadMokhtar / Django + Ajax dynamic forms .py
Created January 4, 2018 14:15 — forked from goldhand/Django + Ajax dynamic forms .py
Django form with Ajax. A simple Task model that can be updated using a CBV with an AJAX mixin. The view sends post data with ajax then updates the view with a callback to a DetailView with a json mixin.There is an abstract CBV, AjaxableResponseMixin, based on the example form django docs, that is subclassed in the TaskUpdateView CBV. TaskUpdateV…
#models.py
class Task(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
def __unicode__(self):
return self.title
### Keybase proof
I hereby claim:
* I am emadmokhtar on github.
* I am emadmokhtar (https://keybase.io/emadmokhtar) on keybase.
* I have a public key ASAZ962lbDefTMLu0vyjegeRC2QM1Hc3EDypBatUNXcloAo
To claim this, I am signing this object:
@EmadMokhtar
EmadMokhtar / 1
Created April 15, 2018 07:14
vscode-settings
sdf
@EmadMokhtar
EmadMokhtar / fix_name.py
Created May 1, 2019 08:25
Notion notes sanitizer
import os
current_dir = os.getcwd()
files_extension = ['.md', '.txt', '.docx']
bad_chars = {
'#': 'hash',
'|': '',
'[': '',
']': '',
@EmadMokhtar
EmadMokhtar / file-logging.py
Created May 4, 2020 09:01
Django Recipies
# Add this part to settings to get file logger in your Django app.
# Log files path on Production environment
LOGS_DIR = '/logs'
# Check if the directory exists and if not create it
if not os.path.exists(LOGS_DIR):
os.mkdir(LOGS_DIR)
# Handler
'app-file-log': {
@EmadMokhtar
EmadMokhtar / .hyper.js
Last active August 25, 2020 08:44
Hyper terminal configuration
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
let fonts =
'"JetBrains Mono for Powerline", "JetBrains Mono", "Ubuntu Mono derivative Powerline", "Ubuntu Mono", "Menlo", "Source Code Pro"';
let fontSize = 16;
module.exports = {
config: {