我正在寻找一种方法来确定COM是标准COM还是SPP COM,也称为COM设备的电缆替换蓝牙适配器.
我有一个可以在USB(COM - > USB)和蓝牙中工作的设备,蓝牙接口可以与SPP配合使用.
我目前正在使用System.IO.Ports.SerialPort.GetPortNames()COM.
有没有办法确定它是否与蓝牙或USB连接?
解:
System.Management.ManagementObjectSearcher Searcher = new System.Management.ManagementObjectSearcher("Select * from WIN32_SerialPort");
foreach (System.Management.ManagementObject Port in Searcher.Get())
{
foreach (System.Management.PropertyData Property in Port.Properties)
{
Console.WriteLine(Property.Name + " " + (Property.Value == null ? null : Property.Value.ToString()));
}
}
Run Code Online (Sandbox Code Playgroud)
输出类似于:
Availability 2
Binary True
Capabilities
CapabilityDescriptions
Caption Standard Serial over Bluetooth link (COM10)
ConfigManagerErrorCode 0
ConfigManagerUserConfig False
CreationClassName Win32_SerialPort
Description Standard Serial over Bluetooth link
DeviceID COM10
ErrorCleared
ErrorDescription
InstallDate
LastErrorCode
MaxBaudRate 9600
MaximumInputBufferSize …Run Code Online (Sandbox Code Playgroud) 我正在尝试为Facebook和网站之间同步的帖子建立评论系统.
到目前为止,一切正常,除非我以一个管理页面的用户登录,它作为页面发布,无论我尝试做什么.
我首先进行了我的页面设置并取消选中"始终评论并在您的页面上发布为测试页面,即使将Facebook用作X."
我的代码如下:
// fb-id is usually POST_ID
FB.api($comments.data('fb-id') + '/comments', 'post', {
message: $('textarea', $comments).val(), // this works fine
from: FB.getUserID() // no effect
}, function(){
// callback here
});
Run Code Online (Sandbox Code Playgroud)
我甚至试图撤销我的权限,在/ me/permissions上执行DELETE并使用publish_stream获取一个新令牌,但仍然会将其作为页面发布.
我只是想用图形API资源管理器中,从那里,如果我张贴到POST_ID /注释中使用的访问令牌只有publish_stream,它还文章为我的网页,而不是我的用户登录.
还试过FB PHP SDK,用相同的参数,不同的方式来获取access_token,同样的事情发生了.
任何人都知道我如何强制FB发布评论作为登录用户?或者这是Facebook的错误?我看到有1-2个人在网上抱怨这个问题,但没有修复.
编辑 Facebook上的错误报告已被接受并分配.这个问题现在可以关闭,因为它是一个有效的错误.
我正在尝试从外部视频创建缩略图,主要是MP4和FLV.我正在使用FFmpegPHP.我已经将缩略图生成工作正常,但是,我需要先在我的服务器上完全加载视频.是否可以仅流式传输视频的一小部分,然后从中提取缩略图?
这是我到目前为止的代码:
require_once PRIV . 'Vendor/FFmpegPHP/FFmpegAutoloader.php';
// Download the whole video.
$video = file_get_contents($_PUT['video']);
$file = 'path_to_cache';
file_put_contents($file, $video);
$movie = new FFmpegMovie($file);
// Generate the thumbnail.
$thumb = $movie->getFrame($movie->getFrameCount() / 2);
$thumb->resize(320, 240);
imagejpeg($thumb->toGDImage(), 'path_to_thumb');
Run Code Online (Sandbox Code Playgroud)
有人有建议吗?
编辑
正如Brad所说,这是更新的代码:
$file = CACHE . 'moodboard_video_' . rand();
$fh = fopen($file, 'w');
$size = 0;
curl_setopt($ch, CURLOPT_URL, $_PUT['video']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $data) use($fh, &$size){
$length = fwrite($fh, $data);
if($length === FALSE) {
return 0;
} else { …Run Code Online (Sandbox Code Playgroud) 所以我正在和我的朋友交谈,用一段代码帮助她,我一直认为数组需要是编译时常量,因为它们在堆栈中.但她说她的朋友使用这段代码做了这件事:
#include <iostream.h>
#include <stdlib.h>
int main()
{
int value = ' ' ;
int sum = 0;
int count = 0;
cout<<"Please enter the total number of employees" <<endl;;
cin>> value;
int numbers[value];
cout<<"Now enter the employees corresponding salaries" <<endl;;
for (int k = 0; k < value; k++)
{
cin >> numbers[k];
}
}
Run Code Online (Sandbox Code Playgroud)
他们正在使用Dev-C++.
这段代码是否有效?我假设没有.
我正在使用Sequelize和钩子(见这里:https://github.com/sequelize/sequelize/pull/894).我正在尝试实现一种日志系统,并且更愿意登录钩子而不是我的控制器.任何人都有任何关于如何将我的用户从req.user带入我的钩子函数的想法?
db.define('vehicle', {
...
}, {
hooks: {
beforeUpdate: function(values, cb){
// Want to get my user in here.
}
}
});
Run Code Online (Sandbox Code Playgroud) 我目前正在PhoneGap中开发一个小型演示,以测试一些功能。我想使用Github提供的PhoneGap-OrientationLock插件,以便能够从JavaScript动态更改屏幕方向,我已经更新了该插件,以便在Cordova中使用它。
我现在的问题是,一旦我想更改屏幕方向,它就会崩溃。即使我尝试setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);使用onCreate方法中的简单操作(从技术上没有使用PhoneGap),我的应用程序也会使用以下调试日志退出启动器:
08-20 08:57:17.083: D/DroidGap(21383): DroidGap.onCreate()
08-20 08:57:17.193: D/CordovaWebView(21383): Origin to allow: http://127.0.0.1*
08-20 08:57:17.193: I/CordovaLog(21383): Found log level DEBUG
08-20 08:57:17.193: I/CordovaLog(21383): Changing log level to DEBUG(3)
08-20 08:57:17.193: I/CordovaLog(21383): Found preference for fullscreen=true
08-20 08:57:17.193: D/CordovaLog(21383): Found preference for fullscreen=true
08-20 08:57:17.193: I/CordovaLog(21383): Found preference for useBrowserHistory=false
08-20 08:57:17.193: D/CordovaLog(21383): Found preference for useBrowserHistory=false
08-20 08:57:17.223: D/DroidGap(21383): DroidGap.init()
08-20 08:57:17.223: D/CordovaWebView(21383): >>> loadUrl(file:///android_asset/www/index.html)
08-20 08:57:17.223: D/PluginManager(21383): init()
08-20 08:57:17.233: D/CordovaWebView(21383): >>> loadUrlNow() …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的应用程序推送到Heroku.我已经能够部署它几次,但现在我已经在我的packages.json文件中将mongoose从"> = 3.5.0"更新为"> = 3.6.0rc0".但是,版本3.6需要mpath和mpromise.
当slug编译开始时,它使用缓存版本的mongoose或者什么,就像我的应用程序启动时,我得到"错误:无法找到模块'mpath'".
我试图设置一个可以停止缓存的自定义buildpack Git,我只是注释掉了bin/compile中的缓存内容,可以在这里找到:https://github.com/jValdron/heroku-buildpack-nodejs
这是推送的输出:http://pastebin.com/L3Yqy2NR
此外,当我从package.json中删除一些依赖项时,如果我使用'heroku run bash'登录,我可以看到那些删除了node_modules中的依赖项.我已经尝试删除node_modules文件夹并执行另一个'git push',这也不起作用.那些被删除的deps仍然在node_modules中.
任何人都知道如何解决这个问题?
编辑:
这是我的package.json文件:
{
"name": "souply-api",
"version": "0.1.0",
"author": "Jason Valdron <jason.valdron@orangesprocket.com>",
"description": "Main gears that runs the Soup.ly application",
"dependencies": {
"bcrypt": ">= 0.7.3",
"express": ">= 3.0.5",
"extend": ">= 1.1.3",
"imagemagick": ">= 0.1.3",
"jade": ">= 0.27.7",
"knox": ">= 0.4.6",
"less": ">= 1.3.1",
"less-middleware": ">= 0.1.9",
"moment": ">= 1.7.2",
"mongoose": ">= 3.6.0rc0",
"mongoose-types": ">= 1.0.3",
"node-native-zip": ">= 1.1.0",
"nodemailer": ">= 0.3.37", …Run Code Online (Sandbox Code Playgroud) node.js ×2
android ×1
arrays ×1
bluetooth ×1
c# ×1
c++ ×1
cordova ×1
express ×1
facebook ×1
ffmpeg ×1
heroku ×1
http ×1
javascript ×1
jquery ×1
npm ×1
orientation ×1
php ×1
sequelize.js ×1
serial-port ×1