Skip to content

Instantly share code, notes, and snippets.

@asherp
asherp / jupyter_pass.py
Created Mar 25, 2021
Sets up a jupyter notebook server password by from the environment variable JUPYTER_PASSWORD (python3 compatible)
View jupyter_pass.py
# -*- encoding: utf-8 -*-
# modified for python3 https://stackoverflow.com/a/48806794/2793333
import os
import fileinput
import hashlib
import random
from ipython_genutils.py3compat import cast_bytes, str_to_bytes
# Get the password from the environment
@asherp
asherp / nft_bitcoiners.md
Last active Apr 7, 2021
NFTs: A Bitcoiner's Perspective
View nft_bitcoiners.md

NFTs: A Bitcoiner's Perspective

Non-fungible tokens (NFTs) are becoming a popular way for artists to monetize their content. Recently, many bitcoiners have maligned the model as illigitimate, calling them scams or the like. As someone who attempted the same model with colored coins in 2012, I would have thought bitcoiners would understand why this model not only fits within the ethos of bitcoin, but is very likely to succeed for similar reasons. I believe success in the NFT model only improves the likelihood of mainstream success of bitcoin. Ironically, bitcoin influencers are using the same arguments made against bitcoin to denounce NFTs. Let's examine each of these arguments and how they have been applied to bitcoin in the past. My hope is that this will sway bitcoiners to not write them off as a mere phase akin to ICOs, but as a growing part of the virtual economy and a sign of things to come.

Addressing Technical Concerns

Technical implementations are not the issue

Some bitcoiners take issue wi

@asherp
asherp / FrechetDistance.py
Last active Mar 12, 2021
Frechet Distance (iterative version)
View FrechetDistance.py
"""Original Code from Tim Wylie http://www.cs.montana.edu/~timothy.wylie/frechet/
A. Pembroke added modifications to combine frechet distance with closest ordered pairs
and implemented an iterative version of the original recursive discrete frechet calculation, df_iterative.
"""
##############################################################################################################
##############################################################################################################
## File: fpact_frechet.py
## Author: Tim Wylie
## Copyright: Tim Wylie
@asherp
asherp / lsqlin.py
Last active Aug 27, 2019
python3 implementation of matlab's lsqlin. requires cvxopt
View lsqlin.py
#!/usr/bin/python
# Derived from: https://github.com/KasparP/PSI_simulations/blob/master/Python/SLAPMi/lsqlin.py
# See http://maggotroot.blogspot.ch/2013/11/constrained-linear-least-squares-in.html for more info
'''
A simple library to solve constrained linear least squares problems
with sparse and dense matrices. Uses cvxopt library for
optimization
'''
__author__ = 'Valeriy Vishnevskiy'
__email__ = 'valera.vishnevskiy@yandex.ru'
@asherp
asherp / time_avg.py
Created Jun 15, 2018
windowed time average
View time_avg.py
def windowed_time_average(data, window = 3):
window = 3
results = []
for i in range(len(data)):
if i < window:
results.append(np.sum(data[:i+1])/window)
else:
results.append(np.sum(data[i-window+1:i+1])/window)
return np.array(results)
@asherp
asherp / plotly_camera_on_update.py
Last active Jun 13, 2018
Demonstrates saving state of previous camera when a new graph loads
View plotly_camera_on_update.py
import dash
from dash.dependencies import Input, Output, State, Event
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import numpy as np
class dccType(object):
@asherp
asherp / plotly_dash_objects.py
Last active Oct 1, 2020
object-orient plotly dash elements
View plotly_dash_objects.py
import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html
class dccType(object):
"""
Object-Orient dash component
"""
def __init__(self, divtype, component_property='value', string=str, **kwargs):
@asherp
asherp / filled_line_plot.py
Last active Jun 9, 2018
Filled line color plot [plotly]. Uses interpolating bezier shape to mask a color contour plot.
View filled_line_plot.py
'''Bezier interpolation method based on
http://www.antigrain.com/research/bezier_interpolation/
'''
import numpy as np
import plotly.graph_objs as go
import colorlover as cl
def roll_forward(a, steps = 1, axis = 0):
return np.roll(a, steps, axis = axis)
View designer.html
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
#design_host {
position: absolute;
width: 100%;
height: 100%;
View designer.html
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
#design_host {
position: absolute;
width: 100%;
height: 100%;