Skip to content

Instantly share code, notes, and snippets.

// Adapted from http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345
var eps = 0.0000001;
function between(a, b, c) {
return a-eps <= b && b <= c+eps;
}
function segment_intersection(x1,y1,x2,y2, x3,y3,x4,y4) {
var x=((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4)) /
((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4));
var y=((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4)) /
((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4));
@haasn
haasn / about:config.md
Last active December 27, 2024 15:46
Firefox bullshit removal via about:config

Firefox bullshit removal

Updated: Just use qutebrowser (and disable javascript). The web is done for.

@PoisonAlien
PoisonAlien / readBam.C
Last active November 9, 2023 21:21
reading bam files in C using htslib
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <htslib/sam.h>
int main(int argc, char *argv[]){
samFile *fp_in = hts_open(argv[1],"r"); //open bam file
bam_hdr_t *bamHdr = sam_hdr_read(fp_in); //read header
bam1_t *aln = bam_init1(); //initialize an alignment
// JVM sizing options
-server -Xms40g -Xmx40g -XX:MaxDirectMemorySize=4096m -XX:PermSize=256m -XX:MaxPermSize=256m
// Young generation options
-XX:NewSize=6g -XX:MaxNewSize=6g -XX:+UseParNewGC -XX:MaxTenuringThreshold=2 -XX:SurvivorRatio=8 -XX:+UnlockDiagnosticVMOptions -XX:ParGCCardsPerStrideChunk=32768
// Old generation options
-XX:+UseConcMarkSweepGC -XX:CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -XX:+CMSClassUnloadingEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseCMSInitiatingOccupancyOnly
// Other options
-XX:+AlwaysPreTouch -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:-OmitStackTraceInFastThrow
@stdavis
stdavis / 1.md
Last active March 20, 2017 22:25
Dojo 1.9.3 `customBoot` layer not interning widget templates properly.

I'm having a problem with my layer file not properly interning my widget template strings resulting in separate requests for each template file: requests

I have set up a simple example repo with an application containing two widgets (App & Widget). My goal is to build my entire application (JS & HTML) into one file. Here's my build profile:

var profile = {
    basePath: '../src/',
    action: 'release',
    optimize: 'closure',
    selectorEngine: 'acme',
@davfre
davfre / bamfilter_oneliners.md
Last active January 18, 2025 22:47
SAM and BAM filtering oneliners
<html>
<head>
<script type="text/javascript">
//<![CDATA[
/* from R code https://github.com/genome-vendor/r-bioc-biostrings/blob/master/src/match_PWM.c */
function compute_pwm_score(pwm, S,offset)
{
var score=0.0;
@timyates
timyates / Biostar77288.groovy
Created July 24, 2013 10:57
Groovy version of 'Low resolution sequence alignment visualization' by @lindenb: https://github.com/lindenb/jvarkit#biostar77288
import java.awt.Insets
import groovy.xml.StreamingMarkupBuilder
import groovy.transform.*
class Biostar77288 {
private int ALN_WIDTH = 1000
private Map<String,Seq> sequences = [:].withDefault { new Seq( name:it ) }
private int maxLength = 0
@trestletech
trestletech / README.md
Last active February 16, 2017 15:24
Shiny Example #4 for Bioconductor

Bioconductor Shiny Example #4

Example Shiny App showing an example of being embedded in a larger, non-Shiny workflow.

This is an example Shiny app featuring some basic analysis of Ovarian Cancer gene expression data collected on the Affymetrix U133A platform. We filter the available genes and samples down to a much smaller matrix to make reproducibility simpler for a broader audience. The R code involved in sampling the data is available in this Gist as an R-Markdown file, and the sampled data are available in this Gist as Rds files.

To run the application, install shiny (install.packages("shiny")) then run the following command:

library(shiny)

@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 5, 2025 13:05
A badass list of frontend development resources I collected over time.