work

How does the List monad work in this example?

匿名 (未验证) 提交于 2019-12-03 01:02:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The List monad has return x = [x] . So why in the following example is the result not [(["a", "b"], [2, 3])] ? > pairs a b = do { x <- a; y <- b; return (x, y)} > pairs ["a", "b"] [2,3] [("a",2),("a",3),("b",2),("b",3)] 回答1: Let us first analyze and rewrite the function pairs : pairs a b = do { x <- a; y <- b; return (x, y)} Here we thus have a monad. We use do as syntactical sugar. But the compiler rewrites this to: pairs a b = a >>= (\x -> b >>= (\y -> return (x, y))) Or in a more canonical form: pairs a b = (>>=) a (\x -> (>>=) b (\y ->

How does AsyncTask SerialExecutor work?

匿名 (未验证) 提交于 2019-12-03 01:02:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: private static class SerialExecutor implements Executor { final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>(); Runnable mActive; public synchronized void execute(final Runnable r) { mTasks.offer(new Runnable() { public void run() { try { r.run(); } finally { scheduleNext(); } } }); if (mActive == null) { scheduleNext(); } } protected synchronized void scheduleNext() { if ((mActive = mTasks.poll()) != null) { THREAD_POOL_EXECUTOR.execute(mActive); } } } Above code snippet is from the AsyncTask source code implementing the

Python multiprocessing IOError: [Errno 232] The pipe is being closed

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to implement this tutorial on mutliprocessing in python, but when I tried to do my own task I get the following error: Traceback (most recent call last): >>> File "C:\Python27\lib\multiprocessing\queues.py", line 262, in _feed send(obj) IOError: [Errno 232] The pipe is being closed Here is a reproducible example of what I am trying to do which gives the same error message: from multiprocessing import Lock, Process, Queue, current_process import time class Testclass(object): def __init__(self, x): self.x = x def toyfunction

Pixastic doesn&#039;t work properly for me, why?

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to do some interactive image processing on a webpage. I found pixastic and it seemed good for the job. On this page I'm trying do blur an image, but I can only get "blurfast" to work. "blur" doesn't work for me. I've been looking around and reading the documentation and can't see why it fails. Has anyone any idea? I use this js: $(function(){ var img = document.getElementById("imageone"); $("#blurfastbutton").click(function() { Pixastic.process(img, "blurfast", {amount:0.2}); }); $("#blurbutton").click(function() { Pixastic.process

Links does not work in &lt;a href&gt; tag when content has .com inside

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: in my code I generate a body of a html email message. Part of it is following: <a href="mylink.pl">SomeName.com</a> When I receive this email in my Mail client or in Gmail and when I click the link I'm directed to the SomeName.com and not to the mylink.pl which is in the href part of the <a> tag. And it looks that this situation occurs only for the .com domains. Any ideas how I could deal with this? 回答1: Use absolute URIs in emails. They start with (usually) http:// What you have is a relative URI, which doesn't make much sense in an email.

have uncommitted work pending. Please commit or rollback before calling out

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i have a batch class public class BatchCreateGCalendars implements Database.Batchable<SObject>, Database.Stateful, Database.AllowsCallouts { private String query; private String pageToken ; private String accessToken; private String CalendarId; public BatchCreateGCalendars(){ this.query = 'Select Id, Name, CalendarId__c from CalendarSettings__c'; // Query to get the CalendardID (Google ID) } public Database.Querylocator start(Database.BatchableContext BC){ return Database.getQueryLocator(query); } public void execute(Database

python opencv SIFT doesn&#039;t work for 8 bit images (JPEG)

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I used SIFT for all my other 24 bit JPEG images without any problems, however, the 8 bit one always give me this following error. image is empty or has incorrect depth (!=CV_8U) in function cv::SIFT::operator () Does anyone know how to deal with it? Here is my code: import cv2 import numpy as np import os import glob import scipy.cluster os.chdir('\mydirectory') images = [] for infile in glob.glob('./*.jpg'): pic = cv2.imread(infile,0) images.append(pic) my_set = images descriptors = np.array([]) feaL=np.array([]) for pic in my_set: kp, des

iODBC does not work under Mac OSX 10.6.4

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've installed iODBC over the package (http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/) and set up all config files as described here: http://blog.opensteam.net/past/2009/1/28/rails_ms_sql_on_mac/ I set up the same thing on a Linux machine and it worked fine. On my Mac OSX 10.6.4, I get this error if i test the connection: xxx@xxx:/opt/local/include$ iodbctest "dsn=res;uid=user;pwd=pass" iODBC Demonstration program This program shows an interactive SQL processor Driver Manager: 03.52.0709.0909 1: SQLDriverConnect = [iODBC][Driver Manager

WAMP server doesnt work, no listening sockets avalible, unable to open logs

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My WAMP server isn't working, when I hover over the orange W icon i get "1 of two services running". I did the right click on the icon, selected tools, selected test port 80 I got: ***** Test which uses port 80 ***** ===== Tested by command netstat filtered on port 80 ===== 'find' is not recognized as internal or external command, operable program or batch file. Port 80 is not associated with TCP protocol 'find' is not recognized as internal or external command, operable program or batch file. Port 80 is not associated with TCP protocol ====

Building assimp 3.2 does not work anymore

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I can't build assimp 3.2 anymore. Yesterday it worked but today it doesn't. I am downloading assimp from here . Then I'm doing cmake CMakeLists.txt -G 'Unix Makefiles' and make as described in their INSTALL file. However when doing make I get the following error: [ 84%] Performing configure step for 'gtest' CMake Error at /home/gartenriese/Documents/assimp/assimp-3.2/test/gtest/src/gtest-stamp/gtest-configure.cmake:16 (message): Command failed: 1 '/usr/bin/cmake' '-DCMAKE_BUILD_TYPE=' '-Dgtest_force_shared_crt=ON' '-Dgtest_disable_pthreads