Questions

Python int to binary string?

Are there any canned Python methods to convert an Integer (or Long) into a binary string in Python? There are a myriad of dec2bin() functions out on Google... But I was hoping I could use a built-in ...

13 Feb at 02:15

Limit text length to n lines using CSS

Is it possible to limit a text length to "n" lines using CSS (or cut it when overflows vertically). `text-overflow: ellipsis;` only works for 1 line text. original text: > Ultrices natoque mus ma...

28 Apr at 18:53

What does "static" mean in C?

I've seen the word `static` used in different places in C code; is this like a static function/class in C# (where the implementation is shared across objects)?

29 Oct at 15:42

Import file size limit in PHPMyAdmin

I have changed all the php.ini parameters I know: `upload_max_filesize`, `post_max_size`. Why am I still seeing 2MB? Im using Zend Server CE, on a Ubuntu VirtualBox over a Windows 7 host.

17 Mar at 01:37

How to mock void methods with Mockito

How to mock methods with void return type? I implemented an observer pattern but I can't mock it with Mockito because I don't know how. And I tried to find an example on the Internet but didn't suc...

21 Oct at 10:41

What is the single most influential book every programmer should read?

If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be? I expect this list to be varied and to cover a wide rang...

26 Sep at 15:39

How do you convert a byte array to a hexadecimal string, and vice versa?

How can you convert a byte array to a hexadecimal string and vice versa?

9 Sep at 09:20

Can HTML checkboxes be set to readonly?

I thought they could be, but as I'm not putting my money where my mouth was (so to speak) setting the readonly attribute doesn't actually seem to do anything. I'd rather not use Disabled, since I wan...

30 Sep at 21:58

How do I use a decimal step value for range()?

How do I iterate between 0 and 1 by a step of 0.1? This says that the step argument cannot be zero: ``` for i in range(0, 1, 0.1): print(i) ```

17 Jul at 04:32

How to convert a factor to integer\numeric without loss of information?

When I convert a factor to a numeric or integer, I get the underlying level codes, not the values as numbers. ``` f <- factor(sample(runif(5), 20, replace = TRUE)) ## [1] 0.0248644019011408 0.024864...

1 Apr at 11:6

How to send HTTP request in Java?

In Java, How to compose an HTTP request message and send it to an HTTP web server?

26 Nov at 14:40

Changing one character in a string

What is the easiest way in Python to replace a character in a string? For example: ``` text = "abcdefg"; text[1] = "Z"; ^ ```

17 Jun at 23:35

What is a non-capturing group in regular expressions?

How are non-capturing groups, i.e., `(?:)`, used in regular expressions and what are they good for?

5 Jan at 21:38

Checking if a string is empty or null in Java

I'm parsing HTML data. The `String` may be `null` or empty, when the word to parse does not match. So, I wrote it like this: ``` if(string.equals(null) || string.equals("")){ Log.d("iftrue", "s...

30 Jan at 08:9

What is a serialVersionUID and why should I use it?

Eclipse issues warnings when a `serialVersionUID` is missing. > The serializable class Foo does not declare a static final serialVersionUID field of type long What is `serialVersionUID` and why ...

17 Mar at 22:44

Writing string to a file on a new line every time

I want to append a newline to my string every time I call `file.write()`. What's the easiest way to do this in Python?

23 Oct at 15:7

How do I find and restore a deleted file in a Git repository?

Say I'm in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I discover that I need to restore that file after deleting it. I know I can ch...

18 Jul at 18:45

Create a dictionary with comprehension

Can I use list comprehension syntax to create a dictionary? For example, by iterating over pairs of keys and values: ``` d = {... for k, v in zip(keys, values)} ```

How to set the environment variables for Java in Windows

How to set the environment variables for Java in Windows (the classpath)?

14 May at 04:21

CSS Image size, how to fill, but not stretch?

I have an image, and I want to set it a specific width and height (in pixels) But If I set width and height using css (`width:150px; height:100px`), image will be stretched, and It may be ugly. How ...

10 Oct at 21:0

How do I declare a global variable in VBA?

I wrote the following code: ``` Function find_results_idle() Public iRaw As Integer Public iColumn As Integer iRaw = 1 iColumn = 1 ``` And I get the error message: > "invalid attr...

8 Jul at 19:39

Most efficient method to groupby on an array of objects

What is the most efficient way to groupby objects in an array? For example, given this array of objects: ``` [ { Phase: "Phase 1", Step: "Step 1", Task: "Task 1", Value: "5" }, { Phase: "Ph...

How to push both value and key into PHP array

Take a look at this code: ``` $GET = array(); $key = 'one=1'; $rule = explode('=', $key); /* array_push($GET, $rule[0] => $rule[1]); */ ``` I'm looking for something like this so that: ``` pri...

19 Dec at 06:6

Creating a byte array from a stream

What is the prefered method for creating a byte array from an input stream? Here is my current solution with .NET 3.5. ``` Stream s; byte[] b; using (BinaryReader br = new BinaryReader(s)) { ...

21 Apr at 17:8

Count the frequency that a value occurs in a dataframe column

I have a dataset ``` category cat a cat b cat a ``` I'd like to be able to return something like (showing unique values and frequency) ``` category freq cat a 2 cat b 1 ```

26 Jan at 09:46