Skip to content

Instantly share code, notes, and snippets.

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

kojix2

🔬
🧬 🖥️ ♋
View GitHub Profile
require 'benchmark_driver'
Benchmark.driver do |x|
x.prelude <<~RUBY
require 'numo/narray'
require 'prime'
class Integer
def devisors
[1].product(*prime_division.map { |p, n| (0..n).map { p**_1 } }).map { _1.inject(:*) }.sort
# c2ffi: Clang-based FFI wrapper generator
# https://github.com/rpav/c2ffi
namespace :c2ffi do
desc 'Generate metadata files (JSON format) using c2ffi'
task :generate do
FileUtils.mkdir_p('codegen/c2ffilogs')
header_files = FileList['■■■/src/*.h']
header_files.each do |file|
basename = File.basename(file, '.h')
@kojix2
kojix2 / ruby-htlisb最終報告.md
Last active September 25, 2022 09:27
ruby-htslib最終報告
@kojix2
kojix2 / ruby-ffi.rb
Last active January 29, 2021 06:04
Ruby-FFIとFiddleによる構造体のclone時の挙動の違い
require 'ffi'
class S < FFI::Struct
layout :i, :int
end
a = S.new
a[:i] = 10
@kojix2
kojix2 / monkey_struct.rb
Last active February 15, 2021 07:26
Ruby FFI bitfields
# frozen_string_literal: true
require "ffi"
module FFI
class BitStruct < Struct
class << self
# def union_layout(*args)
# Class.new(FFI::Union) { layout(*args) }
# end
@kojix2
kojix2 / ruby-htslib_Interim_report.md
Last active January 25, 2021 08:12
ruby-htslib Interim report
@kojix2
kojix2 / mol.rb
Last active September 5, 2020 08:39
XYZ file viewer - GR.rb
require 'gr'
require 'gr3'
require 'numo/narray'
require 'optparse'
# コマンドラインオプション
options = { radius: 1.0, size: 500 }
OptionParser.new do |opt|
opt.on('-o', '--output PATH', String) { |v| options[:save_path] = v }
opt.on('-r', '--radius VALUE', Float) { |v| options[:radius] = v }
@kojix2
kojix2 / bedtools_cheatsheet.md
Created August 6, 2020 02:35 — forked from ilevantis/bedtools_cheatsheet.md
Bedtools cheatsheet

Bedtools Cheatsheet

General:

Tools Description
flank Create new intervals from the flanks of existing intervals.
slop Adjust the size of intervals.
shift Adjust the position of intervals.
subtract Remove intervals based on overlaps b/w two files.