Select single item from a list

Select single item from a list

Using LINQ what is the best way to select a single item from a list if the item may not exists in the list?I have come up with two solutions, neither of which I like. I use a where clause to select the list of items (which I know will only

Ideal settings for pgbouncer with Django's CONN_MAX_AGE

Ideal settings for pgbouncer with Django's CONN_MAX_AGE

I'm running a multi-tennant website, where I would like to reduce the overhead of creating a PostgreSQL connection per request. Django's CONN_MAX_AGE allows this, at the expense of creating a lot of open idle connections to PostgreSQL (8 wo

How to run UnitTests in maven which is in src/test-integration/java folder

How to run UnitTests in maven which is in src/test-integration/java folder

When we say mvn test, usual way is that maven will look for the tests present in src/test/java folder. But I have my tests in some different folder, namely src/integration-test/java. How do I run the tests present in this folder through com

how to hide the status bar in eclipse

how to hide the status bar in eclipse

Is there a way to hide the quite large status bar cluttering the bottom of the eclipse window ? (where the heap status, line and column count and further non-essential info is shown). I am forced to work on a tiny screen here so I already h

Getting a white space at bottom of iphone x screen(xcode 9)

Getting a white space at bottom of iphone x screen(xcode 9)

I'm using Xcode 9 for my project and I'm getting a white space at the bottom, here is the screenshot:Also I'm using storyboard to design with 4 inches (iphone 5s/SE) as layout.How to avoid the white space? 1:Your bottom constraints shoul

Lombok how to customise getter for Boolean object field?

Lombok how to customise getter for Boolean object field?

One of my POJOs has a Boolean object field to permit NULLS in the database (a requirement). Is it possible to use the @Data Lombok annotation at class level yet override the getter for the Boolean field? The default it generates is getXXX m

Python optional parameters

Python optional parameters

Guys, I just started python recently and get confused with the optional parameters, say I have the program like this:class B: passclass A: def __init__(self, builds = B()): self.builds = buildsIf I create A twiceb = A()c = A()an

Frameworks are 'red' in Xcode

Frameworks are 'red' in Xcode

I downloaded a project developed by Apple employees ( who taught course at Stanford on iPhone application development). Strangely , the frameworks are red.http://img.skitch.com/20100730-kcjun96mp2pxnpg7w3x6njw57.jpgI tried to locate coreGra

How can I make a WPF Expander Stretch?

How can I make a WPF Expander Stretch?

The Expander control in WPF does not stretch to fill all the available space. Is there any solutions in XAML for this? 1:All you need to do is this: I am some content... http://joshsmithonwpf.wordpress.com/2007/02/24/stretc

How to get UIImage of AppIcon?

How to get UIImage of AppIcon?

I am using Assets Catalog, and adding app icon of various size to the assets is okay.But when I tried to get the UIImage programmatically, it returned nil.UIImage *appIcon = [UIImage imageNamed"AppIcon"];The app icon is named AppIcon (the d

Setting initial values on load with Select2 with Ajax

Setting initial values on load with Select2 with Ajax

I have select2 controls set up with Ajax (have both single and multiple). I'm trying to have some values on page load but I'm not able to get this to work however. My code for select2 is given below:function AjaxCombo(element, url, multiv

How to select current date in Hive SQL

How to select current date in Hive SQL

How do we get the current system date in Hive? In MySQL we have select now(), can any one please help me to get the query results. I am very new to Hive, is there a proper documentation for Hive that gives the details information about the

git - diff of current changes before committing

git - diff of current changes before committing

I have changed several files in a git repository, but have not committed them yet.I can get a list of the changes by just invoking git status. But how do I get a listing of the lines or the content that I have changed, in addition to the fi

Display and save the plot simultaneously in R, RStudio

Display and save the plot simultaneously in R, RStudio

I need to save the plot as .png and show the plot at the same time without duplicating the code.Is there an elegant way to do it? Working on RStudio for MAC.I can get it to work as bellow but I don't like it.#Step1: save the plotpng("myplot

dynamically set database based on request in django

dynamically set database based on request in django

I am writing a multi-tenant application with python-django.I want to set database connection based on each request.I thought i could write a middleware where we set the database to be used for that particular database.import refrom django.d

How to achieve a blur effect in PHP?

How to achieve a blur effect in PHP?

I've been looking for PHP code to apply a Gaussian blur to images.What I've done was like this:However the effect is very weak, and if I repeat the blur effect, it takes a very long time to process and the end result is still not that good.

Stop browser load from selenium webdriver

Stop browser load from selenium webdriver

My selenium webdriver goes to a page and waits for that page to finish loading. If 30 seconds pass it times-out and the script fails. Is there anyway to have the webdriver stop the page loading after 30 seconds(like pressing the 'x' on th

Hooking the http/https protocol in IE causes GET requests to be sequential

Hooking the http/https protocol in IE causes GET requests to be sequential

I'm using the PassthruAPP method to hook into HTTP/HTTPS requests made by IE.It's working well for the most part, however I noticed a problem. Only one download thread is active at a time, normally IE uses two download threads. I can see

Android: Display digits in Arabic format

Android: Display digits in Arabic format

How can I show the digits in Arabic format?So, if I have integers: 1,2,3 they become '١', '٢', '٣' 1:set the locale to Arabic, EgyptNumberFormat nf=NumberFormat.getInstance(new Locale("ar","EG"));nf.format(i); 2:int i = 1;NumberFormat

How to customize only with css for html5 input range slider-vertical?

How to customize only with css for html5 input range slider-vertical?

I would like to customize the look of a html5 input[range] when it's vertical.Want to avoid CSS 3 directive like transform:rotate, it complicates the UI layout then.Webkit css properties are recognised in my context, the others vendors are

Ninject-ing a dependency in Global.asax

Ninject-ing a dependency in Global.asax

I'm starting a web application with MVC3 and Ninject. There is one dependency that I also need in the Global.asax file that needs to be a singleton.I thought it should be like this:public class MvcApplication : NinjectHttpApplication{ IU

How to use GitHub V3 API to get commit count for a repo?

How to use GitHub V3 API to get commit count for a repo?

I am trying to count commits for many large github repos using the API, so I would like to avoid getting the entire list of commits (this way as an example: api.github.com/repos/jasonrudolph/keyboard/commits ) and counting them.If I had the

Error pages not found, throwing ELMAH error with Custom Error Pages

Error pages not found, throwing ELMAH error with Custom Error Pages

I've made some modifications to Global.asax so that I can show custom error pages (403, 404, and 500) Here's the code: public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() {

Filling bars in barplot with textiles rather than color in R

Filling bars in barplot with textiles rather than color in R

I am trying to fill bars in a barplot using different textiles rather than color.I know how to fill the bars with different patterns of lines like this:aaa This will give me something like this: ___4|

Mapper input Key-Value pair in Hadoop

Mapper input Key-Value pair in Hadoop

Normally, we write the mapper in the form : public static class Map extends MapperHere the input key-value pair for the mapper is - as far as I know when the mapper gets the input data its goes through line by line - so the Key for the map