Friday, 15 January 2010

disk io - Python Writing a 512-byte block of zeros to /dev/sda works, but doesn't behave like it is working -


Here I am trying to create a function (after all) support wiping of drives using several attributes. When I try to write zeroblock in the disc, it is written, but whatever the problem is, you have failed. The reason for this is that I have done this work that has approved the drive from the drive in my test system

  def wipedisk (drive, wipepepe, pass): diskisize = int (system) . HDD [Drive]. Size) DiscSact = Int (System. HDD [Drive]. Signer ()) Characterization = Int (System. HDD [Drive]. Circuit) System. HDD [drive] .start = time.time () if (wipespec == "zero"): Open ("/ dev / zero", "rb") as zero as: zeroblock = zero Rod (Sanctification) zero Close (= pass) = 0 open (with system .hdd [drive]. Device, as "wb") disk: while (pass  

For file.write says:

There is no return value to file a string type.

You mistakenly believe that write assumes that it has succeeded in writing or not. It is not.


swift - Sharing NSUserDefaults plist file? -


I want to use the facilities of NSUserDefaults to save the state. I am currently working. But I want to copy this plist file and want to apply it to the same app on another device.

Is there a way to pass a file name for NSUserDefaults or do I need to use another category? Or is it ok to share the same app with the other device?

The app on Device 1 and Device 2 is the only app I'm not trying to share data between different applications.

?

NSDictionary * dict = [[NSUserDefaults standard user default] dictionary report];

Then on another device:

  NSUserDefaults * defaults = [NSUserDefaults StandardUserDefaults]; (Copy dictionary in NSString * key) {ID of OB = Dictionary [key]; [Default set object: for ob: key]; }  

Or, you can write a .olist to a .plist file, from that to Transport, .plist Decode to dict and like I did the above.

Write in a .plist file:

  [dict tofile: @ "path / to / your / file.plast" atomically : Yes]; Reading from a  .plist  file: 

  NSDictionary * dict = [[NSDictionary alloc] initWithContentsOfFile: @ "Path / / To your / file.plist "];  

html - How do you add multile vendor prefixes to one css property? -


I have an image inside the .img-container. I would like the image inside the container at the center.

  & lt; Div class = 'col-xs-12 col-sm-4 col-lg-4 img-container' & gt; & Lt; Img class = "img- about responsive img-" src = 'img / about5001000.jpg' & gt; & Lt; / Div & gt;  

The only way I know how to handle different browsers with CSS code is how to code them individually (-moz-center, webkit-center):

  .img-container {padding-right: 0 pixels; Padding-left: 0 pixels; Text-line: -moz-center; }  

or

  .img-container {padding-right: 0px; Padding-left: 0 pixels; Text align: -webkit-center; }  

This is not for Firefox nor for Safari and Chrome:

  .img-container {padding-right: 0px; Padding-left: 0 pixels; Text align: center; }  

I'm sure there is a solution that works universally. Thanks!

The browser prefix is ​​used for experimental features that are not yet ready for normal use Or based on the parts of the CSS space which have not yet been finalized.

Text-Align: Center exists since the beginning of time and therefore anytime the prefix Is not required just write ...

  .img- container {padding-right: 0 pixels; Padding-left: 0 pixels; Text align: center; }  

The reason for this does not work for your image is img-responsive class. In Bootsrap, this creates a block element on your image, block elements can not be aligned to text-align .

Bootstrap 3 has an built-in center-block class that should be added to the IMG tag ...

  & lt; Div class = 'Col-xs-12 col-sm-4 col-lg-4 img-container' & gt; & Lt; Img class = "img- centric block about img-" src = 'img / about5001000.jpg' & gt; & Lt; / Div & gt;  


jquery - Fancybox 2 vertical scroll issue -


I use Alt to add additional text to the fancybox v2.1.4 popup, but the problem is that there is no visible Giving a vertical scrollbar to the description text, some text can not be read.

HTML:

  & lt ;! - Item Project Name - & gt; & Lt; Li class = "item-thumb span3 design" & gt; & Lt ;! - Fancybox - Gallery enabled - Title - Full image - & gt; & Lt; A class = "hover-rap fancybox" data -fancybox-group = "gallery" title = "the city" href = "_ included / img / work / full / image-01-full.jpg" gt; & Lt; Span class = "overlay-img" & gt; & Lt; / Span & gt; & Lt; Span class = "overlay-img-thumb font-icon-plus" & gt; & Lt; / Span & gt; & Lt; / A & gt; & Lt ;! - Image and description of thumb - & gt; & Lt; Img src = "_ include / img / work / thumbs / image-01.jpg" alt = "If I put too much text here, there is no scrollbar inside a popup & gt; & lt; / li & gt; & Lt;! - Last Item Project ->  

On the odd, fancybox CSS, all looks correct:

. Fancybox-lock Fancybox overlays {Overflow: Auto; overflow-y: scroll;}

What am I missing?

Do not use CSS to install scroll issues, you can" Helpers ".

Follow the code to fix the scroll issue.

  $ (" .fancybox "). Fancybox ({fitToView : False, height: 'auto', auto-size: false, helper: {overlay: {lock: false}}});  

sockets - Google App Engine Python: [Errno 10054] XML parse -


I am developing an app engine application that relies on the webpage 2 framework. In my case, I need a lib to parse the XML file and I found that ElementTree lib which is under my Python directory Python27 \ Lib \ xml \ etree \ ElementTree.py, Python is version 2.7 and I parsed it Use the method. After parsing operation, I'm repeating it. My relative code snippet here:

  import xml.etree.ElementTree as ET tree = ET. Pars ('myLargeSample.xml') root = tree.getroot () for item in root.iter ('item'): # Function of simple counting  

When I use my wrapper class I request this, which is webapp2 RequestHandler, in most cases this was done, but now I have around 11 MB and when I run the code, I get this error: [Errone 10054] Exception Stack At the end of an existing connection forcibly turned off by the remote host .

Not only this, but my python.xa has consumed up to 2 GB of membrane which is unusual when I requested the wrapper class! When I was found I could not find any close affair because the socket error is the original error, I think do you have any suggestions on what the problem would be? I'm really messing up with this error, thanks for your reply.


javascript - creating custom indicators - each for every 4 item in slider -


Then I have a content slider

Each item has a square in which theat items offset in the slider Such as

like

  & lt; Div id = "slider" & gt; & Lt; Div class = "item item-number -1" & gt; & Lt; / Div & gt; & Lt; Div class = "item item-number-2" & gt; & Lt; / Div & gt; & Lt; Div class = "item item-number -3" & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

And this is a round slider, after the last item it shows the first object again

So I added custom indicators to the slider on top, but most Contrast slider for every 4 items in each indicator slider

  For example, when I have 1-4 items 1 is ancillary, when there are 1-8 items, I have 2 indicators When I have 3 indicators in 1-12 items  

That is why I am an active class. Ihn user sliding starts to add correct indicator

  $ (document) .on ('click', '.prev, .next', function () {var p = $ (This) .parents ('# slider'); var it = p.find ('. Item: first'); var offset = number (this is 'et.' ('Class'). Partition ('') .pop ('Item-num-', '')); var indicator / number; if (offset = 4) indicator = 1 = number; other indicator_number = ?; $ ('.inidicator'). Eq (Indicator_number) .addClass ("active");})  

I want this part indicator_number =? ; I want a formula to find the correct indicator when the current index is larger than the offset 4

Simple arithmetic you should do what you want:

  indicator_number = mathematics.flur ((offset - 1) / 4) + 1);  

Offset - 1 : Obtain the zero based index of the current slide.
/ 4 : Split + 1 : Convert the result to a non-zero based index Math.floor : in a whole number Convert


java - What is the MEMORY complexity of this fibonacci sequence algorithm? -


I recently had a technical interview and I was asked to report the memory complexity of the following algorithms written on the whiteboard.

To be more specific, if I remember correctly, it was referring to "heap space":

  public int [] fib = new int [1000]; Public Intimate Fibonacci (Int Eye) {if (i == 0) returned to 0; If (i == 1) returns 1; If (fib [i]! = 0) returns fib [i]; Fib [I] = Fibonacci (I-1) + Fibonacci (I-2); Returns fib [i]; }  

Because he said "heap space", it seems like he was giving me a clue that he wanted to give me the complexity of the following line code:

  public int [] fiber = new int [1000];  

I think I remember learning in school that in Java there is new in the form of malloc , where malloc < / Code> Allocates storage to a heap, thinking that my memory works correctly, now go back to my question: What is the complexity of this memory? Did I want to say o (1000)? On)? anything else?

Thank you!

"post-text" itemprop = "text">

I think your interviewer wanted to know how well you understood the results of the written code. The usual potential memory problem with the non-tail call recursive code is that every recurring call has a stack frame, which is not complete until the call (including all its recurring subclasses). Heap frames are allocated with a pile, so the recycling can end the pile.

Without a memoimization shortcut that saves and retrieves the already calculated Fibonacci number, memory complexity will be o (n 2 ): nth Fibonacci number calculation According to the ratio of the square of the constellation, a recursive tree will be formed, it re-calculates the same number for different branches of the tree.

But the post code should not count a Fibonacci number more than once, and the total number of the stackframe will not explode in the same way, it will be placed in O (n) worst position, where the array starts After the array is populated, it will be o (1), because from that point it is equal to seeing an array.