Skip to content

Instantly share code, notes, and snippets.

View miio's full-sized avatar

miio mitani miio

  • Sapporo, Hokkaido, Japan
View GitHub Profile
@miio
miio / FixDS-Lite.bash
Last active March 30, 2024 07:10
UDM Pro で固定IPv4を使いたい場合やDS-Liteが挙動おかしいときに作ったスクリプト
# DS-Lite修正
# 参考
# https://techlog.iij.ad.jp/contents/dslite-raspi
REMOTE=''
# SLAAC シングルの人は多分これでいける
# LOCAL=`ip addr show br0 | grep 'mngtmpaddr' | awk '{print $2}' | awk -F/ '{print $1}'`
# DHCP-PDv6の人はこっち
LOCAL=`ip addr show br0 | grep 'inet6' | grep 'dynamic' | awk '{print $2}' | awk -F/ '{print $1}'`
@miio
miio / equipment_color.rb
Last active January 1, 2016 18:29 — forked from maraigue/equipment_color.rb
ActiveDecorator使うときっとこんな感じになりそう(未検証)
# app/decorators/character_decorator.rb
# for https://github.com/kyubuns/misterioso/commit/3598eec678cf7368e105141b1cd7b8c259f1af12
module CharacterDecorator
EQUIPMENT_COLOR_TABLE = {
1 => 'black',
2 => 'orange',
3 => 'forestgreenq',
4 => 'blue',
@miio
miio / ix2015-ggj2014
Last active January 1, 2016 04:39
GGJ用に仕込み中のIX2015コンフィグ(一部隠してますが
! NEC Portable Internetwork Core Operating System Software
! IX Series IX2010 (magellan-sec) Software, Version 8.3.47, RELEASE SOFTWARE
! Compiled Aug 27-Fri-2010 10:36:11 JST #1
! Last updated Dec 23-Mon-2013 15:57:03 JST
!
!
hostname sanjose
timezone +09 00
!
!
@miio
miio / class.php
Created December 5, 2013 01:31
benchmark test
<?php
class A {
public function getA() {
return "A";
}
}
function getA() {
return "A";
@miio
miio / flickr_exif.rb
Last active December 18, 2015 00:39
require 'flickraw'
require 'open-uri'
require 'exifr'
class ConnectionAdapter
def connection
FlickRaw.api_key = ""
FlickRaw.shared_secret = ""
flickr.access_token = ""
flickr.access_secret = ""
MAP_MIN = 0
MAP_MAX = 3000
BLOCK_SIZE = 10
DEBUG = false
# [level1_rate, level2_rate, ...]
RATE = [
25,
20,
15,
11,
@miio
miio / astar.rb
Last active December 15, 2015 08:39
@near_blocks = []
@cost = nil
def nears(i,j)
[[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
end
def near_astar map_sizes, ignores, target, current
x = current[:x]
y = current[:y]
class UserHighScore < ActiveRecord::Base
belongs_to :user
belongs_to :high_score_partition
attr_accessible :score
after_save do
partition = HighScorePartition.where("(min < ? AND ? > max)", self.score, self.score).first("LOCK IN SHARE MODE")
# Not partition if cheet?
raise "Score not range partition" unless partition
# Not modify
return true partition.id == self.high_score_partition.id
class MaterialPermissionHandler < ApplicationPermissionHandler
CODE_NAMES = [
:show, :update, :delete, :edit
]
def has_perm? user, code_name, object_id
obj = Material.find_by_id object_id
# Accept author.
return true if user == obj.user
case code_name
user_name = "miio"
remote_addr = "git@github.com:miio/grit_test.git"
clone_args = {quiet: false, verbose: true, progress: true, branch: 'master'}
# Open Repository
central = create_or_open './storage/central/miio/grit_test/', remote_addr, clone_args
working = create_or_open './storage/working/miio/grit_test/', './storage/central/miio/grit_test/', clone_args
# Add Remote Branch
begin