Hacker News new | ask | show | jobs
by mbar84 1563 days ago
I have a script bound to a hotkey.

User experience: <hotkey> 1+1<enter> exit<enter>

$ cat ~/bin/ipy ipython -i -c "import itertools as it; from statistics import ;import functools as ft;import operator as op;import io;import pathlib as pl;import pandas as pd;import numpy as np;from math import ;import enum;import re;import sys;import os;import json;from collections import defaultdict, deque, Counter;import random;import decimal;import fractions;from time import time;import datetime as dt;import shutil;import subprocess as sp;import uuid;from hashlib import sha256, sha1, blake2b, blake2s"

1 comments

You have just upped my game. No longer will I hand-type my imports when I need to bust out the Swiss army knife and type a quick (now lightning-fast) calculation. Don't know why I didn't do this sooner.

For anyone needing more inspiration, here is some pseudocode for my version (which also has accompanying print()'s in the live script as a reminder of what my imports are):

>>> from base64 import b64encode as be, b64decode as bd;from binascii import hexlify as hexl, unhexlify as unhexl;from Crypto.Random import get_random_bytes as grb;from Crypto.Random.random import randint # PARAMS (a, b) INCLUSIVE;from Crypto.Hash import SHA1, SHA256;from urllib.parse import quote, unquote