Skip to content

Instantly share code, notes, and snippets.

Hamed Rostami H4medRostami

  • $pwd
Block or report user

Report or block H4medRostami

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 Waiting for process with pid XXX to finish.bash
ls /var/cache/dnf/*pid
If have any file then remove them and try running dnf again.
View enums.py
class Planet(Enum):
MERCURY = (3.303e+23, 2.4397e6)
VENUS = (4.869e+24, 6.0518e6)
EARTH = (5.976e+24, 6.37814e6)
MARS = (6.421e+23, 3.3972e6)
JUPITER = (1.9e+27, 7.1492e7)
SATURN = (5.688e+26, 6.0268e7)
URANUS = (8.686e+25, 2.5559e7)
NEPTUNE = (1.024e+26, 2.4746e7)
def __init__(self, mass, radius):
View filtering sequence.py
mylist = [1, 4, -5, 10, -7, 2, 3, -1]
[n for n in mylist if n>0]
View sort and groupby record.py
from operator import itemgetter
rows = [{'address': '5412 N CLARK', 'date': '07/01/2012'},
{'address': '5148 N CLARK', 'date': '07/04/2012'},
{'address': '5800 E 58TH', 'date': '07/02/2012'},
{'address': '2122 N CLARK', 'date': '07/03/2012'},
{'address': '5645 N RAVENSWOOD', 'date': '07/02/2012'},
{'address': '1060 W ADDISON', 'date': '07/02/2012'},
{'address': '4801 N BROADWAY', 'date': '07/01/2012'},
{'address': '1039 W GRANVILLE', 'date': '07/04/2012'}, ]
View min,max,sortDict.py
prices={'ACME':45.23,
'AAPL':612.78,
'IBM':205.55,
'HPQ':37.20,'FB':10.75}
min_price=min(zip(prices.values(),prices.keys()))# min_price is (10.75, 'FB')
max_price=max(zip(prices.values(),prices.keys()))# max_price is (612.78, 'AAPL')
#Similarly, to rank the data, use zip() with sorted(), as in the following:
prices_sorted=sorted(zip(prices.values(),prices.keys()))
# prices_sorted is [(10.75, 'FB'), (37.2, 'HPQ'),
View Nargest_Nsmallest.py
import heapq
nums=[1, 8, 2, 23, 7, -4, 18, 23, 42, 37, 2]
print(heapq.nlargest(3, nums))
print(heapq.nsmallest(3, nums))
portfolio=[{'name':'IBM','shares':100,'price':91.1},
{'name':'AAPL','shares':50,'price':543.22},
{'name':'FB','shares':200,'price':21.09},
You can’t perform that action at this time.