Skip to content

Instantly share code, notes, and snippets.

View phaustin's full-sized avatar

Philip Austin phaustin

  • University of British Columbia
  • Vancouver, BC Canada
View GitHub Profile
import trio
WORKER_COUNT = 10
async def worker(receive_chan):
# Trick: each url gets its own clone of the send channel
# After processing a URL, we close its clone
# That way, when all the URLs are done, all the send clones will be
# closed, so the 'async for ... in receive_chan' will automatically exit.
async for send_chan, url in receive_chan:
@phaustin
phaustin / install-conda.yml
Created February 28, 2021 19:11 — forked from aksakalli/install-conda.yml
Installing Minicaonda/Anaconda from Ansible playbook for all
- name: Install Conda
block:
- name: Download Miniconda
get_url:
url: https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh
dest: /tmp/install-miniconda.sh
checksum: md5:a946ea1d0c4a642ddf0c3a26a18bb16d
mode: 0550
- name: Create conda folder
@phaustin
phaustin / GitHub-Forking.md
Created May 22, 2020 01:47 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@phaustin
phaustin / chmxdx_letters.py
Created May 19, 2020 01:58 — forked from decentral1se/chmxdx_letters.py
chmxdx_letters.py
from contextlib import asynccontextmanager
from string import ascii_letters
from typing import Dict
import attr
from trio import (
BrokenResourceError,
ClosedResourceError,
Lock,
MemoryReceiveChannel,
@phaustin
phaustin / post-commit
Created January 2, 2019 15:54
Pre and post commit hooks to automatically generate production ready css and add it to the current commit. git add doesn't add the files to the current commit so a .commit file is created to keep track and execute an amending commit in a post-commit hook
#!/bin/sh
#
# To enable this hook place this file in .git/hooks and make it executable.
if [ -a .commit ]
then
rm .commit
git commit --amend -C HEAD --no-verify
fi
exit
@phaustin
phaustin / CMakeLists.txt
Last active December 2, 2018 21:18 — forked from YannickJadoul/CMakeLists.txt
Shared data between two pybind11 modules
cmake_minimum_required(VERSION 3.8)
project(example)
add_subdirectory(pybind11)
add_library(shared_counter SharedCounter.cpp)
target_compile_features(shared_counter PUBLIC cxx_std_11)
pybind11_add_module(foo foo.cpp)
target_link_libraries(foo PRIVATE shared_counter)
@phaustin
phaustin / crawler.py
Last active November 17, 2016 21:19 — forked from MBAustin/crawler.py
import re, sys, time
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from bs4 import BeautifulSoup
class Render(QWebPage):
def __init__(self, url):
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from bs4 import BeautifulSoup
qInstallMsgHandler(lambda *args: None)
class Render(QWebPage):
@phaustin
phaustin / matlab_notebook.ipynb
Last active February 20, 2021 08:26 — forked from macd/gist:10562695
Chapter 1 A Brief Tutorial. A direct translation of Chapter 1 of D.J. Higham and N.J. Higham, MATLAB Guide (2005)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@phaustin
phaustin / 00README.rst
Created February 17, 2013 22:17 — forked from GaelVaroquaux/00README.rst
passing arrays to cython

Cython example of exposing C-computed arrays in Python without data copies

The goal of this example is to show how an existing C codebase for numerical computing (here c_code.c) can be wrapped in Cython to be exposed in Python.

The meat of the example is that the data is allocated in C, but exposed in Python without a copy using the PyArray_SimpleNewFromData numpy