Skip to content

Instantly share code, notes, and snippets.

View shekharkoirala's full-sized avatar
💯
:)

shekhar koirala shekharkoirala

💯
:)
View GitHub Profile
@shekharkoirala
shekharkoirala / usaCities.js
Created June 12, 2019 06:25 — forked from Lwdthe1/usaCities.js
JSON of 5,950+ USA Cities and Their States
[
{'city': 'Abbeville', 'state': 'Louisiana'},
{'city': 'Aberdeen', 'state': 'Maryland'},
{'city': 'Aberdeen', 'state': 'Mississippi'},
{'city': 'Aberdeen', 'state': 'South Dakota'},
{'city': 'Aberdeen', 'state': 'Washington'},
{'city': 'Abilene', 'state': 'Texas'},
{'city': 'Abilene', 'state': 'Kansas'},
@shekharkoirala
shekharkoirala / scrap_share_market_send_email
Created June 1, 2019 07:19
Scrap Nepali share market and send email to anyone. The message will be top 5 share difference ( rise ).
import requests
from bs4 import BeautifulSoup
def parse_df(link, columns):
page = requests.get(link)
soup = BeautifulSoup(page.content, 'html.parser')
temp_data = []
final_data = []
data2 = soup.find_all(class_='container')
data_ = data2[4]
@shekharkoirala
shekharkoirala / send_email
Created June 1, 2019 07:15
send email to anyone using python
import smtplib, ssl
port = 465 # For SSL
smtp_server = "smtp.gmail.com"
sender_email = "" # Enter your address
receiver_email = "" # Enter receiver address
cc_email = "" #Enter cc address
bcc_email = "" #Enter bcc address
password = "" # password of sender email
message_subject = "" # Enter subject
@shekharkoirala
shekharkoirala / service_shell
Created February 3, 2019 10:48
shell script to to run the service file.
#path : /etc/init.d/service_name
#!/bin/sh
### BEGIN INIT INFO
# Provides: myservice
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: My Service
# Description: Does some specific work
@shekharkoirala
shekharkoirala / service_name.service
Last active February 3, 2019 05:53
Run python program as a service in linux
# path : sudo nano /lib/systemd/system/service_name.service
[Unit]
Description=Daemon Service
[Service]
Type=simple
ExecStart=/usr/bin/python3 /path/to/python/file/example.py
[Install]
WantedBy=multi-user.target
@shekharkoirala
shekharkoirala / mongodb_nested
Last active February 2, 2019 06:07
Insert nested json in Mongodb
from pymongo import MongoClient , DESCENDING , ASCENDING
mongo_uri = "mongodb://localhost:27017/"
client = MongoClient(mongo_uri)
db = client['medium_gist']
def create_collection(customer_detail):
post = {"name": customer_detail["name"],
"Address": customer_detail["address"],
"items": {}
}