Rodhos Soft

備忘録を兼ねた技術的なメモです。Rofhos SoftではiOSアプリ開発を中心としてAndroid, Webサービス等の開発を承っております。まずはご相談下さい。

2018-01-01から1年間の記事一覧

既存メソッドの拡張

declare interface String { getCount(): number; } (String.prototype as any).getCount = function () { return this.length; }; でimportする。

iframeとタイマー

タイマーでiframeを切り替えてみた。 function getID(identifier:string):string { return '[data-id="' + identifier +'"]' } const x:JQuery<HTMLIFrameElement> = $(getID("child")) as JQuery<HTMLIFrameElement> const y = x.get(0); setTimeout(function(){ y.src ="./hoge.html"; },2000) y.</htmliframeelement></htmliframeelement>…

文字列受け渡し

class Hello { companion object { init { System.loadLibrary("Hello") } } external fun printHello() external fun printNative(str:String, len:Int); } fun main(args: Array<String>) { Hello().printHello() val str = "hello form kotoln" Hello().printNati</string>…

kotlinでhelloworld

class Hello { companion object { init { System.loadLibrary("Hello") } } external fun printHello() } fun main(args: Array<String>) { Hello().printHello() } でコンパイル kotlinc hello.kt前回同様ライブラリを用意して実行 kotlin HelloKt</string>

hello world

fun main(args: Array<String>) { println("Hello, World!") } ```` として kotlinc hello.kt でコンパイル。できたら実行 kotlin HelloKt</string>

cppでhelloworld

cのときと同様でhello.cppを作る。 #include "Hello.h" #include <iostream> extern "C" { JNIEXPORT void JNICALL Java_Hello_printHello (JNIEnv *env, jclass obj) { std::cout << "hello cpp" << std::endl; } } あとはコンパイル時に-libc++をつける。 gcc -share</iostream>…

cでhelloworld

java側を用意 public class Hello { static{ System.out.println(java.library.path); System.loadLibrary("Hello"); } static native void printHello(); public static void main(String args[]){ printHello(); } } コンパイル javac Hello.java C側を作…

チュートリアル2

さらに簡単な例 #include <rxcpp/rx.hpp> rxcpp::observable<std::string> twice(std::string word) { return rxcpp::observable<>::just(word + word); } rxcpp::observable<int> length(std::string word) { int l = (int)word.length(); return rxcpp::observable<>::just(l); } rxcpp::ob</int></std::string></rxcpp/rx.hpp>…

チュートリアル

一番簡単な使い方 rxcpp::observable<int> obs = rxcpp::observable<>::create<int> ( [=](rxcpp::subscriber<int> s) { s.on_next(100); s.on_next(200); s.on_next(300); s.on_completed(); } ); auto x = obs.flat_map([=](int x) { return rxcpp::observable<>::just(x </int></int></int>…

ライブラリ

Boost Libraries

variant 共用体

かなり便利なことがわかった。 #include <boost/variant.hpp> #include <iostream> int main(int argc, const char * argv[]) { // insert code here... std::cout << "Hello, World!\n"; boost::variant<int, std::string> v; v = 100; boost::variant<int, std::string> s; s = "200"; if (v.type() == typeid(int)) { int l =</int,></int,></iostream></boost/variant.hpp>…

boost設定

Macの場合。brewでinstall /usr/local/Cellar/boost/1.67.0_1 ここにincludeヘッダーとlibがあるのでXCodeのパスを通す。 Header Search Pathsにinclude Library Search Pathsにlib non-recursiveOther linker flagに -lboost_system設定

チュートリアル的な記述7

cpp

typeerase的なものを作ってみたがポインタ周りが怪しいので修正中 #include "TypeErase.hpp" #include <iostream> #include <map> class AnyBase; using AnyBase_sp = std::shared_ptr<AnyBase>; class AnyBase { public: AnyBase() = default; virtual ~AnyBase() = default; templa</anybase></map></iostream>…

チュートリアル的な記述6

cpp

継承やテンプレートなどを色々使ってみた。 #include <iostream> void hello() { std::cout << "hello/bye" << std::endl; std::string s; while (true) { std::cin >> s; if (s == "hello") { std::cout << "hello!" << std::endl; } else if (s == "bye") { std::cou</iostream>…

チュートリアル的な記述5

cpp

クラス、構造体 // class デフォルトのアクセス指定子がprivate // struct デフォルトのアクセウ指定子がpublic struct Animal; struct Man2; struct Animal { int age = 10; virtual void attack(); }; struct Man2 : Animal { typedef std:: shared_ptr<std::string> st</std::string>…

チュートリアル的な記述4

cpp

ファイル操作 #include <iostream> #include <fstream> void fileSample() { // file std::ofstream ofs("test.txt"); if (!ofs) { std::cerr << "[error]open file" << std::endl; std::exit(1); } ofs << "Hello, World\n123" << std::endl; // auto close std::ifstream ifs(</fstream></iostream>…

チュートリアル的な記述3

cpp

変数 #include <sstream> #include <iomanip> #include <fstream> void basicVariable() { const int c = 10; // ref int r = 0; int& r2 = r; r2 = 100; std::cout << r << std::endl; // 100 // 構造体 Point p; p.x = 10; p.y = 10; std::cout << p.d2() <</fstream></iomanip></sstream>

チュートリアル的な記述2

cpp

参照 // class class CPYCost { public: CPYCost(); ~CPYCost(); /// オブジェクトのコピー用の代入演算子 CPYCost& operator=(const CPYCost& rhs); int x; private: }; void refAdd(int &x); void pAdd(int *x); void refUse() { // 参照 int x = 1; int& …

チュートリアル的な記述

cpp

関数 int twice(int x); int twice(int x) { return x * 2; } auto nfunc2(int x) -> decltype(x) { return x * 100; } namespace FunctionauUse { int add(int x); void echo(int x); } /// 関数を変数に格納する。 void functionalUse() { std::function<void(int)> f</void(int)>…

window.location.hrefがきかない

iOS

バグがある。 How to fix window.location issue in iOS9 UIWebview - Stack OverflowsetTimeOutで次のイベントループまでまって実行してやる必要がある。

WKWebViewのデバッグ

iOS

iosのsafariの設定の詳細のwebインスペクタをON macのsafariの開発者モードでデバッグ

開発用サーバ

WebPackの開発用サーバを使う。 webpack-dev-serverをnpmでインストール。 webpack.config.jsに devServer: { contentBase: path.resolve(__dirname, 'app'), port: 3000 } を等と設定、また、outputのpublicPathも追加してcontentBaseに合わせておく(そうし…

履歴をしらべてコピーする。

履歴を調べて古かったらコピーするというスクリプトを書いてみた。 makefileの代わりに import sys import os import shutil import re # pathlistで指定したフォルダのファイルに対応するファイルがbasepath以下にある場合、basepathの方が古くなっていたら…

plugin

webpack plugin webpack pluginは apply(compiler) {} を持つクラスとして定義して、 webpack.config.jsにおいて plugins: [ new HelloPlugin() ] のように入れてやれば良い。 const pluginName = 'HelloPlugin'; class HelloPlugin { apply(compiler) { com…

localhostの場所の確認

web

サーバ確認 httpdはhttpデーモン このhttpデーモンがapacheか確認する。 httpd -v これがapacheと出たら つまりapacheのコマンド apachectl と同じということ。 コンフィグファイル(/httpd.conf)の場所を調べる。 httpd -V conf内の DocumentRootの場所を調…

初歩

javaプラグインの使用 build.gradle apply plugin: 'java' プロジェクトとタスク プロジェクトは複数のタスクから構成される。 タスク 分割不可能な作業単位 build.gradle task hello << { println 'Hello world!' } 実行は gradle -q hello -qはログの抑制 …

出力先

pathを絶対パスに変換してoutputで指定してやれば良い。 const path = require('path'); module.exports = { // or production mode: 'development', entry: { menu:'./src/main.ts'}, output: { path: path.resolve(__dirname, 'app/dist') },

こまごま

ファイル移動 vm *.js ./tmp

スクロールを一時禁止

このような感じで onKeypadOpen:() => { $(document).on("touchmove.noScroll", function(e:JQuery.Event) { e.preventDefault(); }) }, onKeypadClose:() => { $(document).off("touchmove.noScroll"); },

カスタムデータ属性

data-hogeで cssから参照は[data-hoge="fuga"]