convert

How to convert the ^M linebreak to 'normal' linebreak in a file opened in vim?

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: vim shows on every line ending ^M How I do to replace this with a 'normal' linebreak? 回答1: This is the only thing that worked for me: :e ++ff=dos Found it at: http://vim.wikia.com/wiki/File_format 回答2: Command :%s/ /\r/g Where means type Ctrl + V then Ctrl + M . Explanation :%s substitute, % = all lines ^M characters (the Ctrl-V is a Vim way of writing the Ctrl ^ character and Ctrl-M writes the M after the regular expression, resulting to ^M special character) /\r/ with new line ( \r ) g And do it globally (not just the first occurrence on

Convert a CERT/PEM certificate to a PFX certificate

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've seen a couple questions about how to convert a PFX to a cert file, but I need to go the other way. I have two files: bob_cert.cert bob_key.pem I'd like to convert them to a single .pfx file. Is there a tool that does this? 回答1: openssl pkcs12 -inkey bob_key.pem -in bob_cert.cert -export -out bob_pfx.pfx 回答2: Here is how to do this on Windows without third-party tools: Import certificate to the certificate store. In Windows Explorer select "Install Certificate" in context menu. Follow the wizard and accept default options "Local User"

ES6 - Convert from 'require' to 'import'

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: If the alternative to: var Foo = require('foo'); is: import Foo from 'foo'; What is the alternative to: var Bar = require('foo').batz Could it be: import {batz} from 'foo' ? 回答1: Nearly. It does however depend on how you are exporting them. named exports ( export var batz = … ): import {batz as Bar} from 'foo'; default-exported object ( export default {batz: …}; ) - should not be used: import Foo from 'foo'; var Bar = Foo.batz; 文章来源: ES6 - Convert from 'require' to 'import'

Convert base64 string to image

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to crop/resize user profile image using jquery plugin namely crop.js which sends user image as base64 via ajax to my controller as $ . ajax ({ type : "post" , dataType : "json" , url : "${g.createLink(controller: 'personalDetail', action:'uploadUserImage')}" , data : { avatar : canvas . toDataURL () } }); but I unable to decode this base64 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAYAAAA+VemSAAAgAEl...==' string as Image,Can you guys guide me how can I save my base64 string as image on my server?. 回答1:

Convert date from milliseconds to ISODate object

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to aggregate records in a MongoDB colloection by hour and need to convert date stored as timestamp (milliseconds) to ISODate so that I can use aggregate framework's built-in date operators ($hour, $month, etc.) Records are stored as { "data" : { "UserId" : "abc" , "ProjId" : "xyz" }, "time" : NumberLong ( "1395140780706" ), "_id" : ObjectId ( "532828ac338ed9c33aa8eca7" ) } I am trying to use an aggregate query of following type: db . events . aggregate ( { $match : { "time" : { $gte : 1395186209804 , $lte :

cannot convert 'std::basic_string<char>' to 'const char*' for argument '1' to 'int system(const char*)'

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I get this error: "invalid operands of types 'const char*' and 'const char [6]' to binary 'operator+'" when i try to compile my script. Here should be the error: string name = "john"; system(" quickscan.exe resolution 300 selectscanner jpg showui showprogress filename '"+name+".jpg'"); 回答1: The type of expression " quickscan.exe resolution 300 selectscanner jpg showui showprogress filename '"+name+".jpg'" is std::string . However function system has declaration int system(const char *s); that is it accepts an argumnet of type const char *

Convert HttpPostedFileBase to byte[]

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my MVC application, I am using following code to upload a file. MODEL public HttpPostedFileBase File { get; set; } VIEW @Html.TextBoxFor(m => m.File, new { type = "file" }) Everything working fine .. But I am trying to convert the result fiel to byte[] .How can i do this CONTROLLER public ActionResult ManagePhotos(ManagePhotos model) { if (ModelState.IsValid) { byte[] image = model.File; //Its not working .How can convert this to byte array } } 回答1: As Darin says, you can read from the input stream - but I'd avoid relying on all the data

How to convert a file to utf-8 in Python?

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to convert a bunch of files to utf-8 in Python, and I have trouble with the "converting the file" part. I'd like to do the equivalent of: iconv -t utf-8 $file > converted/$file # this is shell code Thanks! 回答1: You can use the codecs module , like this: import codecs BLOCKSIZE = 1048576 # or some other, desired size in bytes with codecs.open(sourceFileName, "r", "your-source-encoding") as sourceFile: with codecs.open(targetFileName, "w", "utf-8") as targetFile: while True: contents = sourceFile.read(BLOCKSIZE) if not contents: break

Convert HTML to word file ?

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to convert ruby file in word file i.e (docx file). For pdf, we prawn gem. But is there any gem for word file. I am trying to convert my html file in word file so that it can be editable for user too. What should do in that case ? I was planning to convert that file in word file. Will it be possible or not. 回答1: If you are using Rails: in initializers/mime_types.rb: Mime::Type.register 'application/vnd.ms-word', :msword in your controller: say you want to export show action: def show @item = Item.find params[:id] respond_to do |format|

Convert Date format into DD/MMM/YYYY format in SQL Server

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a query in sql, I have to get date in a format of dd/mmm/yy Example: 25/jun/2013 . How can I convert it for SQL server? 回答1: I'm not sure there is an exact match for the format you want. But you can get close with convert() and style 106 . Then, replace the spaces: SELECT replace(convert(NVARCHAR, getdate(), 106), ' ', '/') 回答2: we can convert date into many formats like SELECT convert(varchar, getdate(), 106) This returns dd mon yyyy More Here This may help you 回答3: There are already multiple answers and formatting types for SQL