Hosting CLR in Delphi with/without JCL – example

Here’s another option. That’s the C# Code. And even if you do not want to use my unmanaged exports, it would still explain how to use mscoree (the CLR hosting stuff) without going through IDispatch (IDispatch is pretty slow). using System; using System.Collections.Generic; using System.Text; using RGiesecke.DllExport; using System.Runtime.InteropServices; namespace DelphiNET { [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid(“ACEEED92-1A35-43fd-8FD8-9BA0F2D7AC31”)] … Read more

How do you detect the host platform from Dart code?

import ‘dart:io’ show Platform; if (Platform.isAndroid) { // Android-specific code } else if (Platform.isIOS) { // iOS-specific code } All options include: Platform.isAndroid Platform.isFuchsia Platform.isIOS Platform.isLinux Platform.isMacOS Platform.isWindows You can also detect if you are running on the web using kIsWeb, a global constant indicating if the application was compiled to run on the web: … Read more

Copying a struct containing pointers to CUDA device

Edit: CUDA 6 introduces Unified Memory, which makes this “deep copy” problem a lot easier. See this post for more details. Don’t forget that you can pass structures by value to kernels. This code works: // pass struct by value (may not be efficient for complex structures) __global__ void kernel2(StructA in) { in.arr[threadIdx.x] *= 2; … Read more

Android USB host and hidden devices

To enable USB host API support you should add a file named android.hardware.usb.host.xml and containing the following lines: <permissions> <feature name=”android.hardware.usb.host”/> </permissions> into folder /system/etc/permissions in that folder find file named handheld_core_hardware.xml or tablet_core_hardware.xml and add <feature name=”android.hardware.usb.host” /> into <permissions> section. Reboot your device. Usb host api should work. Tested on CUBE U30GT with … Read more

How to ping an IP address

InetAddress.isReachable() according to javadoc: “.. A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host..”. Option #1 (ICMP) usually requires administrative (root) rights.

How to mount host volumes into docker containers in Dockerfile during build

It is not possible to use the VOLUME instruction to tell docker what to mount. That would seriously break portability. This instruction tells docker that content in those directories does not go in images and can be accessed from other containers using the –volumes-from command line parameter. You have to run the container using -v … Read more