Skip to content

Instantly share code, notes, and snippets.

# -> (i + k) % len(nums)
# A -> List
# k -> number of postion
def rotate(A, k):
k %= len(A)
A[k:], A[:k] = A[:-k], A[-k:]
return A
@govindsharma7
govindsharma7 / redis-autostart-osx.md
Created December 21, 2018 20:38 — forked from subfuzion/redis-autostart-osx.md
redis auto start OS X

Install with Homebrew

brew install redis

Set up launchctl to auto start redis

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)

@govindsharma7
govindsharma7 / countryinfo.py
Created September 20, 2018 03:28 — forked from pamelafox/countryinfo.py
Python list of country codes, names, continents, capitals, and pytz timezones
countries = [
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'},
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'},
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"},
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'},
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'},
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'},
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai
@govindsharma7
govindsharma7 / xls_to_json.py
Created September 18, 2018 04:51 — forked from yosemitebandit/xls_to_json.py
converting xls files to JSON dicts in python
"""XLS -> json converter
first:
$ pip install xlrd
then:
$ cat in.xls
date, temp, pressure
Jan 1, 73, 455
Jan 3, 72, 344
Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF
Professional: KBJFW-NXHK6-W4WJM-CRMQB-G3CDH
Keys are generic ones. These are the same from MSDN account.
Product Key : -6Q8QF
Validity : Valid
Product ID : 00369-90000-00000-AA703
Advanced ID : XXXXX-03699-000-000000-00-1032-9200.0000-0672017
@govindsharma7
govindsharma7 / send_an_email.py
Created June 3, 2018 05:56 — forked from yzhong52/send_an_email.py
Send an email with a gmail account using python 3
# smtplib module send mail
import smtplib
TO = 'recipient@mailservice.com'
SUBJECT = 'TEST MAIL'
TEXT = 'Here is a message from python.'
# Gmail Sign In
gmail_sender = 'sender@gmail.com'
@govindsharma7
govindsharma7 / py_mail.py
Created June 3, 2018 05:25 — forked from arjkb/py_mail.py
Python program to send emails to multiple people
import smtplib
from string import Template
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
MY_ADDRESS = 'my_address@example.comm'
PASSWORD = 'mypassword'
# import necessary packages
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# For each contact, send the email:
for name, email in zip(names, emails):
msg = MIMEMultipart() # create a message
# add in the actual person name to the message template
message = message_template.substitute(PERSON_NAME=name.title())
@govindsharma7
govindsharma7 / client.html
Created May 26, 2018 18:04 — forked from diorahman/client.html
Ajax, call jQuery POST to node.js expressjs
<html>
<head>
<title>jsonp test</title>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(function(){
$('#select_link').click(function(e){
e.preventDefault();
console.log('select_link clicked');
@govindsharma7
govindsharma7 / app.py
Created May 1, 2018 17:01 — forked from rduplain/app.py
Add a second static directory to Flask, in ../static/.
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route('/base/<path:filename>')
def base_static(filename):
return send_from_directory(app.root_path + '/../static/', filename)