Questions

Generate a random point within a circle (uniformly)

I need to generate a uniformly random point within a circle of radius . I realize that by just picking a uniformly random angle in the interval [0 ... 2π), and uniformly random radius in the interval...

8 Jun at 05:59

MySQL OPTIMIZE all tables?

MySQL has an [OPTIMIZE TABLE](http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html) command which can be used to reclaim unused space in a MySQL install. Is there a way (built-in command or com...

29 Mar at 15:1

How to change facet labels?

I have used the following `ggplot` command: ``` ggplot(survey, aes(x = age)) + stat_bin(aes(n = nrow(h3), y = ..count.. / n), binwidth = 10) + scale_y_continuous(formatter = "percent", breaks = c(0...

11 Apr at 12:40

How do I get the current time zone of MySQL?

Anyone knows if there is such a function in MySQL? This doesn't output any valid info: ``` mysql> SELECT @@global.time_zone, @@session.time_zone; +--------------------+---------------------+ | @@g...

3 Sep at 17:39

How to append a new row to an old CSV file in Python?

I am trying to add a new row to my old CSV file. Basically, it gets updated each time I run the Python script. Right now I am storing the old CSV rows values in a list and then deleting the CSV file a...

22 May at 11:19

How can I autoformat/indent C code in vim?

When I copy code from another file, the formatting is messed up, like this: ``` fun() { for(...) { for(...) { if(...) { } } } } ``` How can I autoformat this code in vim?

7 May at 19:6

Check if string begins with something?

I know that I can do like `^=` to see if an id starts with something, and I tried using that for this, but it didn't work. Basically, I'm retrieving a URL and I want to set a class for an element for ...

10 Oct at 00:21

TransactionScope automatically escalating to MSDTC on some machines?

In our project we're using TransactionScope's to ensure our data access layer performs it's actions in a transaction. We're aiming to require the MSDTC service to be enabled on our end-user's machine...

How to bind to a PasswordBox in MVVM

I have come across a problem with binding to a `PasswordBox`. It seems it's a security risk but I am using the MVVM pattern so I wish to bypass this. I found some interesting code here (has anyone use...

27 Aug at 16:42

Passing properties by reference in C#

I'm trying to do do the following: ``` GetString( inputString, ref Client.WorkPhone) private void GetString(string inValue, ref string outValue) { if (!string.IsNullOrEmpty(inValue)) ...

17 Nov at 11:7

Mapping two integers to one, in a unique and deterministic way

Imagine two positive integers A and B. I want to combine these two into a single integer C. There can be no other integers D and E which combine to C. So combining them with the addition operator do...

SQL left join vs multiple tables on FROM line?

Most SQL dialects accept both the following queries: ``` SELECT a.foo, b.foo FROM a, b WHERE a.x = b.x SELECT a.foo, b.foo FROM a LEFT JOIN b ON a.x = b.x ``` Now obviously when you need an outer ...

28 May at 13:11

How to properly create an SVN tag from trunk?

I am creating my first project in [Subversion](http://en.wikipedia.org/wiki/Apache_Subversion). So far I have ``` branches tags trunk ``` I think I immediately need to make branches singular and ...

14 Nov at 18:7

How to list running screen sessions?

I have a bunch of servers, on which I run experiments using `screen`. The procedure is the following : 1. ssh to server XXX 2. launch screen 3. start experiments in a few tabs 4. detach screen 5. di...

2 Nov at 22:4

Why compile Python code?

Why would you compile a Python script? You can run them directly from the .py file and it works fine, so is there a performance advantage or something? I also notice that some files in my applicatio...

30 Oct at 04:25

How can I escape square brackets in a LIKE clause?

I am trying to filter items with a [stored procedure](https://en.wikipedia.org/wiki/Stored_procedure) using . The column is a varchar(15). The items I am trying to filter have square brackets in the n...

How to deal with SQL column names that look like SQL keywords?

One of my columns is called `from`. I can't change the name because I didn't make it. Am I allowed to do something like `SELECT from FROM TableName` or is there a special syntax to avoid the SQL Serve...

2 Oct at 14:6

How do I turn a String into a InputStreamReader in java?

How can I transform a `String` value into an `InputStreamReader`?

13 Dec at 23:29

HTTP 1.0 vs 1.1

Could somebody give me a brief overview of the differences between HTTP 1.0 and HTTP 1.1? I've spent some time with both of the RFCs, but haven't been able to pull out a lot of difference between the...

20 Jun at 09:12

Case-insensitive search

I'm trying to get a case-insensitive search with two strings in JavaScript working. Normally it would be like this: ``` var string="Stackoverflow is the BEST"; var result= string.search(/best/i); al...

Find out how much memory is being used by an object in Python

How would you go about finding out how much memory is being used by an object? I know it is possible to find out how much is used by a block of code, but not by an instantiated object (anytime during ...

9 Mar at 23:17

How do I disable a Button in Flutter?

I'm just starting to get the hang of Flutter, but I'm having trouble figuring out how to set the enabled state of a button. From the docs, it says to set `onPressed` to null to disable a button, and ...

26 Dec at 09:50

How to create Toast in Flutter

Can I create something similar to [Toasts](https://developer.android.com/guide/topics/ui/notifiers/toasts.html) in Flutter? [](https://i.stack.imgur.com/a2ahK.jpg) Just a tiny notification window that...

26 Dec at 09:44

TypeScript-'s Angular Framework Error - "There is no directive with exportAs set to ngForm"

I keep getting this error while using TypeScript's Angular2-forms framework: > `directive` Here's my code project dependencies : ``` "dependencies": { "@angular/common": "2.0.0-rc.6", "@an...

Is there a way to "extract" the type of TypeScript interface property?

Let's suppose there's a typing file for library X which includes some interfaces. ``` interface I1 { x: any; } interface I2 { y: { a: I1, b: I1, c: I1 } z:...

11 Aug at 23:29