Skip to content

Instantly share code, notes, and snippets.

:octocat:
.

Ahmed Eid a-eid

:octocat:
.
Block or report user

Report or block a-eid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View towerofhanoi.py
""" Tower of Hanoi """
def printMove(fr , to):
print("move from {} to {} ".format(str(fr),str(to)) )
def towers(num , original , dist ,spare):
if num == 1:
printMove(original , dist)
else:
towers(num-1, original , spare , dist) # move the upper stack to spare to
towers(1, original , dist , spare) # move the bigger to to
View inject.js
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
};
NodeList.prototype.__proto__ = Array.prototype; // eslint-disable-line
NodeList.prototype.on = NodeList.prototype.addEventListener = function (name, fn) {
@a-eid
a-eid / issue.md
Last active Jun 26, 2017
medium issue extended
View issue.md

medium

Maybe I was not clear enough so I will explain the issue again after posting the versions you asked about

View stripped-of-script-tags.js
<html><!-- #BeginTemplate "/Templates/master.dwt" --><!-- DW6 -->
<head>
<!-- #BeginEditable "doctitle" -->
<title>Real Estate Puerto Rico ,Bienes Raices en Puerto Rico Clasificados Alquiler
Online</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="description" CONTENT="Real Estate Puerto Rico ,Bienes Raices en Puerto Rico Clasificados Alquiler Online">
<META NAME="keywords" CONTENT="Real Estate Puerto Rico , Alquiler Bienes Raices en Puerto Rico Clasificados Online, bienes raices puerto rico, puerto rico bienes raices, puerto rico real estate,real, estate, alquiler, rent, real estate, bienes raices, casa, clasificados, classifieds, puerto rico, online, homes, apartamento, house">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
View python_fetch_words.py
import sys
from urllib.request import urlopen
def fetch_words(url):
words = []
with urlopen(url) as f:
for line in f:
for word in line.decode('utf-8').split():
words.append(word)
return words
View bubblesort.js
function bubble_sort(arr){
for(let i = 0 , n = arr.length ; i < n - 1 ; n -= 1){
for(let ii = i , j = i + 1 ; j < n ; j += 1 , ii += 1){
if(arr[ii] > arr[j]){
let temp = arr[ii]
arr[ii] = arr[j]
arr[j] = temp
}
}
}
View gens.md

##what are generators##

  • They're pausable functions, pausable iterable functions, to be more precise
  • They're defined with the *
  • every time you yield a value, the function pauses until .next(modifiedYieldValue) is called
var myGen = function*() {
  var one = yield 1;
  var two = yield 2;
  var three = yield 3;
  console.log(one, two, three);
View setProperty.js
function setObject(str , value){
var arr = str.split('.')
var init = window
for(var i = 0 ; i < arr.length-1 ; i++){
if(!init[arr[i]]) init[arr[i]] = {}
init = init[[arr[i]]]
}
init[arr[arr.length-1]] = value // trick ..
}
@a-eid
a-eid / toggle_touchpad.sh
Created Apr 6, 2017
command toggle touchpad ubuntu
View toggle_touchpad.sh
#!/bin/bash
read TPdevice <<< $( xinput | sed -nre '/TouchPad/s/.*id=([0-9]*).*/\1/p' )
state=$( xinput list-props "$TPdevice" | grep "Device Enabled" | grep -o "[01]$" )
if [ "$state" -eq '1' ];then
xinput --disable "$TPdevice"
else
xinput --enable "$TPdevice"
fi
@a-eid
a-eid / bsearch.js
Created Apr 2, 2017
simple binary search example ...
View bsearch.js
const bsearch = (arr , start , end , el) => {
if(start > end) return -1
let mid = Math.round((start + end) / 2)
if(mid == el) return mid
else if ( mid < el ) return bsearch(arr , mid + 1 , end , el)
else if ( mid > el ) return bsearch(arr , start , mid - 1 , el)
}
You can’t perform that action at this time.