array

Swift - define a recursive type with a protocol

匿名 (未验证) 提交于 2019-12-03 01:36:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to define a type that can be serialized to a valid JSON object So for instance if a JSON can contain the following: String Number Array Object Date Boolean I would like to define a protocol with valid types protocol JsonSerializable { } typealias JSONObject = [ String : JsonSerializable ] typealias JSONArray = [ JsonSerializable ] // foundation implements serializing numbers + strings + dates etc. to JSON extension String : JsonSerializable {} extension Int : JsonSerializable {} // problem with defining dictionary and array

GMail Username and Password not accepted error when sending email with SwiftMailer

匿名 (未验证) 提交于 2019-12-03 01:35:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I get the following error when trying to use my GMail account to send an email from my PHP application with SwiftMailer. 535-5.7.8 Username and Password not accepted This is my SwiftMailer code: $transporter = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl') ->setUsername('ayrshireminiscontact@gmail.com') ->setPassword('~password-in-here~'); $mailer = Swift_Mailer::newInstance($transporter); $message = Swift_Message::newInstance('Portfolio Enquiry') ->setFrom(array('ayrshireminiscontact@gmail.com' => 'CRMPicco Portfolio Enquiry

writing APIC to mp3 file with getid3 (id3v2)

匿名 (未验证) 提交于 2019-12-03 01:35:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to write APIC picture to mp3 file with getid3. here is the code; $cover = "/home/user/public_html/artwork/cover.jpg"; $TagData['attached_picture'][]=array( 'picturetypeid'=>2, // Cover. More: module.tag.id3v2.php -> function APICPictureTypeLookup 'description'=>'cover', // text field 'mime'=>'image/jpeg', // Mime type image 'data'=>$cover // Image data ); but it doesnt work. image size is around 1.5 MB. should i resize it or sth ? where am i wrong ? Thanks 回答1: Looking at the demo they have on their website: http://www.getid3.org

Fortran increase dynamic array size in function

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need a variable size array in Fortran. In C++ I would use vector. So I have a function like integer function append(n, array, value) integer, pointer, dimension(:) :: array integer, pointer, dimension(:) :: tmp_arr integer n if (size(array) .eq. n) then allocate(tmp_arr(2*size(array))) tmp_arr(1:size(array)) = array deallocate(array) array => tmp_arr end if n = n + 1 array(n) = value append = n end function that works fine if I use it the way integer pos, val pos = append(n, array, val) However, if I would like to use it the way integer i

forming json from coldfusion query for use in jquery autocomplete

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm stumped. I have an existing autocomplete function which worked when called from a ColdFusion autosuggest input. Now, I'm trying to convert the page to use a jQuery autocomplete input, and can't make it work. Here's the existing function, in autosuggest.cfc: <cffunction name="lookupSerialNumber" access="remote" returntype="Array" > <cfargument name="search" type="any" required="false" default=""> <!--- Define variables ---> <cfset var data=""> <cfset var result=ArrayNew(1)> <!--- Do search ---> <cfquery name="data"> SELECT DISTINCT SERIAL

deserialize json array list in c#

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm working on a project which has as backend mainly C#, but I'm not an experienced C# dev so I'm not able to figure out hot to fix a json deserialization of an list of objects. The following function is what takes care of the deserialization, but I get an error : using System . IO ; using System . Web ; using Raven . Imports . Newtonsoft . Json ; namespace Corina . Web . Handlers { public class JsonRequestHandler { public T Handle < T >( HttpContextBase context ) { string requestData ; context . Request . InputStream . Position =

Convert numpy array to rgb image

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a numpy array with value range from 0-255 . I want to convert it into a 3 channel RGB image. I use the PIL Image.convert() function, but it converts it to a grayscale image. I am using Python PIL library to convert a numpy array to an image with the following code: imge_out = Image.fromarray(img_as_np.astype('uint8')) img_as_img = imge_out.convert("RGB") The output converts the image into 3 channels, but it's shown as a black and white (grayscale) image. If I use the following code img_as_img = imge_out.convert("R") it shows error

Fastest way to read every n-th row with numpy's genfromtxt

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I read my data with numpy's genfromtxt: import numpy as np measurement = np . genfromtxt ( 'measurementProfile2.txt' , delimiter = None , dtype = None , skip_header = 4 , skip_footer = 2 , usecols =( 3 , 0 , 2 )) rows , columns = np . shape ( measurement ) x = np . zeros (( rows , 1 ), dtype = measurement . dtype ) x [:]= 394 measurement = np . hstack (( measurement , x )) np . savetxt ( 'measurementProfileFormatted.txt' , measurement ) this works fine. But i want only ever 5-th , 6-th (so n-th ) row in the final Output file.

Distribution plot of an array

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a numpy array containing float values in [-10..10]. I would like to plot a distribution-graph of the values, like this (here it is done for a binomial random variable) : For example I would like bars counting the number of elements in each interval [-10, -9.5], [-9.5, -9], ..., [9.5, 10]. How to prepare such a distribution plot with Python? 回答1: Indeed matplotlib, more precisely you'll find samples of code corresponding to what you are after at: http://matplotlib.org/examples/pylab_examples/histogram_demo_extended.html import numpy as

How to create image from a list of pixel values in Python3?

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: If I have a list of pixel rows from an image in the following format, how would get the image? [ [(54, 54, 54), (232, 23, 93), (71, 71, 71), (168, 167, 167)], [(204, 82, 122), (54, 54, 54), (168, 167, 167), (232, 23, 93)], [(71, 71, 71), (168, 167, 167), (54, 54, 54), (204, 82, 122)], [(168, 167, 167), (204, 82, 122), (232, 23, 93), (54, 54, 54)] ] 回答1: PIL and numpy are your friends here: from PIL import Image import numpy as np pixels = [ [(54, 54, 54), (232, 23, 93), (71, 71, 71), (168, 167, 167)], [(204, 82, 122), (54, 54, 54), (168, 167