Skip to content

Instantly share code, notes, and snippets.

View alphaWizard's full-sized avatar

Arpit Gupta alphaWizard

View GitHub Profile
import asyncio
import time
import aiohttp
from aiohttp.client import ClientSession
async def download_link(url:str,session:ClientSession):
async with session.get(url) as response:
result = await response.text()
print(f'Read {len(result)} from {url}')
#!/usr/bin/env bash
# Copyright The Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#!/usr/bin/env bash
# Copyright The Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
import sys
import os
sys.path.insert(0, os.path.join(os.path.expanduser('~'), '.azure', 'cliextensions', 'connectedk8s'))
from kubernetes import client as kube_client, config
def try_list_node_fix():
try:
from kubernetes.client.models.v1_container_image import V1ContainerImage
@alphaWizard
alphaWizard / debug_req.py
Created September 18, 2020 10:09
Request-response printing for logging
def print_request(req):
print('HTTP/1.1 {method} {url}\n{headers}\n\n{body}'.format(
method=req.method,
url=req.url,
headers='\n'.join('{}: {}'.format(k, v) for k, v in req.headers.items()),
body=req.body,
))
def print_response(res):
print('HTTP/1.1 {status_code}\n{headers}\n\n{body}'.format(
# import nltk
# from nltk import word_tokenize
# from nltk.util import ngrams
# from collections import Counter
# text = "I need to write a program in NLTK that breaks a corpus (a large collection of txt files) into unigrams, bigrams, trigrams, fourgrams and fivegrams.I need to write a program in NLTK that breaks a corpus"
# token = nltk.word_tokenize(text)
# bigrams = ngrams(token,2)
# trigrams = ngrams(token,3)
@alphaWizard
alphaWizard / tornadowhoosh.py
Created August 30, 2018 19:16 — forked from anonymous/tornadowhoosh.py
Tornado - Whoosh - DidYouMean
import whoosh,os
from whoosh import index
import whoosh.index
import whoosh.fields
import whoosh.qparser
import tornado.ioloop
import tornado.web
class Search(object):
def __init__(self, indexdir, searchstr=None):
@alphaWizard
alphaWizard / tornadowhoosh.py
Created August 30, 2018 19:16 — forked from anonymous/tornadowhoosh.py
Tornado - Whoosh - HighLighted Search
import whoosh,os
from whoosh import index
import whoosh.index
import whoosh.fields
import whoosh.qparser
import tornado.ioloop
import tornado.web
from whoosh import analysis, fields, formats, query, highlight
class Search(object):
@alphaWizard
alphaWizard / travis_to_conda.md
Created August 29, 2018 12:37 — forked from zshaheen/travis_to_conda.md
How to Setup Automatic Uploads to Anaconda from Travis CI in 15 minutes

How to Setup Automatic Uploads to Anaconda from Travis CI in 15 minutes

TL;DR: Edit .travis.yaml to install Anaconda and to run conda_upload.sh after testing. Edit meta.yaml to take in the environmental variables $VERSION and $CONDA_BLD_PATH. Create conda_upload.sh which sets the needed environmental variables, builds the tar archive, and uploads it to Anaconda. Finally edit some stuff on your Anaconda and Travis CI account so they can talk.

Intro

The following steps will detail how to automatically trigger Anaconda builds and uploads from Travis CI. This will only upload successful builds in the master branch and if there are multiple commits in a single day, it'll only keep the latest one. Both of these settings can easily be changed.

Edit .travis.yaml

First, edit .travis.yml so that it installs Anaconda.

install:
#include<bits/stdc++.h>
using namespace std;
void merge(int ar[],int l,int mid,int r) //O(n) merge and O(1) auxillary space
{
int oddl=0,oddr=0; //counts of odd numbers in left and right subarrays
for(int i=l;i<=mid;++i)
{
if(ar[i]%2==1) oddl++;
else break;