format

Truncate beginning of string with str.format

痴心易碎 提交于 2019-12-11 04:34:41
问题 I'd like to allign a string to the right but have its beginning be truncated instead of its end. I tried this: my_str = '01234567890' print "{0:>4.4}".format(my_str) Output: '0123' Desidered Output: '7890' Is there a way to do this with format or do I have to cut the string before feeding it? 来源: https://stackoverflow.com/questions/30721292/truncate-beginning-of-string-with-str-format

Command APDU returning 6985 (Conditions of use not satisfied) in result

杀马特。学长 韩版系。学妹 提交于 2019-12-11 04:14:20
问题 I am working on reading a smart card in Java. When I execute the following code below, the card returns 6985 (Conditions of use not satisfied) as a result. TerminalFactory factory = TerminalFactory.getDefault(); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); if (terminals != null && !terminals.isEmpty()) { // Use the first terminal CardTerminal terminal = terminals.get(0); // Connect with the card Card card = terminal.connect("*");

Powershell Out-Printer breaks Format-Table column layout

不问归期 提交于 2019-12-11 04:01:55
问题 Iam trying to use Format-Table to print some process data. I started with testing the output directly in the shell. Something along the lines of (Get-Process is just a substitute for my data): Get-Process | Format-Table ProcessName, Id The problem is that the first column has some larger cells and i needed to set up some formatting like this: $tableFormat = @{Expression={$_.ProcessName}; width=70}, @{Expression={$_.Handles}}; Get-Process | Format-Table $tableFormat In both cases, the output

Display current date in XML element

孤街浪徒 提交于 2019-12-11 03:51:18
问题 I'm using an XSL to transform one XML into another. My problem is that in one element I have to display the current date with the format:YYYYMMDD. I tried using a variable like these: <xsl:variable name="dateNow" select="current-dateTime()"/> <xsl:variable name="dateNow2" select="current-date()"/> And then tried to format then, but no success. <FRUEHESTER_LIEFERTERMIN><xsl:value-of select="format-dateTime($dateNow, '[Y0001][M01][D01]')"/></FRUEHESTER_LIEFERTERMIN> 回答1: What exactly is

C# and diskpart: how to select by disk label and not by a number?

蓝咒 提交于 2019-12-11 03:36:00
问题 I have a C# application that install Windows image. I have to choose the disk where the system will copied (C: or D: or ...) on the user interface. For that, it's ok. Then i have to format the disk. I have to select with diskpart.exe the good physical disk associed to C:. But with diskpart, we choose the disk with number: select disk 0 or 1 or ... How to make the connection between the good disk number and the letter choosen by users on the interface ? I found Nothing on google. I tried to

what the proper cross-browser date format is for passing to new Date()

本秂侑毒 提交于 2019-12-11 03:35:09
问题 i did use var elems = $("#D li").toArray(); elems.sort(function(a, b) { var adate = new Date($(a).find('div.dateDiv').text()); var bdate = new Date($(b).find('div.dateDiv').text()); return adate > bdate ? -1 : 1; }); $("#D").html(elems); <div id="D"> <li>1<div class="dateDiv">2012-04-15 10:25:45</div><div>df</div></li> <li>2 <div class="dateDiv">2012-04-10 19:41:08</div><div>df</div></li> <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div><div>ab</div></li> <li>4 <div class="dateDiv">2012

how to change dateformat of jquery Datepicker

一曲冷凌霜 提交于 2019-12-11 03:32:50
问题 i'm using the jquery 1.5.1 and 1.8.11 jQueryUI and i'm getting a very strange problem. i've tried a lot of things and the behaviour seems to be just the same. what happens if that i whant to get my date addoring the "yy-mm-dd" format according the documentation. but, as all the examples i use the tipical code (below) and when i start writing the date on the textbox, i cannot type some thing like '2011-03-22' because when i type the first 2(of day) the widget assumes automatically the 02 value

Audio Conversion C#

╄→гoц情女王★ 提交于 2019-12-11 03:25:23
问题 What is the best way to convert various audio formats to PCM? For example: mp3, evrc, ogg vox. Is there a library out there that will allow me to implement this relatively easily? EDIT: I guess my initial question wasn't really what I needed. Most of the libs I have found are file converters. What I need is a block converter, where I pass in a 1Kb block of vox data and it returns its converted PCM block. Of course I’ll have to tell the converter what type of data it is and various pieces of

File upload control to upload PDF only

孤街浪徒 提交于 2019-12-11 03:23:56
问题 I got a file control like <div class="form-group"> @Html.LabelFor(m => m.File, new { @class = "col-md-2 control-label" }) <div class="col-md-10"> @Html.TextBoxFor(m => m.File, new { type = "file" }) </div> I want it to allow only PDF format files, so in my model, its like [Display(Name = "Terms of Business")] [Required, FileExtensions(Extensions=".pdf", ErrorMessage="Incorrect file format")] public HttpPostedFileBase File { get; set; } However, the control still allows to upload documents of

How to add caption with the tables r package?

落花浮王杯 提交于 2019-12-11 03:19:35
问题 Using the iris data, we make a table with the tables package: library(tables) table <- tabular( (Sepal.Length+Sepal.Width) ~ Format(format(digits=2))*(mean + sd), data=iris ) With the Hmisc package, we would add the caption with the latex function like this: latex(table, caption="My table") But that does not work with the tables package, because it defines an S3 method, latex.tabular . So I have tried this, following an example in the package vignette: latex(table, options=list(toprule="\