Azure IoT Hubにデバイスを登録する
Azure IoT Hubにデバイスを登録する時、WindowsだとDevice Explorerを使用します、Windows以外の場合はiothub-explorerを使用します。
ここでは、LinuxやMac OS Xのような非Windowsを対象とします。
前提
- Node.JSとnpmがインストールされていることが必要です。
iothub-explorerのインストール
- GitHubのiothub-explorerを参考にインストールします。
$ sudo npm install -g iothub-explorer@latest
$ iothub-explorer help
- Azure PortalのIoT Hubの設定から、共有アクセスポリシーを選択し、iothubownerの接続文字列をクリップボードにコピーして、つぎのコマンドを実行します。
$ iothub-explorer login "HostName=<my-hub>.azure-devices.net;SharedAccessKeyName=<my-policy>;SharedAccessKey=<my-policy-key>"
- new-device-idの部分に登録するデバイスIDを設定します。
$ iothub-explorer create <new-device-id> --connection-string
Angularのui-bootstrapでmenuitemをdisabledにする
Angular 1.5のui-bootstrapでDropdown MenuのMenuItemをdisabledにするいい方法が今ひとつ見つからず、 ng-classを使ってdisabledにするようにしました。
Version
- angular - 1.5.0
- bootstrap - 3.3.6
<div uib-dropdown> <a href id="simple-dropdown" uib-dropdown-toggle> Click me </a> <ul uib-dropdown-menu aria-labelledby="simple-dropdown"> <li role="menuitem" ng-class="{'disabled': one}"><a href>one</a> </li> <li role="menuitem" ng-class="{'disabled': two}"><a href>two</a> </li> <li role="menuitem" ng-class="{'disabled': three}"><a href>three</a> </li> </ul> </div>
Eclipseでdoma2を使うためのGradleの設定
Version
- Spring Boot - 1.3.2.RELEASE
- doma-spring-boot - 1.0.1
Gradleのビルドスクリプト
EclipseのAPT処理を有効にして、doma2によるAPT処理ができるようにbuild.gradleで設定します。
buildscript { repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.2.RELEASE") } } apply plugin: 'java' apply plugin: 'spring-boot' apply plugin: 'eclipse' processResources.destinationDir = compileJava.destinationDir compileJava.dependsOn processResources compileJava.options.compilerArgs = ['-Adoma.dao.subpackage=impl', '-Adoma.dao.suffix=Impl'] sourceCompatibility = '1.8' targetCompatibility = '1.8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' eclipse { jdt { file { withProperties {properties -> properties.setProperty('org.eclipse.jdt.core.compiler.processAnnotations', 'enabled') } } } } eclipseJdt { doFirst { def factorypath = file('.factorypath') def writer = new FileWriter(factorypath) def xml = new groovy.xml.MarkupBuilder(writer) xml.setDoubleQuotes(true) xml.'factorypath'() { def domaJar = configurations.compile.find { it.name.startsWith('doma-2') } 'factorypathentry'(kind: 'EXTJAR', id: domaJar, enabled: true, runInBatchMode: false) } } } repositories { mavenCentral() } configurations.all { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } dependencies { compile 'org.springframework.boot:spring-boot-starter-thymeleaf' compile 'org.seasar.doma.boot:doma-spring-boot-starter:1.0.1' compile 'org.xerial:sqlite-jdbc:3.8.11.2' testCompile 'junit:junit' testCompile 'org.springframework.boot:spring-boot-starter-test' }
Spring BootアプリケーションでDB2を使用する設定
Version
- Spring Boot - 1.3.2.RELEASE
- doma-spring-boot - 1.0.1
Application Properties
doma.dialect=DB2 spring.datasource.url=jdbc:db2://[HOST]:[PORT]/[DATABASE]:currentSchema=[SCHEMA]; spring.datasource.driver-class-name=com.ibm.db2.jcc.DB2Driver spring.datasource.username=[USERNAME] spring.datasource.password=[PASSWORD]
C++でビットアクセス
環境とコンパイラのバージョン
- CentOS7 64bit
- clang 3.4.2
FooBar構造体を定義して1bit(bit0)のfooと3bit(bit1-3)のbarを定義して、1byteの値cをキャストして取り出しています。
#include <stdio.h> struct FooBar { unsigned char foo:1; // bit0 unsigned char bar:3; // bit1-3 unsigned char baz:4; // bit4-7 }; int main(int argc, char** argv) { unsigned char c; c = 0b00001101; // 1 = 1 // 110 = 6 // foo: 1, bar: 6 printf("foo: %d, bar: %d\n", ((FooBar&) c).foo, ((FooBar&) c).bar); }