Skip to content

Instantly share code, notes, and snippets.

import pool from "ndarray-scratch"
import pack from "ndarray-pack"
import concatRows from "ndarray-concat-rows"
import concatCols from "ndarray-concat-cols"
import qr from "ndarray-householder-qr"
export function regression2d(
y0,
y1,
x0,
import { promises as fs } from "fs";
import createContext from "gl";
import beamcoder from "beamcoder";
const w = 100, h = 100;
async function main() {
const decoder = beamcoder.decoder({
@nanki
nanki / gnomonic.py
Created March 9, 2019 16:05
gnomonic transformation
import numpy as np
from PIL import Image
from skimage import transform
def gnomonic2equirectangular(ishape, oshape, fov):
def inner(xy):
ones = np.expand_dims(np.ones(xy.shape[0]), 0).transpose()
v = np.concatenate((xy, ones), axis=1)
v /= np.linalg.norm(v, axis=1, keepdims=True)
#!/usr/bin/osascript
tell application "Terminal"
contents of selected tab of the front window
end tell
@nanki
nanki / vim-runner.sh
Created September 28, 2018 10:36
vim runner
#!/bin/sh
vim -T builtin_dumb --not-a-term -c "$1" -c 'qa!' --cmd 'set nomore t_cl= t_cm=.' | sed -e 's/\.//g'
@nanki
nanki / file0.txt
Created December 30, 2017 11:06
astropyで初日の出の時間を計算する🌅 ref: https://qiita.com/nanki/items/97191fee71ec5a3255f5
import astropy.coordinates
import astropy.units as u
from astropy.coordinates import EarthLocation, AltAz
from astropy.time import Time
from datetime import datetime
from scipy import optimize
tt = EarthLocation(lat=35.6585 * u.deg, lon=139.7455 * u.deg, height=250 * u.m)
def alt(timestamp):
@nanki
nanki / ff
Created September 8, 2015 06:38
file finder
#!/usr/bin/env ruby
# -*- coding: UTF-8 -*-;
require 'open3'
require 'shellwords'
EDITOR = ENV['EDITOR'] || 'vim -b'
EXCLUDE_EXTENTSONS = %w(psd gif jpg png DS_Store tmp JPG PNG swp swf o bundle dylib so)
@nanki
nanki / aobench.cr
Last active August 29, 2015 14:23 — forked from genki/aobench.cr
IMAGE_WIDTH = 256
IMAGE_HEIGHT = 256
NSUBSAMPLES = 2
NAO_SAMPLES = 8
class Vec
def initialize(x, y, z)
@x = x
@y = y
@z = z
# OK
class A
def a=(a)
@a = a
end
end
# OK
class B
def a=(a);@a = a;end
@nanki
nanki / mandelbrot.go
Created May 16, 2015 02:47
Vintage and modern Mandelbrot set in Go.
package main
import "fmt"
import "math/cmplx"
func dot(bits uint8) string {
bits = bits & 7 | (bits & 112) >> 1 | (bits & 8) << 3 | bits & 128
return string(0x2800 + uint32(bits))
}