Skip to content

Instantly share code, notes, and snippets.

@nanki
nanki / hem
Created April 29, 2014 02:01
heavy exclamation mark
❗️❗️❗️❗️❗️❗️
import IOBluetooth
class A: NSObject, CBCentralManagerDelegate {
var c: CBCentralManager!
init() {
super.init()
c = CBCentralManager(delegate:self, queue:nil)
}
@nanki
nanki / ble.rb
Last active December 10, 2016 14:21
framework 'IOBluetooth'
class A
def initialize
@c = CBCentralManager.alloc.initWithDelegate(self, queue:nil)
end
def centralManagerDidUpdateState(central)
if central.state == CBCentralManagerStatePoweredOn
@c.scanForPeripheralsWithServices(nil, options:nil)
@nanki
nanki / tag.rb
Created April 2, 2015 23:32
tag EBS volumes
require 'aws-sdk-core'
require 'aws-sdk-resources'
require 'yaml'
config = YAML.load_file('config.yml')[:tag]
Aws.config.update(
region: 'ap-northeast-1',
credentials: Aws::Credentials.new(config[:access_key_id], config[:secret_access_key])
)
@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))
}
# OK
class A
def a=(a)
@a = a
end
end
# OK
class B
def a=(a);@a = a;end
@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
@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 / 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 / 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'