coding-style

What is the best way to print a table with delimiters in Python

流过昼夜 提交于 2019-12-03 16:46:55
I want to print a table mixed with string and float values, as tab delimited output printout. Sure I can get the job done: >>> tab = [['a', 1], ['b', 2]] >>> for row in tab: ... out = "" ... for col in row: ... out = out + str(col) + "\t" ... print out.rstrip() ... a 1 b 2 But I have a feeling there is a better way to do it in Python, at least to print each row with specified delimiter, if not the whole table. Little googling (from here ) and it is already shorter: >>> for row in tab: ... print "\t".join([str(col) for col in row]) ... a 1 b 2 Is there still a better, or more Python-ish, way to

Software Safety Standards

≯℡__Kan透↙ 提交于 2019-12-03 16:39:01
问题 What industry known software safety standards has anyone had experience in having to adhere to while developing software that is involved in controlling a device/system that has potential to harm the individuals using it? 回答1: Start here: http://www.aonix.com/safety_critical_overview.html Read this: http://www.ghs.com/products/safety_critical/index.html Listen to this: http://www.podnova.com/channel/388090/episode/7/ This is a well-understood topic. The military has been building safety

Using “m” prefix for variables in Kotlin

99封情书 提交于 2019-12-03 16:36:31
问题 Using "m" prefix for variable names became usual in programming, mainly in Android, but since Kotlin arrived, this minor thing bothers me a bit. Setting and getting variables with "m" prefix doesn't seem really nice, because in Java we create (and name) our setters and getters, so we can omit the "m", but this doesn't happen in Kotlin, unless we walk in the opposite of conventions and repeat Java's technique. Java: public class Foo { private String mName; public void setName(String name) {

Change style of ProgressDialog

不问归期 提交于 2019-12-03 16:30:18
问题 Is it possible to change ProgressBar style of progress dialog. If yes, then how can I do it? 回答1: You can style your progress dialog this way: create a drawable file with your ring shape (circular_progress_dialog.xml) <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="270" android:toDegrees="270"> <shape android:innerRadiusRatio="2.5" android:shape="ring" android:thickness="2dp" android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->

To camelCase or not to camel_case

有些话、适合烂在心里 提交于 2019-12-03 16:26:58
问题 What is the standard when coding in Java, when do you use camel case when do you use underscores etc. 回答1: You stick with the Java Code Conventions. What exactly the standard is doesn't matter - what matters is that everyone follows it, and you should too. 回答2: ClassName Renderer HttpSession methodName applyTo() run() instanceVariable / localVariable currentUser threadList CONSTANT_NAME LOG DEFAULT_CONTEXT G (Generic Type Parameter) T E 回答3: See Sun's Code Conventions for the Java(TM)

Is there a concise opposite of “is empty”?

筅森魡賤 提交于 2019-12-03 16:18:41
问题 Interfaces to string classes typically have of method named IsEmpty (VCL) or empty (STL). That's absolutely reasonable because it's a special case, but the code that uses these methods often has to negate this predicate, which leads to a "optical (and even psychological) overhead" (the exclamation mark is not very obvious, especially after an opening parenthesis). See for instance this (simplified) code: /// format an optional time specification for output std::string fmtTime(const std:

How to share a Symfony2 model with several projects

限于喜欢 提交于 2019-12-03 16:13:08
问题 We are creating a SaaS that monitors certain assets. This means it takes in data, saves it, and displays it in a webinterface. For this, we have a few components that we created with/are moving to Symfony2: a frontend web application, where users can view their data a backend administrative web application, where we create new monitors, users, etc. an API an application that retrieves the received data from a queue and puts it in our database (this is now a seperate script, but I'm thinking

Emacs mode/function that wraps operators with spaces

ε祈祈猫儿з 提交于 2019-12-03 16:03:52
I remember that there was a mode for Emacs, or was it an option, can't recall, that prettified the code by placing space after operators like , , . , wrapped = with spaces, and some other cools stuff that I can't remember. I reckon that this is pretty much language-specific issue, but I usually put space after commas, and wrap = with spaces. Any ideas about this mode? sanityinc You're probably thinking of smart-operator.el . How about smartchr.el ? This is probably not what you are trying to recall, but I'm sure it works nicely for that purpose. For example: (require 'smartchr) (global-set-key

Style triggers in Silverlight

元气小坏坏 提交于 2019-12-03 15:57:43
I am trying to use style triggers in silverlight like so: <Path Canvas.Top="20" Stroke="#FF808080" Data="M 0,20 20,0 40,20 Z" StrokeLineJoin="Round"> <Path.Style> <Style TargetType="{x:Type Path}"> <Setter Property="Fill" Value="DarkGray"/> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=userControl, Path=PumpRunning}" Value="True"> <Setter Property="Fill" Value="DarkGreen"/> </DataTrigger> </Style.Triggers> </Style> </Path.Style> </Path> I want to do this so that the fill value of the path changes if the pump is running or not. The problem is that style triggers are not supported

How to make a fancy transparent menu like the “share menu” in Android gallery?

亡梦爱人 提交于 2019-12-03 15:45:19
On my Android 2.2.2 device the gallery looks really nice. What I would love to do in my own app is to press a button and then show a menu that looks like this: Is this using any standard Android themes / styles? Does anybody know of an example code to have a menu like this? Edit: I figured out that one could mimic this menu with a Dialog. To simplify things I'm not using a ListView in this example, just a single TextView entry for the dialog: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_root" android:orientation="vertical" android:layout