Skip to content

Instantly share code, notes, and snippets.

View clintval's full-sized avatar

Clint Valentine clintval

View GitHub Profile
@clintval
clintval / Counter.scala
Created November 25, 2020 01:43
Use a Bloom filter to count all the unique elements in an iterator, approximately
package com.twinstrandbio.math
import breeze.util.BloomFilter
import com.fulcrumgenomics.commons.util.SimpleCounter
import scala.reflect.runtime.{universe => ru}
/** Methods for counting. */
object Counter {
@clintval
clintval / how-to-download-wistia-hosted.md
Last active January 18, 2021 15:26
Download Wistia Video
  1. Go to the video’s URL
  2. Right-Click on the video and select “Copy link and thumbnail”
  3. Open a notepad and paste the link you just copied.
  4. Search for a link that contains ?wvideo=<id>, where the appended <id> is the video identifier code.
  5. Copy that the video identifier code in notepad, and append it to this link: http://fast.wistia.net/embed/iframe/<id>
  6. Open up a new browser tab using the newly created link, and the video will load full-screen.
  7. Use the developers tools to open up and view the source-code of the new video in another tab.
  8. Search for the first link/URL that ends in “.bin”
  9. Copy and paste that link into a new tab, and then replace the “.bin” with “.mp4”, and hit enter.
  10. The video should now be able to download the video.
@clintval
clintval / kindle.rb
Created January 17, 2021 18:41 — forked from tobi/kindle.rb
Download your Kindle Highlights to local markdown files. Great for Obsidian.md.
#!/usr/bin/env ruby
# gem install active_support
require 'active_support/inflector'
require 'active_support/core_ext/string'
# gem install webrick (only ruby3)
require 'webrick'
# gem install mechanize
@clintval
clintval / amplicon_record.rs
Created January 26, 2021 05:50
An amplicon record for VarDictJava's amplicon-mode
/// A record of output from VarDict/VarDictJava run in amplicon-aware mode.
#[derive(Debug, Deserialize)]
struct AmpliconVariant<'a> {
pub sample: &'a str,
pub interval_name: &'a str,
pub contig: &'a str,
pub start: u64,
pub end: u64,
pub ref_allele: &'a str,
@clintval
clintval / dxapp.json
Created January 30, 2021 16:15
DNAnexus App for checking md5
{
"name": "md5check",
"title": "MD5 checksum",
"summary": "Generate MD5 checksum of one or more files and save the output info in a text file. Hard timeout policy for 10hrs.Use batch input processing or instance of large storage if you have large amount of data to process. Questions go to [email protected]",
"dxapi": "1.0.0",
"version": "0.0.1",
"inputSpec": [
{
"name": "i_put",
"label": "Input File(s)",
@clintval
clintval / rasterize.md
Created February 23, 2021 01:34
Will rasterize PDFs, 4 at a time recursively, without anti-aliasing

Rasterize Recursively

 ❯ parallel -j4 convert -density 400 +antialias {} {.}.raster.pdf ::: **/*.pdf
@clintval
clintval / BiMap.scala
Created July 30, 2021 02:32
MIT License (see fgbio/commons for inspiration)
package com.twinstrandbio.collection
import scala.collection.compat._
import scala.collection.{StrictOptimizedIterableOps, mutable}
/** A mutable bi-directional map. There is a 1:1 mapping between keys and values. */
class BiMap[K, V]() extends mutable.Map[K, V]
with mutable.MapOps[K, V, mutable.Map, BiMap[K, V]]
with StrictOptimizedIterableOps[(K, V), mutable.Iterable, BiMap[K, V]] {
private val forward = mutable.HashMap.empty[K, V]
@clintval
clintval / download.sh
Created August 1, 2021 19:14
Download COSMIC
export TOKEN=???
curl -s -X GET \
-H "Content-Type: application/octet-stream" \
-H "Authorization: Bearer ${TOKEN}" "https://my.qiagendigitalinsights.com/bbp/data/files/cosmic" \
-o files.txt
parallel -k \
'curl -X GET \
-H "Content-Type: application/octet-stream" \
@clintval
clintval / FullyPeekableIterator.scala
Last active January 31, 2023 13:16
Peek as much as you'd like, memory allowing
/*
* The MIT License
*
* Copyright © 2022 Clint Valentine
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
package io.cvbio.collection
import io.cvbio.io.Io
import com.fulcrumgenomics.commons.collection.SelfClosingIterator
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent._
import scala.concurrent.duration.{Duration, DurationInt}
import scala.concurrent.{Await, ExecutionContext, Future}