Skip to content

Instantly share code, notes, and snippets.

View jwbargsten's full-sized avatar

Joachim Bargsten jwbargsten

View GitHub Profile
@jwbargsten
jwbargsten / corr_light_intensity.R
Created September 3, 2012 21:09
correlation analysis - light intensity experiment
# Copyright (c) 2012 Joachim Bargsten
#
# 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 furnished to do so, subject to the following
# conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial
# portions of the Software.
@jwbargsten
jwbargsten / makeTranscriptDbFromGFF3.R
Created September 18, 2012 15:23
Create TranscriptDb objects from GFF3 files
## source: http://permalink.gmane.org/gmane.science.biology.informatics.conductor/40247
require(plyr)
require(rtracklayer)
require(GenomicRanges)
require(GenomicFeatures)
## determine the rank for all exons of a transcript
## the rank is reversed, if the strand is negative
.exon_rank_order <- function(exon.starts, strands) { order(exon.starts, decreasing=strands[1] == '-') }
@jwbargsten
jwbargsten / density2d_map.R
Created July 18, 2013 15:03
plot pretty 2d density map with ggplot2
library(ggplot2)
library(MASS)
## generate some random data
data <- data.frame(a=abs(rnorm(1000, mean=0.5)), b=abs(rnorm(1000, mean=0.5)))
data$a <- data$a / max(data$a)
data$b <- data$b / max(data$b)
## layout settings for ggplot
@jwbargsten
jwbargsten / ajping.py
Last active August 29, 2015 14:01
pings a servlet engine with AJP protocol
#!/usr/bin/env python
# source: http://www.joedog.org/pub/AJP/ajping.txt
from struct import unpack
import time
import sys
import socket
acks = set([65, 66, 0, 1, 9])
@jwbargsten
jwbargsten / setup.cfg
Created May 25, 2020 10:30 — forked from althonos/setup.cfg
A `setup.cfg` template for my Python projects
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c
[metadata]
name = {name}
version = {version}
author = Martin Larralde
author-email = [email protected]
home-page = https://github.com/althonos/{name}
description = {description}
long-description = file: README.rst, CHANGELOG.rst
@jwbargsten
jwbargsten / parseflags.sh
Created April 22, 2021 13:40 — forked from bxparks/parseflags.sh
Simple Bash Shell Command Line Processing Template
#!/bin/bash
#
# Self-contained command line processing in bash that supports the
# minimal, lowest common denominator compatibility of flag parsing.
# -u: undefined variables is an error
# -e: exit shell on error
set -eu
function usage() {
@jwbargsten
jwbargsten / deskew.java
Created September 13, 2021 20:49 — forked from witwall/deskew.java
Automatic image deskew in Java http://anydoby.com/jblog/en/java/1990 Those who have to process scans should know how painful it is to manually deskew images. There are several approaches to do this deskewing automatically. The basis of all the methods is to identify lines following the same direction in a image and then by deviation from horizon…
public double doIt(BufferedImage image) {
final double skewRadians;
BufferedImage black = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_BINARY);
final Graphics2D g = black.createGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
skewRadians = findSkew(black);
System.out.println(-57.295779513082320876798154814105 * skewRadians);
return skewRadians;
@jwbargsten
jwbargsten / esm-package.md
Created March 6, 2022 11:10 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@jwbargsten
jwbargsten / Effective Scala Case Class Patterns.md
Created May 26, 2022 09:05 — forked from chaotic3quilibrium/Effective Scala Case Class Patterns.md
Article: Effective Scala Case Class Patterns - The guide I wished I had read years ago when starting my Scala journey

Effective Scala Case Class Patterns

Version: 2022.03.02

Available As