Why is lock(this) {…} bad?

Why is lock(this) {…} bad?

The MSDN documentation says thatpublic class SomeObject{ public void SomeOperation() { lock(this) { //Access instance variables } }}is "a problem if the instance can be accessed publicly". I'm wondering why? Is it because t

Is Ruby pass by reference or by value?

Is Ruby pass by reference or by value?

@user.update_languages(params[:language][:language1], params[:language][:language2], params[:language][:language3])lang_errors = @user.errorslogger.debug "--------------------LANG_ERRORS--------

Android Studio Rename Package

Android Studio Rename Package

How do you rename packages in new IDE Android Studio, based on intelijj ?Is there any automatic refactoring included? I want to make bulk refactoring but I don't know how. I worked 2 years with eclipse and in eclipse it's one click operatio

Javascript: Do I need to put this.var for every variable in an object?

Javascript: Do I need to put this.var for every variable in an object?

In C++, the language I'm most comfortable with, usually one declares an object like this:class foo{public: int bar; int getBar() { return bar; }}Calling getBar() works fine (ignoring the fact that bar might be uninitialized). The vari

“INSERT IGNORE” vs “INSERT … ON DUPLICATE KEY UPDATE”

“INSERT IGNORE” vs “INSERT … ON DUPLICATE KEY UPDATE”

While executing an INSERT statement with many rows, I want to skip duplicate entries that would otherwise cause failure. After some research, my options appear to be the use of either: ON DUPLICATE KEY UPDATE which implies an unnecessary u

What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

I have some code and when it executes, it throws a IndexOutOfRangeException, saying, Index was outside the bounds of the array.What does this mean, and what can I do about it?Depending on classes used it can also be ArgumentOutOfRangeExce

Tree item select event in javafx2

Tree item select event in javafx2

I have created the treeview in javafx2. i need to write the event for getting clicked node name. pls let me know how to do this? 1:use ChangeListener .Sample code : treeView.getSelectionModel().selectedItemProperty().addListener( new Ch

Which is better? array, ArrayList or List (in terms of performance and speed)

Which is better? array, ArrayList or List (in terms of performance and speed)

I require a fast speed in processing my page. The count of the values to be added will be dynamic.Which one of the above is preferred? Support with a valid reason.Edit: For eg:string str = "a,b,c"; //Count of the number of elements in str i

How can I force overflow: hidden to not use up my padding-right space

How can I force overflow: hidden to not use up my padding-right space

I have the following code:2222222222222222222222111111111111111111111111113333333333333333333(XHTML 1.0 transitional)What happens is that the padding-right doesn't appear, it's occupied by the content, which means the overflow uses up the p

Intellij “Make project automatically” woes

Intellij “Make project automatically” woes

Back in december I switched from Eclipse to IntelliJ but within a couple of days I switched back.Today I tried IntelliJ again and basically I have only one issue left.The issue is I want to compile Java classes on saving. The reason is I'm

Put a button over an ImageView

Put a button over an ImageView

I'm newbie in Android.I would like to know if it's possible to put a button or another component over an ImageView. I've tried setting the image as a background image of a LinearLayout, but when I change between landscape and portrait mode,

data.table - does setkey(…) create an index or physically reorder the rows in a data table?

data.table - does setkey(…) create an index or physically reorder the rows in a data table?

This (very basic) question is the result of an exchange here. The documentation for setkey() states: setkey() sorts a data.table and marks it as sorted. The sorted columns are the key. The key can be any columns in any order. The columns

Why should objects in Redux be immutable?

Why should objects in Redux be immutable?

Why should objects in Redux be immutable?I know that some frameworks such as Angular2 will use onPush and can take advantage of immutability to compare states of views for faster rendering, but I am wondering if there are other reasons as R

Django annotation with nested filter

Django annotation with nested filter

Is it possible to filter within an annotation? In my mind something like this (which doesn't actually work)Student.objects.all().annotate(Count('attendance').filter(type="Excused"))The resultant table would have every student with the numbe

UIButton in Swift is not registering touches

UIButton in Swift is not registering touches

I'm trying to create a UIButton using Swift. It compiles fine and I can see my button in the simulator, but when I click it, nothing happens. This is the code I am using:let settings = UIButton()settings.addTarget(self, action: "touchedSet:

How can I display an image in the Applet?

How can I display an image in the Applet?

I have an image and I want to display it in the applet, The problem is the image wont display. Is there something wrong with my code?Thanks...Here's my code :import java.applet.Applet;import java.awt.*; public class LastAirBender extends Ap

How to load language with gettext in PHP?

How to load language with gettext in PHP?

I have created a language file in poedit for the use of the PHP gettext function, now on the page I am trying to test it on, I cannot get it to find/load the .po or .mo file I created, does anyone see what I am doing wrong?$locale = "en_US"

Multiple DbContexts on one DB with Code First Migrations

Multiple DbContexts on one DB with Code First Migrations

I stumbled uppon the same problem as described in this question. In addition, i didn't want to loose the __migrationHistory table from the database.I tried it with the suggested Solution of using one "super" context which contains all DbSet

Running a standalone script doing a model query in Django with `settings/dev.py` instead of `setting

Running a standalone script doing a model query in Django with `settings/dev.py` instead of `setting

Note the settings/dev.py instead of one settings.py file and the script.py in my_app in the following Django(1.4.3) project:.├── my_project│ ├── my_app│ │ ├── __init__.py│ │ ├── models.py│ │ ├── tests.py│ │ ├── views.py│

Uploaded docx files turning into zip

Uploaded docx files turning into zip

I am currently using symfony 1.4 and would like to allow users to upload Microsoft Word docx files. Using the sfWidgetFormInputFile widget and sfValidatorFile below users are able to select and successfully upload their docx files using a

Elegant solution to implement timeout for bash commands and functions

Elegant solution to implement timeout for bash commands and functions

I wrote a function to run commands, which takes two args 1st a command 2nd timeout in seconds:#! /bin/bashfunction run_cmd { cmd="$1"; timeout="$2" grep -qP "^\d+$" $exitfile) & start=$(date +%s) while true; do pid=$(job

JavaScript to listen for URL changes in YouTube HTML5 Player

JavaScript to listen for URL changes in YouTube HTML5 Player

I'm writing a Chrome extension so I need to be able to listen for changes in the YouTube URL (i.e., see that you switched videos). YouTube makes this hard because with its HTML5 video player there is no full page reload, there is no URL fra

Reordering groups in Likert plots with R

Reordering groups in Likert plots with R

I'm using the jbryer/likert package to plot Likert data.Consider the response table, called items—here, A, B, and so on are the column names, not part of the data:A B C D5 4 5 43 3 3 42 2 2 22 2 2 35 3 6 73 3 5 4And the following code:choic

IPython 4 shell does not work with Sublime REPL

IPython 4 shell does not work with Sublime REPL

I am having problems with running the IPython shell from the Sublime REPL package. Here is what I get: C:\Anaconda\lib\site-packages\IPython\config.py:13: ShimWarning: The`IPython.config` package has been deprecated. You should import from

Iphone - device - linker error

Iphone - device - linker error

I have added libpng to my application. If I build for simulator, everything is OK. When I build application for device, I got linker error: Undefined symbols for architecture armv7: "_png_init_filter_functions_neon", referenced from: _pn