Skip to content

Instantly share code, notes, and snippets.

@iwazer
iwazer / waiting_for_table_metadata_lock.md
Created September 27, 2021 07:30
MySQLオンラインDDLのWaiting for table metadata lockについて

オンラインDDLのWaiting for table metadata lockについて

(1) トランザクション中に対象のテーブルをSELECT
A: begin;
A: select * from target_table where id=1;

(2) 対象のテーブルにオンラインDDLを実行
B: CREATE INDEX a_target_table_index ON target_table  (field1, field2);
app.files_dependencies “foo.rb" => "#{Bundler.bundle_path}/gems/sugarcube-3.0.0/lib/cocoa/sugarcube-files/nsstring.rb"
@iwazer
iwazer / gist:77da0531bc719a84b0d3
Created November 7, 2014 03:17
rubymotion YAML trouble
YAML.load('["a","b"]')
#=> ["a", "b"]
YAML.load('["あ","い"]')
#=> nil
$ rake preload=true
/Users/e-iwazawa/Develop/github/motioncv-test/vendor/opencv/motioncv.gemspec:2: warning: already initialized constant VERSION
Create ./app/_preload_.rb
+ /Library/RubyMotion/data/ios/7.0/BridgeSupport/AVFoundation.bridgesupport
+ /Library/RubyMotion/data/ios/7.0/BridgeSupport/AssetsLibrary.bridgesupport
+ /Library/RubyMotion/data/ios/7.0/BridgeSupport/CoreGraphics.bridgesupport
+ /Library/RubyMotion/data/ios/7.0/BridgeSupport/Foundation.bridgesupport
+ /Library/RubyMotion/data/ios/7.0/BridgeSupport/UIKit.bridgesupport
+ ./vendor/opencv/framework/opencv2.framework/opencv2.framework.bridgesupport
Build ./build/iPhoneSimulator-7.0-Development

こういうモデルで

ActiveRecord::Schema.define(version: 20130922022806) do

  create_table "models", force: true do |t|
    t.string   "field1"
    t.string   "field2"
    t.datetime "created_at"
 t.datetime "updated_at"
#
# This Snippet may do to be able to refer all definitions of libraries
# from RubyMotion REPL, when You paste this Snippet on bottommost of
# your RubyMotion Rakefile. But it is very slow...
#
# Usage:
# rake preload=true # generate preload source file before build simulator
#
# rake preload:clean # delete preload source file
#

RubyMotionのREPLで全ての定数とClassを参照可能にする拡張(案)

Rakefileに何らかの定義を書くかや起動オプションの指定で、全てのBridgeSupportファイルの定数やクラスなどを参照実行するプログラムがコンパイルされて、REPLから見えるようになるモードがあると便利そうだ。

  1. Path: /Library/RubyMotion/data/[ios|osx]/[version]/BridgeSupport/[framework].bridgesupport
  2. Rakefileに定義されているFrameworkのBridgeSupportファイルを読み込む
  • デフォルトで定義されてる3つ
  • 追加されているFramework
  • vendor/**/*.bridgesupport
app.vendor_project('vendor/opencv2.framework', :static,
products: ['opencv2'],
source_files: ['Headers/imgproc/imgproc_c.h', 'Headers/imgproc/types_c.h',
'Headers/motion/MotionCV.h', 'Headers/motion/MotionMat.h'],
force_load: false
)
# -*- coding: utf-8 -*-
Motion::Project::App.setup do |app|
:
app.frameworks += ['AVFoundation','AssetsLibrary']
app.libs += ['-lc++']
:
app.vendor_project('vendor/opencv2.framework', :static,
products: ['opencv2'],
force_load: false
class GreyScaleViewController < UIViewController
:
def viewDidLoad
super
srcMat = MotionCV.MotionMatFromUIImage(UIImage.imageNamed("sato.jpg"))
greyMat = MotionMat.new
MotionCV.cvtColorInput(srcMat, output:greyMat, code:CV_BGR2GRAY)
@imageView.image = MotionCV.UIImageFromMotionMat(greyMat)
end
end