Skip to content

Instantly share code, notes, and snippets.

Ashwin Vishnu ashwinvis

Block or report user

Report or block ashwinvis

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
@ashwinvis
ashwinvis / fizzbuzz.py
Created Jul 29, 2019
A Fizzbuzz implementation: modular and extensible
View fizzbuzz.py
lookup = {3: "Fizz", 5: "Buzz"}
def is_multiple(n, m):
return n % m == 0
def fizzbuzz(n):
output = ""
for m, string in lookup.items():
@ashwinvis
ashwinvis / following.ipynb
Last active Jul 13, 2019
View statistics and organize your Mastodon following into lists
View following.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View unstar_github.py
# coding: utf-8
"""
Ref
---
* https://pygithub.readthedocs.io/en/latest/introduction.html#very-short-tutorial
If you are using an access token to circumvent 2FA, make sure you have
enabled "repo" scope
Troubleshooting
@ashwinvis
ashwinvis / math.md
Created Apr 16, 2019
Markdown + latex
View math.md

Markdown stuff

import this

Inline equations

$\Sigma_{i=0}^\infty \frac{1}{n} = 2$ is a fact. However:

@ashwinvis
ashwinvis / python_aliases.sh
Last active Jul 13, 2019
Useful aliases for Python and pew and conda
View python_aliases.sh
## General stuff
## Uncomment if pip cache takes up too much space
# alias pip="python -m pip --no-cache-dir"
## or even better simply symlink ~/.cache/pip
alias spyder='env python /usr/bin/spyder'
alias spyder3='env python3 /usr/bin/spyder3'
alias jupyter-clean-checkpoints='find -name ".ipynb_checkpoints" -type d | xargs rm -rf'
alias ipcluster-mpi='ipcluster start -n 2 --engines=MPIEngineSetLauncher'
@ashwinvis
ashwinvis / Interpolation.ipynb
Last active Aug 10, 2018
Unstructured 2D data algorithms in scipy.interpolate: results and performance
View Interpolation.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ashwinvis
ashwinvis / backup_venv.sh
Last active Aug 8, 2018
Backup virtualenv before a Python 3.x upgrade and restore / recreate after the upgrade
View backup_venv.sh
#!/bin/bash
cd ~
pip freeze --user --exclude-editable > REQUIREMENTS.txt
cd $WORKON_HOME # or wherever you store your virtualenvs
for activate in ./*/bin/activate
do
source $activate
echo $VIRTUAL_ENV
View FluidSim interactive output.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View terminal_read.py
import curses
from random import randint
# Print random text in a 10x10 grid
stdscr = curses.initscr()
for rows in range(10):
line = ''.join([chr(randint(41, 90)) for i in range(10)])
stdscr.addstr(line + '\n')
View terminal_hide_cursor.py
import curses
import time
stdscr = curses.initscr()
curses.curs_set(1) # visible
time.sleep(2)
curses.curs_set(0) # invisible
time.sleep(2)
curses.curs_set(1) # visible
time.sleep(2)
You can’t perform that action at this time.