Skip to content

Instantly share code, notes, and snippets.

View kojix2's full-sized avatar
🔬
🧬 🖥️ ♋

kojix2

🔬
🧬 🖥️ ♋
View GitHub Profile
@vincentchu
vincentchu / smith-waterman.rb
Created June 23, 2011 05:50
Smith Waterman implementation in Ruby
class Matrix
IndexOverflow = Class.new(StandardError)
attr_reader :dims, :nrows, :ncols
def initialize(mm, nn)
@dims = [mm, nn]
@nrows = mm
@ncols = nn
@DQNEO
DQNEO / convert_annotate.sh
Created March 26, 2014 09:39
[ImageMagick]convertコマンドで写真に文字を入れる
$ convert -pointsize 300 -gravity south -font Times-Roman -annotate 0 "aaaaa" -fill red flower.jpg out.jpg
# -pointsize 文字の大きさ
# -gravity 文字の位置
# -font フォント
# -annotate 数値:文字の傾き 文字列:テキスト
# -fill 文字の色
@junpeitsuji
junpeitsuji / binom.rb
Last active March 6, 2020 00:30
binom.rb - 二項係数を3パターンで実行するスクリプト
require 'benchmark'
_MAXNUM=1000
#=begin
# 二項係数 nCk を計算する関数 ver.1
def binom_v1(n,k)
if k==0 then
return 1
@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
@parmentf
parmentf / GitCommitEmoji.md
Last active July 4, 2024 10:57
Git Commit message Emoji
# It is show-the-point demo for my article
# "On DataFrame datatype in Ruby" http://zverok.github.io/blog/2016-01-10-dataframe.html
require 'good_data_frame' # `require': cannot load such file -- good_data_frame (LoadError)
# Initialization (with default index): hashes of column: values
# Values of each column are homogenous
# First and most important thing is "what columns is"
table = GDF.new(
manager: ['Tom', 'Jerry', 'Magda'],
@PolarNick239
PolarNick239 / rgb_to_hsv_np.py
Last active January 14, 2023 10:48
numpy RGB to HSV
#
# Copyright (c) 2016, Nikolay Polyarnyi
# All rights reserved.
#
import numpy as np
def rgb_to_hsv(rgb):
"""
Let [tag] = any tag in upstream repo
git fetch upstream --tags
git push origin --tags
@mono0926
mono0926 / commit_message_example.md
Last active June 24, 2024 02:44
[転載] gitにおけるコミットログ/メッセージ例文集100
@komasaru
komasaru / conv_camel_snake.rb
Created October 28, 2016 08:48
Ruby script to convert CamelCase and snake_case each other.
class String
def to_camel
self.split(/_/).map(&:capitalize).join
# or
#self.split(/_/).map{ |w| w[0] = w[0].upcase; w }.join
end
def to_snake
self.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')