Some Of The Best Answers From Latest Asked Questions

7

answers

Getting session value in javascript

I am using an external javascript file for my asp.net project. Now i want to get the session value in that javascript. How can i get the session value in that javascript file? Thanks in advance....

4

answers

what do <form action="#"> and <form method="post" action="#"> do?

I'm reading a book on html development (which I'm fairly new at) and despite the fact that the book just had its 1st publishing one month ago (Nov. 2011), the author is an experienced coder and maybe ..

8

answers

Android - get children inside a View?

Given a View how can I get the child views inside it? So I have a custom View and debugger shows that under mChildren there are 7 other views. I need a way to access these views but it doesn't seem l..

34

answers

Android: I am unable to have ViewPager WRAP_CONTENT

I have setup a simple ViewPager that has an ImageView with a height of 200dp on each page. Here is my pager: pager = new ViewPager(this); pager.setLayoutParams(new LayoutParams(LayoutParams.FILL_PAR..

3

answers

How do I disable and re-enable a button in with javascript?

I can easily disable a javascript button, and it works properly. My issue is that when I try to re-enable that button, it does not re-enable. Here's what I'm doing: <script type="text/javascript..

19

answers

Node: log in a file instead of the console

Can I configure console.log so that the logs are written on a file instead of being printed in the console?..

6

answers

How to programmatically send a 404 response with Express/Node?

I want to simulate a 404 error on my Express/Node server. How can I do that?..

14

answers

Stop Chrome Caching My JS Files

I will make a change to my JS files but it won't really change in the browser, I have to rename the files every time so that it reloads it. Is there some sort of .htaccess command I can add or somethi..

7

answers

HTML span align center not working?

I have some HTML: <div align="center" style="border:1px solid red"> This is some text in a div element! </div> The Div is changing the spacing on my document, so I want to use a span fo..

3

answers

Does java have a int.tryparse that doesn't throw an exception for bad data?

Possible Duplicate: Java: Good way to encapsulate Integer.parseInt() how to convert a string to float and avoid using try/catch in java? C# has Int.TryParse: Int32.TryParse Method (String..

13

answers

Storing data into list with class

I have the following class: public class EmailData { public string FirstName{ set; get; } public string LastName { set; get; } public string Location{ set; get; } } I then did the follo..

6

answers

How to instantiate a File object in JavaScript?

There's a File object in JavaScript. I want to instantiate one for testing purposes. I have tried new File(), but I get an "Illegal constructor" error. Is it possible to create a File object ? F..

16

answers

How can I have Github on my own server?

Is there anything out there like Github that is for your own local server? I am curious if there is like a PHP script or even a desktop client that mimics Github's functionality, I love Github but it..

4

answers

Cause of a process being a deadlock victim

I have a process with a Select which takes a long time to finish, on the order of 5 to 10 minutes. I am currently not using NOLOCK as a hint to the MS SQL database engine.At the same time we have anot..

11

answers

Invalid column name sql error

I am trying to enter data into my database, but it is giving me the following error: Invalid column name Here's my code string connectionString = "Persist Security Info=False;User ID=sa;Passwo..

11

answers

Send POST data on redirect with JavaScript/jQuery?

Basically what I want to do is send POST data when I change the window.location, as if a user has submitted a form and it went to a new page. I need to do it this way because I need to pass along a hi..

7

answers

Powershell: How can I stop errors from being displayed in a script?

When my PowerShell script tries, for example, to create a SQL Server object for a server that doesn't exist ("bla" in my case), PowerShell displays lots of PowerShell errors in red. Since my script c..

1

answers

twig: IF with multiple conditions

It seem I have problem with a twig if statement. {%if fields | length > 0 || trans_fields | length > 0 -%} The error is: Unexpected token "punctuation" of value "|" ("name" expected) in I..

7

answers

Get element type with jQuery

Is it possible, using jQuery, to find out the type of an element with jQuery? For example, is the element a div, span, select, or input? For example, if I am trying to load values into a drop-down li..

7

answers

Converting a double to an int in Javascript without rounding

In C# the following code returns 2: double d = 2.9; int i = (int)d; Debug.WriteLine(i); In Javascript, however, the only way of converting a "double" to an "int" that I'm aware of is by using Math...

9

answers

SELECT * FROM X WHERE id IN (...) with Dapper ORM

What is the best way to write a query with IN clause using Dapper ORM when the list of values for the IN clause is coming from business logic? For example let's say I have a query: SELECT * FROM..

10

answers

Where are static methods and static variables stored in Java?

For example: class A { static int i=0; static int j; static void method() { // static k=0; can't use static for local variables only final is permitted // static int L; ..

5

answers

Selecting a Record With MAX Value

In SQL Server 2008 I have a table CUSTOMERS that has two columns as: ID, BALANCE How can I write the query that selects the ID of the customer who has maximum balance, "in the most effective way"? ..

10

answers

Download an SVN repository?

I'm looking for an online tool that will allow me downloading an online SVN repository (google code etc.). Do you know of anything? Update I want to download the top parent folder and all its subfol..

10

answers

Android: checkbox listener

I want to put a Listener over a CheckBox. I looked for info and it is like this: satView = (CheckBox)findViewById(R.id.sateliteCheckBox); satView.setOnCheckedChangeListener(new OnCheckedChangeListen..

9

answers

Extracting specific columns in numpy array

This is an easy question but say I have an MxN matrix. All I want to do is extract specific columns and store them in another numpy array but I get invalid syntax errors. Here is the code: extractedD..

7

answers

Classes cannot be accessed from outside package

I have two packages. The class I want to import from the first package is declared as PUBLIC. Despite, when I test a file from the second package it shows me compilation errors like this: PUBLICcl..

8

answers

Subtract two variables in Bash

I have the script below to subtract the counts of files between two directories but the COUNT= expression does not work. What is the correct syntax? #!/usr/bin/env bash FIRSTV=`ls -1 | wc -l` cd .. ..

5

answers

Batch files: List all files in a directory with relative paths

Concerning Windows batch files: Is there a way to list all the files (or all of a specific type) in a certain directory and its subdirectories, including the paths relative to the current (or the sear..

7

answers

Difference between static memory allocation and dynamic memory allocation

I would like to know what is the difference between static memory allocation and dynamic memory allocation? Could you explain this with any example?..

19

answers

Extract file name from path, no matter what the os/path format

Which Python library can I use to extract filenames from paths, no matter what the operating system or path format could be? For example, I'd like all of these paths to return me c: a/b/c/ a/b/c \a\..

13

answers

How to dismiss the dialog with click on outside of the dialog?

I have implemented a custom dialog for my application. I want to implement that when the user clicks outside the dialog, the dialog will be dismissed. What do I have to do for this?..

7

answers

Auto increment in MongoDB to store sequence of Unique User ID

I am making a analytics system, the API call would provide a Unique User ID, but it's not in sequence and too sparse. I need to give each Unique User ID an auto increment id to mark a analytics datap..

8

answers

ASP.NET Background image

I am using VS2005 C#. I have a .aspx login page and I would like to implement a background image to it. Below is my current page screenshot: Below is my background code: <div align="center..

10

answers

Remove '\' char from string c#

I have the following code string line = ""; while ((line = stringReader.ReadLine()) != null) { // split the lines for (int c = 0; c < line.Length; c++) { if ( line[c] == ',' ..

5

answers

Parsing json and searching through it

I have this code import json from pprint import pprint json_data=open('bookmarks.json') jdata = json.load(json_data) pprint (jdata) json_data.close() How can I search through it for u'uri': u'http..

4

answers

How to ssh connect through python Paramiko with ppk public key

i'm using Paramiko to connect through ssh to a server. Basic authentication works well, but i can't understand how to connect with public key. When i connect with putty, the server tell me this: Us..

8

answers

How do I 'git diff' on a certain directory?

git diff actually runs a diff on all source code. How do I do this on a certain directory, so that I can view modifications on files underneath it?..

12

answers

Vertical Menu in Bootstrap

Is there a way to create a vertical menu (not dropdown, entirely separate vertical menu on sidebar) by using any bootstrap class? I can create one using my css, but just want to know if there is any b..

4

answers

Replace words in a string - Ruby

I have a string in Ruby: sentence = "My name is Robert" How can I replace any one word in this sentence easily without using complex code or a loop?..

2

answers

Handle JSON Decode Error when nothing returned

I am parsing json data. I don't have an issue with parsing and I am using simplejson module. But some api requests returns empty value. Here is my example: { "all" : { "count" : 0, "question..

13

answers

Enable remote MySQL connection: ERROR 1045 (28000): Access denied for user

MySQL 5.1.31 running on Windows XP. From the local MySQL server (192.168.233.142) I can connect as root as follows: >mysql --host=192.168.233.142 --user=root --password=redacted From a remote m..

8

answers

How does a Breadth-First Search work when looking for Shortest Path?

I've done some research, and I seem to be missing one small part of this algorithm. I understand how a Breadth-First Search works, but I don't understand how exactly it will get me to a specific path,..

14

answers

Generating unique random numbers (integers) between 0 and 'x'

I need to generate a set of unique (no duplicate) integers, and between 0 and a given number. That is: var limit = 10; var amount = 3; How can I use Javascript to generate 3 unique numbers between..

20

answers

How to cin to a vector

I'm trying to ask the user to enter numbers that are put into a vector, then using a function call to count the numbers, why is this not working? I am only able to count the first number. template &..

10

answers

Get value of a string after last slash in JavaScript

I am already trying for over an hour and cant figure out the right way to do it, although it is probably pretty easy: I have something like this : foo/bar/test.html I would like to use jQuery to ext..

24

answers

Missing artifact com.sun:tools:jar

I've been following the getting started tutorial, but am stuck after I imported the playn project using Maven. I am using Eclipse Indigo running on 64bit Windows 7. All the imported projects have th..

7

answers

Regex Last occurrence?

I'm trying to catch the last part after the last backslash I need the \Web_ERP_Assistant (with the \) My idea was : C:\Projects\Ensure_Solution\Assistance\App_WebReferences\Web_ERP_WebService\Web_E..

12

answers

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=0, data=null} to activity

My app allows the user to press a button, it opens the camera, they can take a photo and it will show up in an imageview. If the user presses back or cancel while the camera is open I get this force c..

3

answers

How to hide .php extension in .htaccess

Possible Duplicate: Remove .php extension with .htaccess I'm trying to hide the .php file extension but for some reason can't get it to work. My latest attempt was the following: <IfMod..

9

answers

How to Parse JSON Array with Gson

I want to parse JSON arrays and using gson. Firstly, I can log JSON output, server is responsing to client clearly. Here is my JSON output: [ { id : '1', title: 'sample..

8

answers

How do I loop through rows with a data reader in C#?

I know I can use while(dr.Read()){...} but that loops every field on my table, I want to retrieve all the values from the first row, and then second... and so on. Let's say I have a table like this: ..

2

answers

Complex numbers usage in python

I'm a math newbie. Now I'm getting deeper into Python data types. I can't understand how to use a complex number. Please give me examples of usage of complex numbers in Python...

4

answers

How can I interrupt a running code in R with a keyboard command?

Can anyone tell how can I interrupt a running script in R? Let's say I have an infinite loop or some other problem, and I want to stop the script from running. Is there a keyboard command that does ..

9

answers

Referring to a Column Alias in a WHERE Clause

SELECT logcount, logUserID, maxlogtm , DATEDIFF(day, maxlogtm, GETDATE()) AS daysdiff FROM statslogsummary WHERE daysdiff > 120 I get "invalid column name daysdiff". Maxlogtm is a date..

6

answers

Change the location of an object programmatically

I've tried the following code: this.balancePanel.Location.X = this.optionsPanel.Location.X; to change the location of a panel that I made in design mode while the program is running but it return..

3

answers

How do I make a text go onto the next line if it overflows?

I tried word-wrap: break-word;, but it separates lines mid word...

8

answers

Limiting the number of characters in a string, and chopping off the rest

I need to create a summary table at the end of a log with some values that are obtained inside a class. The table needs to be printed in fixed-width format. I have the code to do this already, but I..

23

answers

How to read a text file into a string variable and strip newlines?

I use the following code segment to read a file in python: with open ("data.txt", "r") as myfile: data=myfile.readlines() Input file is: LLKKKKKKKKMMMMMMMMNNNNNNNNNNNNN GGGGGGGGGHHHHHHHHHHHHHH..

19

answers

Serializing with Jackson (JSON) - getting "No serializer found"?

I get the an exception when trying to serialize a very simple object using Jackson. The error: org.codehaus.jackson.map.JsonMappingException: No serializer found for class MyPackage.TestA and no..

7

answers

Conditional formatting using AND() function

I'm trying conditional formatting on a sheet. I need to fill the cells with a certain color according to the following conditional statement: =AND((INDIRECT(ADDRESS(4;COLUMN()))>=INDIRECT(ADDRESS(..

5

answers

how do I set height of container DIV to 100% of window height?

I have a couple of problems with my container DIV. For one it is not recognising the height of my content correctly (I would have thought it would extend beyond the bottom of the main content and sid..

13

answers

Execute command without keeping it in history

I want to execute some commands but don't want to store them in the command history. So that nobody will be able to search it in the .bash_history file. Is there any way how to execute bash commands ..

7

answers

Selenium: Can I set any of the attribute value of a WebElement in Selenium?

I have a WebElement, I want to reset its an attribute's value to some other value (for e.g. attr is the attribute, and I want to change its original value=1 to new value=10). Is it possible? I am us..

3

answers

VBA: Conditional - Is Nothing

There is an If condition in a VBA application as seen below: If Not My_Object Is Nothing Then My_Object.Compute When the code is run in debug mode, I found that the If condition returns a true even..

4

answers

How to set text color to a text view programmatically

How can I set Text Color of a text view to #bdbdbd programatically?..

9

answers

Which JRE am I using?

There are two varieties of JRE available. Java VM: IBM vs. Sun. Is there a way to know which JRE I am using through JavaScript or some Java issued command...

9

answers

How can you use php in a javascript function

<html> <?php $num = 1; echo $num; ?> <input type="button" name="lol" value="Click to increment" onclick="Inc()" /> &..

8

answers

Find ALL tweets from a user (not just the first 3,200)

With https://dev.twitter.com/docs/api/1/get/statuses/user_timeline I can get 3,200 most recent tweets. However, certain sites like http://www.mytweet16.com/ seems to bypass the limit, and my browse th..

5

answers

How to resize image (Bitmap) to a given size?

How to resize image (Bitmap) to for example 800*480 programatically ? I have retrieved a picture in my app which is ~1MB and I need to scale it down to 800*480 I have loaded that picture and compresse..

7

answers

T-SQL to list all the user mappings with database roles/permissions for a Login

I am looking for a t-sql script which can list the databases and and the respective roles/privileges mapped for a particular user. Using SQL Server 2008 R2...

19

answers

How do I check if a column is empty or null in MySQL?

I have a column in a table which might contain null or empty values. How do I check if a column is empty or null in the rows present in a table? (e.g. null or '' or ' ' or ' ' and ...) ..

7

answers

Git commit -a "untracked files"?

When I do a git commit -a, I am seeing the following: # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # O..

7

answers

Get the latest date from grouped MySQL data

I have the following data in my database: |NO | model | date | +---+-------+----------+ |1 | bee |2011-12-01| |2 | bee |2011-12-05| |3 | bee |2011-12-12| |4 | tar |2011-12-13| I wa..

1

answers

Reading multiple Scanner inputs

What I am trying to do is have multiple inputs that all have different variables. Each variable will be part of different equations. I am looking for a way to do this and, I think I have an idea. I ju..

11

answers

Get URL query string parameters

What is the "less code needed" way to get parameters from a URL query string which is formatted like the following? www.mysite.com/category/subcategory?myqueryhash Output should be: myqueryhash ..

15

answers

Child inside parent with min-height: 100% not inheriting height

I found a way to make a div container to occupy at least full height of a page, by setting min-height: 100%;. However, when I add a nested div and set height: 100%;, it doesn't stretch to container's ..

22

answers

Echo newline in Bash prints literal \n

In Bash, tried this: echo -e "hello\nworld" But it doesn't print a newline, only \n. How can I make it print the newline? I'm using Ubuntu 11.04...

9

answers

jQuery Validate - Enable validation for hidden fields

In the new version of jQuery validation plugin 1.9 by default validation of hidden fields ignored. I'm using CKEditor for textarea input field and it hides the field and replace it with iframe. The fi..

4

answers

integrating barcode scanner into php application?

We have been developing web application in php. We need barcode scanner to be integrated into our application. Our application is divided into two modules, users and merchant. When user comes and sc..

8

answers

find all unchecked checkbox in jquery

I have a list of checkboxes: <input type="checkbox" name="answer" id="id_1' value="1" /> <input type="checkbox" name="answer" id="id_2' value="2" /> ... <input type="checkbox" name="an..

21

answers

Can not connect to local PostgreSQL

I've managed to bork my local development environment. All my local Rails apps are now giving the error: PGError could not connect to server: Permission denied Is the server running locally and ..

4

answers

How can I set the max-width of a table cell using percentages?

<table> <tr> <td>Test</td> <td>A long string blah blah blah</td> </tr> </table> <style> td{max-width:67%;} </style> The above does not wo..

11

answers

How do I concatenate two strings in C?

How do I add two strings? I tried name = "derp" + "herp";, but I got an error: Expression must have integral or enum type ..

5

answers

Why is JsonRequestBehavior needed?

Why is Json Request Behavior needed? If I want to restrict the HttpGet requests to my action I can decorate the action with the [HttpPost] attribute Example: [HttpPost] public JsonResult Foo() { ..

5

answers

Customize the Authorization HTTP header

I need to authenticate a client when he sends a request to an API. The client has an API-token and I was thinking about using the standard Authorization header to send the token to the server. Normal..

3

answers

PostgreSQL 'NOT IN' and subquery

I'm trying to execute this query: SELECT mac, creation_date FROM logs WHERE logs_type_id=11 AND mac NOT IN (select consols.mac from consols) But I get no results. I tested it, and I know that the..

4

answers

Convert int (number) to string with leading zeros? (4 digits)

Possible Duplicate: Number formatting: how to convert 1 to "01", 2 to "02", etc.? How can I convert int to string using the following scheme? 1 converts to 0001 123 converts to 0123 Of ..

8

answers

How to check sbt version?

How do I check which version of sbt I'm running? I have the bash file set up that uses sbt-launch.jar, and it works, but $ sbt version only shows the "project version" (0.1) and $ sbt --ve..

3

answers

How can I assign an ID to a view programmatically?

In an XML file, we can assign an ID to a view like android:id="@+id/something" and then call findViewById(), but when creating a view programmatically, how do I assign an ID? I think setId() is not t..

7

answers

Finding element in XDocument?

I have a simple XML <AllBands> <Band> <Beatles ID="1234" started="1962">greatest Band<![CDATA[lalala]]></Beatles> <Last>1</Last> <Salary>..

3

answers

Sort tuples based on second parameter

I have a list of tuples that look something like this: ("Person 1",10) ("Person 2",8) ("Person 3",12) ("Person 4",20) What I want produced, is the list sorted in ascending order, by the second valu..

8

answers

MySQL - select data from database between two dates

I have saved the dates of a user's registration as a datetime, so that's for instance 2011-12-06 10:45:36. I have run this query and I expected this item - 2011-12-06 10:45:36 - will be selected: SEL..

3

answers

ASP.NET page life cycle explanation

I was asked to explain the ASP.NET page life cycle in an interview some time back. I did explain it to him, but he was not satisfied with my answer. Could someone explain the life cycle to me please?..

27

answers

How to disable action bar permanently

I can hide the action bar in honeycomb using this code: getActionBar().hide(); But when the keyboard opens, and user copy-pastes anything, the action bar shows again. How can I disable the action b..

7

answers

Origin null is not allowed by Access-Control-Allow-Origin

I have made a small xslt file to create an html output called weather.xsl with code as follows: <!-- DWXMLSource="http://weather.yahooapis.com/forecastrss?w=38325&u=c" --> <xsl:styleshee..

15

answers

Open URL in same window and in same tab

I want to open a link in the same window and in the same tab that contains the page with the link. When I try to open a link by using window.open, then it opens in new tab—not in the same tab in th..

3

answers

How can I get the nth character of a string?

I have a string, char* str = "HELLO" If I wanted to get just the E from that how would I do that?..

5

answers

Toggle display:none style with JavaScript

I want to change the style (second line below) to remove the display: none; part when the user clicks on the "Show All Tags" link. If the user clicks the "Show All Tags" link again, I need the display..

8

answers

Extracting .jar file with command line

I am trying to extract the files from a .jar file. How do I do that using command line? I am running Windows 7..