Skip to content

Instantly share code, notes, and snippets.

@ctb
ctb / README.md
Last active April 10, 2020 21:01

Implement contig contamination analysis as in (blog post)

@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active May 15, 2025 03:57
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@spacejam
spacejam / rr-with-rust.md
Last active March 7, 2025 17:31
using rr with rust

using rust with rr

rr is a great debugging tool. it records a trace of a program's execution, as well as the results of any syscalls it executes, so that you can "rewind" while you debug, and get deterministic forward and reverse instrumented playback. it works with rust, but by default if you try it out, it could be pretty ugly when you inspect variables. if this bothers you, configure gdb to use a rust pretty-printer

rr is probably in your system's package manager.

usage

"""
From Luiz Irber.
Takes an SRA accession and determines the location of the .sra data file for automated or downloading.
Follows this format: ftp://ftp-trace.ncbi.nih.gov/sra/sra-instant/reads/ByRun/sra/{SRR|ERR|DRR}/<first 6 characters of accession>/<accession>/<accession>.sra
Format according to NCBI utility handbook: https://www.ncbi.nlm.nih.gov/books/NBK158899/
"""
def sra_url(accession):
"""Returns predicted URL given SRA accession as input."""
accession = accession.upper()
@blahah
blahah / internet_of_data_transforms.md
Last active February 29, 2020 17:50
Ways dat can be leveraged to transform science, #1 - the internet of data transforms

dat is an incredibly powerful technology for peer to peer sharing of versioned, secure, integrity-guaranteed data.

One thing it excels at is populating a live feed of data points from one source, and allowing any number of peers to subscribe to that feed. The data can only originate from the original source (this is guaranteed using public-key encryption), but the peers in the network can still sync the new data with one another. To subscribe to a given source you only need to know an alphanumeric key that uniquely identifies the source, and is automatically generated by dat.

There are many ways that this simple system can be used to build a new infrastructure for science. This is the first in a series of posts in which I'll explain how.

Here I briefly describe some ways dat can be used to automate some aspects of scientific discovery, increase resource and information reuse efficiency, and help keep our information resources up to date with science (a topic I will expand on signif

@dkoslicki
dkoslicki / JaccardEstimateViaContainment.py
Created April 24, 2017 17:11
Testing typical bottom-k min hash estimate of Jaccard index versus containment estimate of Jaccard index
import sourmash_lib
import numpy as np
import matplotlib.pyplot as plt
from pybloom import BloomFilter
n = 10000 # sequence length
ksize = 10 # k-mer length
h = 100 # number of hashes in sketch
i_range = range(1, 50000, 500) # range of intersection sizes
#i_range = [10000]
@shoyer
shoyer / xarray-tutorial-cleared.ipynb
Last active November 25, 2023 03:59
Xarray tutorial for Rossbypalooza
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vasanthk
vasanthk / System Design.md
Last active May 16, 2025 07:32
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@0XDE57
0XDE57 / config.md
Last active May 14, 2025 03:10
Firefox about:config privacy settings

ABOUT

about:config settings to harden the Firefox browser. Privacy and performance enhancements.
To change these settings type 'about:config' in the url bar. Then search the setting you would like to change and modify the value. Some settings may break certain websites from functioning and rendering normally. Some settings may also make firefox unstable. I am not liable for any damages/loss of data.

Not all these changes are necessary and will be dependent upon your usage and hardware. Do some research on settings if you don't understand what they do. These settings are best combined with your standard privacy extensions (HTTPS Everywhere No longer required: Enable HTTPS-Only Mode, NoScript/Request Policy, uBlock origin, agent spoofing, Privacy Badger etc), and all plugins set to "Ask To Activate".

#!/bin/sh
jq -r 'def banner: "\(.) " + (28-(.|length))*"-";
("Non-cell info" | banner), del(.cells), "",
(.cells[] | ("\(.cell_type) cell" | banner),
"\(.source|add)",
if ($show_output == "1") then
"",
( select(.cell_type=="code" and (.outputs|length)>0) |
("output" | banner),
(.outputs[] |