Skip to content

Instantly share code, notes, and snippets.

View viklund's full-sized avatar
:octocat:
Always be gitin'

Johan Viklund viklund

:octocat:
Always be gitin'
View GitHub Profile
@viklund
viklund / hitomi
Created May 12, 2009 20:10
hitomi test
#!perl6
# A lot of the subs in this one can be simplified and merged
class For {
has $.value;
method perl { "For.new('$.value')" }
}
class If {
cc -o perl6.o -I/home/viklund/proto-2009-06-02/rakudo/parrot/include -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHASATTRIBUTE_CONST -DHASATTRIBUTE_DEPRECATED -DHASATTRIBUTE_MALLOC -DHASATTRIBUTE_NONNULL -DHASATTRIBUTE_NORETURN -DHASATTRIBUTE_PURE -DHASATTRIBUTE_UNUSED -DHASATTRIBUTE_WARN_UNUSED_RESULT -falign-functions=16 -fvisibility=hidden -funit-at-a-time -maccumulate-outgoing-args -W -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wdisabled-optimization -Wendif-labels -Wextra -Wformat -Wformat-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimplicit -Wimport -Winit-self -Winline -Winvalid-pch -Wlogical-op -Wmissing-braces -Wmissing-field-initializers -Wno-missing-format-attribute -Wmissing-include-dirs -Wpacked -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wno-shadow -Wsign-compare -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default -Wtrigraphs -Wundef -Wunkno
#!/home/johan/perl6/rakudo/perl6
sub unescape($s is rw) {
my $string = $s;
$string .= subst('+', ' ', :g);
# RAKUDO: This could also be rewritten as a single .subst :g call.
# ...when the semantics of .subst is revised to change $/,
# that is.
while $string ~~ /\%(<[0..9A..F]>**2)/ {
my $match = $0;
use v6;
multi infix:<compress> ( $a, $b ) { $a ~~ $b ?? $a !! [ $a, $b ] }
multi infix:<compress> ( @a, $b ) { @a[*-1] ~~ $b ?? @a !! [ @a, $b ] }
say ([compress] <a a a a b c c a a d e e e e>).perl;
use v6;
enum TG <B C D>;
class A { }
my $a1 = A.new( ) but B;
my $a2 = A.new( ) but C;
for $a1, $a2 {
May-31 05:24:56.746 [main] DEBUG nextflow.cli.Launcher - $> /home/vagrant/bin/nextflow run hello
May-31 05:24:56.813 [main] INFO nextflow.cli.CmdRun - N E X T F L O W ~ version 0.19.2
May-31 05:24:57.037 [main] DEBUG nextflow.scm.AssetManager - Listing projects in folder: /home/vagrant/.nextflow/assets
May-31 05:24:57.042 [main] INFO nextflow.cli.CmdRun - Pulling nextflow-io/hello ...
May-31 05:24:57.043 [main] DEBUG nextflow.scm.RepositoryProvider - Request [credentials -:-] -> https://api.github.com/repos/nextflow-io/hello/contents/nextflow.config
May-31 05:24:58.247 [main] DEBUG nextflow.scm.RepositoryProvider - Request [credentials -:-] -> https://api.github.com/repos/nextflow-io/hello/contents/main.nf
May-31 05:24:58.797 [main] DEBUG nextflow.scm.RepositoryProvider - Request [credentials -:-] -> https://api.github.com/repos/nextflow-io/hello
May-31 05:24:58.943 [main] DEBUG nextflow.scm.AssetManager - Pulling nextflow-io/hello -- Using remote clone url: https://github.com/nextflow-io/hello.git
May-31
$ awk '$4>50 && $3>90 && F[$1]++ < 1{print}' blast_result
$4 is column 4 i.e. length, larger than 50bp
$3 percent identity bigger than 90
F[$1]++ < 1 is the tricky part. We count upwards for each query we find and as long as the number
is less than 1 it is true, since the ++ is after the F[$1] the value will be zero the first time
and 1 the second time and so on.
@viklund
viklund / number_of_commits.rb
Created October 16, 2017 13:49
Number of commits per repo on the NBISweden github repo
#!/usr/bin/env ruby
require 'octokit'
require 'set'
def repo_name(repo)
return ORG + "/" + repo[:name]
end
ORG = "NBISweden"
import markovify
import json
import os
users = json.load(open('slack/users.json'))
user = ''
for u in users:
if u['name'] == 'viklund':
user = u['id']
#!/bin/bash
MYSQL_PORT=3366
MYSQL_HOST=127.0.0.1
MYSQL_PASS=rootpw
# Start a mysql instance with docker for example like this:
docker volume create swefreq-mysql-data
docker run -v swefreq-mysql-data:/var/lib/mysql --rm --name mysql -e MYSQL_ROOT_PASSWORD=$MYSQL_PASS -d -p $MYSQL_PORT:3306 mysql