Skip to content

Instantly share code, notes, and snippets.


Nidhal Selmi Nydhal

View GitHub Profile
Nydhal / hn_upvoted_scraper.js
Created Jul 25, 2020
Scrape all your HN upvoted links and Export to CSV or HTML (from your browser).
View hn_upvoted_scraper.js
Search HN upvoted from your browser and Export to CSV or HTML.
1. Navigate your browser to
2. Copy code to the browser console and run.
4. Look for the popup window in the upper-left corner of your browser.
(function () {
const popup = createPopup('HN upvoted');
const base = '';
Nydhal /
Created Dec 4, 2019
Python Simulation of the Coupon Collector Problem Expectation a.k.a Mean Cover Time of a Random Walk on a Complete Graph K_n (n=52, 10000 trials).
import random as rd
for _ in range(10000): seen, n_draws = set(), 0
while len(seen)<52:
n_draws +=1
print (sum(result) / len(result))
View sleepfizzbuzz
import asyncio
async def FizzBuzz(i: int):
await asyncio.sleep(i)
print("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or i)
async def SleepFizzBuzz(l,loop):
tasks = [loop.create_task(FizzBuzz(i)) for i in range(1,l+1)]
for t in tasks:
await t
View Corr_Matrix_Generation.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding=utf-8
import urllib3 as u
from bs4 import BeautifulSoup
from tabulate import tabulate
import pandas as pd
digikey_id_list = ['product-details', 'prod-att-table'] # Digi-Key tables
def get_soup(url):
Nydhal / audio.html
Last active Jul 6, 2018
Stylized HTML5 audio player
View audio.html
<!DOCTYPE html><html><body>
<style> audio { filter:
drop-shadow(0px 0px 0px #ff0000);
from sympy import binomial as b
def getA2B(X,Y,x,y):
U,D,s = X==x,Y==y,x+y
u = sum([b(s,i) for i in range(0,y)])
d = sum([b(s,i) for i in range(y+1,s+1)])
r = u*U+b(s,y)+D*d
return r/2**s
print('B(3,4) C(3,3) => ',getA2B(3,4,3,3))
# Problem represnetation :
# Enter destination coordinates B(X,Y) and intercept point C(x,y)
Nydhal /
Last active Apr 26, 2018
#Python code to sample n trials given N and M (short but not best way)
import random as r,itertools as t
def s(M,N,L=[0]):
while len(L)<M+1:
if x!=L[-1]:L.append(x)
return len([x[0] for x in t.groupby([(L[i]>L[i-1]) for i in range(2,M+1)])])
M,N,n = 100,100,100000
l = []
for i in range(1,n):
View Hotels.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Hotel Stars="****">
<Name>Harbor View Inn</Name>
<Address BusLines="R2">