Skip to content

Instantly share code, notes, and snippets.

@dandavison
dandavison / index.html
Created Apr 3, 2021
vue-file-agent: Preloading Exising Files Demo
View index.html
<script type="text/x-template" id="vue-file-agent-demo">
<div>
<VueFileAgent
:uploadUrl="'https://www.mocky.io/v2/5d4fb20b3000005c111099e3'"
:uploadHeaders="{}"
:multiple="true"
:deletable="true"
:editable="true"
:meta="true"
:accept="'image/*,video/*,.pdf,.zip'"
View prepare_bug.rs
fn prepare(line: &str) -> String {
if !line.is_empty() {
let mut line = line.chars();
let prefix = line.next().unwrap();
let output_line = line.collect::<String>();
format!("{}{}", prefix, output_line)
} else {
"<empty line>".to_string()
}
}
View decorator_for_recording.py
#!/usr/bin/env python
from scipy.optimize import bisect
def record_optimization(func):
def recorder(self, *args, **kwargs):
if not hasattr(self, '_recorder_inputs'):
self._recorder_inputs = []
View compile-tmux.sh
#!/bin/bash
set -e
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
make
sudo make install
View nahin.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:4780d40a866e0b942ff9

Two columns satisfy a "one-to-one" constraint if each value in column 1 is associated with exactly one value in column 2, and vice versa. E.g. in this data, the person column and the email column satisfy a one-to-one constraint:

>>> table = [('pablo', 'ppicasso@gmail.com'),
             ('georgia', 'gokeefe@hotmail.com'),
    	     ('mark', 'mrothko@aol.com')]
>>> is_one_to_one(table)
View delete_empty_report_objects.py
from collections import Counter
from django.db import transaction
from django.db.models import Q
from counsyl.product.common.state import flow
from counsyl.product.mynomics.models import ChildReport
from counsyl.product.mynomics.models import PersonReport
View cube.coffee
width = 500
height = 300
cube =
nodes: [
{x: 0, y: 0, z:0},
{x: 0, y: 0, z:1},
{x: 0, y: 1, z:0},
{x: 0, y: 1, z:1},
{x: 1, y: 0, z:0},
@dandavison
dandavison / chart.coffee
Created Nov 27, 2012
d3 reusable chart: coffeescript
View chart.coffee
class BaseChart
constructor: ->
@_width = 720
@_height = 80
draw: (selection) =>
me = @
selection.each( (d, i) -> me._draw(this, d, i) )