Skip to content

Instantly share code, notes, and snippets.

👨‍💻
django + react => new products coming soon

Lokesh Sanapalli lokesh1729

👨‍💻
django + react => new products coming soon
Block or report user

Report or block lokesh1729

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 index.html
<script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@lokesh1729
lokesh1729 / get_starting_date_minus_n_months.py
Last active Oct 31, 2019
This function returns the datetime object by substracting n months (time won't change) #python
View get_starting_date_minus_n_months.py
def get_starting_date_minus_n_months(curr_date, num_months):
"""
Given the curr_date (datetime) object and num_months, returns the starting date
minus "num_months" months. Note that time won't change
for example: curr_date is "2019-10-22 23:59:59" and num_months is 3
it returns "2019-07-01 23:59:59"
"""
if num_months < 0:
raise ValueError(
@lokesh1729
lokesh1729 / divide_array_sub_arrays_v1.py
Created Jul 10, 2019
divide an array into contiguous k sub arrays
View divide_array_sub_arrays_v1.py
def divide(data, n_column=3):
result = []
cur_index = 0
n = len(data)
while cur_index < n/n_column:
result.append(data[cur_index*n_column: (cur_index+1)*n_column])
cur_index += 1
if n%n_column != 0:
result.append(data[cur_index*n_column: (cur_index+1)*n_column])
return result
@lokesh1729
lokesh1729 / base62_encode.py
Last active Jul 17, 2019
#python #url #shortid #short #base62 #base64
View base62_encode.py
BASE62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
def encode(num, alphabet=BASE62):
"""Encode a positive number in Base X
Arguments:
- `num`: The number to encode
- `alphabet`: The alphabet to use for encoding
"""
if num == 0:
@lokesh1729
lokesh1729 / prettier-eslint-react-config
Last active Jul 2, 2019
#prettier #eslint config for #react
View prettier-eslint-react-config
# package.json
{
"devDependencies": {
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^5.0.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-react": "^7.14.1",
"husky": "^2.5.0",
"lint-staged": "^8.2.1",
"prettier": "^1.18.2",
View threading_requests.py
import concurrent.futures
import json
import time
import requests
URLS = [
"https://reqres.in/api/users",
"http://dummy.restapiexample.com/api/v1/employees",
# "https://jsonplaceholder.typicode.com/todos",
# "https://jsonplaceholder.typicode.com/posts",
View asyncio_requests
import asyncio
import json
import time
import aiohttp
result = []
async def download_site(session, url):
View producer_consumer.py
import concurrent.futures
import logging
import random
import threading
SENTINEL = object()
View get_nested_values_from_dict.py
def get_nested_values_from_dict(data, attrs, index=0):
"""
get values from nested dictionary
Example:
>>> data = {"a": {"b": {"c": 3}}
>>> get_nested_values_from_dict(data, ["a", "b", "c"])
>>> 3
:param data: dict
:param attrs: list
:param index: int
View Default%20%28OSX%29.sublime-keymap
[
{ "keys": ["command+["], "command": "jump_back" },
{ "keys": ["command+]"], "command": "jump_forward" },
]
You can’t perform that action at this time.