Skip to content

Instantly share code, notes, and snippets.

import iterutils
iterator letters: char {.closure.} =
for c in 'a' .. 'z':
yield c
# Now requires a parameter
iterator numbers(s: int): int {.closure.}=
var n = s
while true:
#!/usr/bin/env perl
# lisa-andrea, Dec 10 2016
my$f= $[;my
$ch=0;sub l{length}
sub r{join"", reverse split
("",$_[$[])}sub ss{substr($_[0]
,$_[1],$_[2])}sub be{$_=$_[0];p
(ss($_,$f,1));$f+=l()/2;$f%=l
();$f++if$ch%2;$ch++}my$q=r
import algorithm
proc rev[T](xs: openarray[T]): seq[T] =
result = newSeq[T](xs.len)
for i, x in xs:
#result[^i-1] = x # or:
result[xs.high-i] = x
type
@telatin
telatin / procedures.nim
Created August 19, 2020 11:20
Simple procedures in nim
import strutils
proc strutilsPolyA(sequence: string, length: int): string =
result = sequence & repeat('A', length)
proc vanillaPolyA(sequence: string, length: int): string =
result = sequence
for i in 1 .. length:
result &= 'A'
@telatin
telatin / parse_messages_calls.py
Last active August 3, 2020 13:12
Parse messages JSON files and print a report of calls
#!/usr/bin/env python3
from __future__ import (absolute_import, division,
print_function, unicode_literals)
import json
import sys
import json
import argparse
import pdb
import datetime
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
sub getRead {
my $self = shift;
state $line;
$self->{counter_fake}++;
if ($self->{counter_fake} < 4) {
say Dumper $self;
}
#@<instrument>:<run number>:<flowcell ID>:<lane>:<tile>:<x-pos>:<y-pos>:<UMI> <read>:<is filtered>:<control number>:<index>
@telatin
telatin / meta.yaml
Created June 24, 2020 09:40
Example `meta.yaml` to package a Perl "Module::Name" for Conda
{% set name = "perl-module-name" %}
{% set version = "0.01" %}
{% set sha256 = "de31386013dc32f46f4c00d19230eeecca0c33ed1f1b13403a08e087a0278a05" %}
package:
name: {{ name }}
version: {{ version }}
source:
url: https://cpan.metacpan.org/authors/id/X/XY/XYNICKNAME/Module-Name-{{ version }}.tar.gz
@telatin
telatin / .screenrc
Created June 23, 2020 09:34
GNU screen configuration file (~/.screenrc)
# Bind F11 and F12 (NOT F1 and F2) to previous and next screen window
bindkey -k F1 prev bindkey -k F2 next startup_message off
# Window list at the bottom.
hardstatus alwayslastline
hardstatus string "%-w%{= BW}%50>%n %t%{-}%+w%< | %c | %D %d"
# Enable mouse scrolling and scroll bar history scrolling
termcapinfo xterm* ti@:te@
#!/usr/bin/env perl
use 5.010;
use Term::ANSIColor;
use Data::Dumper;
use Carp qw(confess);
use FindBin qw($RealBin);
use lib "$RealBin/../lib/";
use FASTX::Reader;
use File::Basename;
# Print splash screen