Skip to content

Instantly share code, notes, and snippets.

View mie00's full-sized avatar

Mohamed I. Elawadi mie00

View GitHub Profile
@mie00
mie00 / s9.py
Created March 22, 2014 16:06
nine-liner sudoku solver
def complement(arr):
return filter(lambda x:x not in arr,range(1,10))
def possibilities(a,arr):
x,y=a%9,a/9
return complement(
map(lambda k:arr[k],
range(x,81,9)+range(9*y,9*(y+1))+
map(lambda z:z+(x-x%3)+(y-y%3)*9,[0,1,2,9,10,11,18,19,20])
)
)
@mie00
mie00 / define.c
Created April 8, 2014 09:19
Dosoky c
#include <stdio.h>
void change(int* xp){ //define "declare" pointer called xp , type "int*" NOT "int"
printf("0:%d\n",*xp); //print x - the value which pointer points to - old value
*xp=6; // change the value of x - using its addr -
printf("1:%d\n",*xp); //print x - the value which pointer points to - new value
printf("5:%p\n",xp); // print the pointer " the addr of var. x"
printf("2:%p\n",&xp); //print the addr of the pointer xp
}
int main(){
int x=5;
@mie00
mie00 / download.py
Created July 1, 2014 13:30
pdf free books
# -*- coding: utf-8 -*-
import re
import urllib
from multiprocessing import Pool
import requests
import progressbar
CHUNK_SIZE = 1024 * 1024 # 1MB
def download(i):
@mie00
mie00 / searchDeep.js
Created December 23, 2015 11:32
JavaScript object deep search
function searchDeep(obj,query,objName){
var a = []
var b = function(obj,query,c){
if(~(a.indexOf(obj))) return []
a.push(obj)
var d = []
if(query in obj){
d.push(c)
}
for(var j in obj){
@mie00
mie00 / otlob.js
Created July 12, 2016 13:55
A script to random restaurants and oreders from otlob.com (add it to grease monkey)
// ==UserScript==
// @name random_order
// @namespace otlob
// @description randomise order
// @include https://www.otlob.com/*
// @version 1
// @grant none
// @authors Mohamed Elawadi <mohamed@elawadi.net>, Ahmed Thabet <xmonader@gmail.com>
// ==/UserScript==
Element.prototype.documentOffsetTop = function () {
@mie00
mie00 / netns.sh
Last active July 5, 2024 09:24
Create a network namespace that is connected to the internet
#!/usr/bin/env bash
set -e
function usage {
echo "usage: $0 [create|remove] netns_name [network_ip]"
exit 1
}
if [ "$#" -lt "1" -o "$1" = "-h" -o "$1" = "--help" ]; then
usage
@mie00
mie00 / bills.py
Last active October 23, 2017 15:30
For bills and stuff
#!/usr/bin/env python
def calc(gross, delivery, d):
"""
usage:
>>> calc(120, 9, {
'Ashraf': 40,
'Thabet': 20,
'Awadi': 20,
'Ghanem': 20,
@mie00
mie00 / botlock.py
Last active October 25, 2016 14:25
#!/usr/bin/env python3
from twx.botapi import TelegramBot, send_message
import time
d = {}
dr = {}
bot = TelegramBot('bot-token')
bot.update_bot_info().wait()
#!/usr/bin/env python3
from twx.botapi import TelegramBot, send_message
import time
from collections import Counter
polls = {}
def aggregate_votes(votes):
return '\n'.join('%s: %s' % (k,v) for k,v in sorted(Counter(votes.values()).items(), key=lambda x:x[1]))
@mie00
mie00 / unlock.py
Created February 11, 2017 15:10
The script that I used to bruteforce my mobile pin
import os, random
from time import sleep
def command(com):
return os.system('adb %s > /dev/null 2>&1' % com)
def reboot():
return command('reboot')
def shell(com):