syntax

Python: Convert args to dict, like PHP's compact?

I want a function exactly like PHP's compact function. i.e., if I pass in a list of variable names: compact('var1','var2') it returns me back a dict: {'var1':var1, 'var2':var2} ...

ObjectPascal identifier naming style on other languages

I learned to program with delphi, and i always liked the object pascal code style, looks very intuitive and clean. When you look at the variable declaration, you know what are you dealing with.. A fast summary: Exception E EMyError Classes and Types T TMyClass Fields in classes f fVisible Events On OnMouseDown Pointer types...

Python string format character for __unicode__?

Firstly, is there one? If not, is there a nice way to force something like print '%s' % obj to call obj.__unicode__ instead of obj.__str__? ...

Dot syntax variable onto array

Hi, I have an array of buttons that when clicked on, opens or closes content on my site. I need to be able to track which one is open so that when I click on that button again, I will know whether or not to close the content. Here's my array: var imageOptions = ['.corporateNeeds', '.marketResearch', '.corpStrategic', '.employeeTrainin...

Why is Main method private?

New console project template creates a Main method like this: class Program { static void Main(string[] args) { } } Why is it that neither the Main method nor the Program class need to be public? ...

Which of * and [] bind strongest in C?

Possible Duplicate: C pointer to array/array of pointers disambiguation In C, is int *thing[5] an array of five pointers, each pointing to an integer, or a pointer to an array of five integers? ...

C++: Expected a declaration (compiler error C2059)

The following is giving me a compiler error: #include <foo.h> #define ODP ( \ L"bar. " \ // C2059 here L"baz.") #define FFW (5) What am I doing wrong? ...

how is this table updated if there is no model file?

I'm trying to manually update a db in Spree, but it has no model file. I want to know how to CRUD into the option_values_variants table. The code uses James Golick's Resource Controller, but I want to do it without. models/option_value.rb class OptionValue < ActiveRecord::Base belongs_to :option_type acts_as_list :scope => :option...

Python syntax for and/or'ing things together?

I'm trying to devise a scheme for validating form fields. I've decided you can pass in a list of validators to each field like, Field(validators=[email_validator, required_validator]) But then I thought, what if you wanted to or the validators together, rather than anding them? For example, a field that accepts either a Canadian posta...

Since when does PHP autocast integer to float?

echo 1/3; I was expecting the above to output 0, but in fact PHP is smart enough to output 0.33333333333333 Since when does PHP start to behave like this? ...

VB.net: What is the difference between foo=Nothing and foo is Nothing?

In VB.net, what is the difference between if foo is Nothing Then doStuff() End If and if foo=Nothing Then doStuff() End If Update I received the following answer: foo is Nothing simply checks if foo is not assigned to any reference. foo=Nothing checks if the reference held by foo is equal to nothing ...

Is there a notepad++ plugin that makes JSP comments format correctly?

I would love Notepad++ to show the comments correctly (see screenshot) Is there any plugin that takes care of it? Or is there any way I can get it to default to another languages' formatting when I load a JSP file? ...

Does VB.NET not allow line continuations over commented-out lines?

I just had this throw a compilation error while refactoring some legacy (hence VB.NET) unit tests, where I wanted to just comment out one of the sample inputs to MBUnit: <RowTest> _ '<Row("Something")> _ <Row("SomethingElse")> _ Which gave: Attribute specifier is not a complete statement. Use a line continuation to apply the attribu...

What does this piece of code mean in scala?

def func(arg: String => Int): Unit = { // body of function } I mean this fragment: String => Int ...

Please help with correcting some quick SQL syntax, inner join on new column.

Ok so say I Col1,Col2, and COl3 exist in MyTable. However, [Interval] does not. Select Col1,Col2,Col3, [Interval] = CASE WHEN (cast(segstart as float) - floor(cast(segstart as float))) >= (cast(@TweleveAM as float) - floor(cast(@TweleveAM as float))) THEN CAST('0' as smallint) End FROM MyTable But now I want to use the new column I m...

Scala, parametherised objects

Is this possible to get: object test[A](l: Int): List[A] = { ... } You know what i mean. Is that possible? ...

Scala wants from me apply method

import java.util.Random class Kostka { val rand = new Random(System.currentTimeMillis()) val value: List[Int] = List(rand.nextInt(6+1)) } object MyRandom { def Fill[A](n: Int): List[A] = { if (n<=0) Nil else { var lst = List[A] for (i <- 1 to n){ lst ++= (new Kostka).val...

Unnamed arrays in structs in Go

So I can have struct { int x []int } However, struct { int []int } will result in a syntax error: unexpected [, expecting }. Is there a way of having unnamed arrays in structs in Go? If so, what's the correct syntax? ...

How do I remove javascript validation from my eclipse project ?

I am using eclipse on my project and while messing around with my eclipse settings, I turned on Javascript support. Now eclipse complains that JQuery library has errors in it and is not letting me compile the project. Does anyone know how to turn javascript validation off? ...

How do/can I run a select SQL statement inside an if?

I'm having trouble finding the syntax for a statement (or whether or not it's even possible). We're running SQL Server 2005, and I'd like to do something like: IF ((SELECT count(*) FROM mytable WHERE userid = 'myid' AND value = 3) < 1) then INSERT INTO mytable VALUES ('myid', 3) Any suggestions? Thanks ...