Questions Tagged with #Svn server

Determine function name from within that function (without using traceback)

In Python, without using the traceback module, is there a way to determine a function's name from within that function? Say I have a module foo with a function bar. When executing foo.bar(), is ther..

How connect Postgres to localhost server using pgAdmin on Ubuntu?

I installed Postgres with this command sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev Using psql --version on terminal I get psql (PostgreSQL) 9.3.4 then I installe..

AngularJS - Passing data between pages

I am an AngularJS starter. I am trying to send data from : Page A : Van Listing page to Page B: Van Update page. When user click the update link for a van, I am invoking a controller and retrievi..

Group by in LINQ

Let's suppose if we have a class like: class Person { internal int PersonID; internal string car; } I have a list of this class: List<Person> persons; And this list can have multi..

Rounding a number to the nearest 5 or 10 or X

Given numbers like 499, 73433, 2348 what VBA can I use to round to the nearest 5 or 10? or an arbitrary number? By 5: 499 -> 500 2348 -> 2350 7343 -> 7345 By 10: 499 -> 500 2348 -..

'Incomplete final line' warning when trying to read a .csv file into R

I'm trying to read a .csv file into R and upon using this formula: pheasant<-read.table(file.choose(),header=TRUE,sep=",") I get this warning message: "incomplete final line found by readTableH..

How can I sort an ArrayList of Strings in Java?

I have Strings that are put into an ArrayList randomly. private ArrayList<String> teamsName = new ArrayList<String>(); String[] helper; For example: teamsName.add(helper[0]) where hel..

How to implement a queue using two stacks?

Suppose we have two stacks and no other temporary variable. Is to possible to "construct" a queue data structure using only the two stacks?..

How do I get time of a Python program's execution?

I have a command line program in Python that takes a while to finish. I want to know the exact time it takes to finish running. I've looked at the timeit module, but it seems it's only for small snip..

How to create named and latest tag in Docker?

Supposed I have an image that I want to tag as 0.10.24 (in my case it's an image containing Node.js 0.10.24). I built that image using a Dockerfile and executing docker build and by providing a tag us..

How to git clone a specific tag

From git-clone(1) Manual Page --branch can also take tags and detaches the HEAD at that commit in the resulting repository. I tried git clone --branch <tag_name> <repo_url> But ..

How to validate GUID is a GUID

How to determine if a string contains a GUID vs just a string of numbers. will a GUID always contain at least 1 alpha character?..

installing cPickle with python 3.5

This might be silly but I am unable to install cPickle with python 3.5 docker image Dockerfile FROM python:3.5-onbuild requirements.txt cpickle When I try to build the image $ docker build -t ..

Column calculated from another column?

Given the following table: id | value -------------- 1 6 2 70 Is there a way to add a column that is automatically calculated based on another column in the same table? Like a VIEW, but pa..

Alternative to mysql_real_escape_string without connecting to DB

I'd like to have a function behaving as mysql_real_escape_string without connecting to database as at times I need to do dry testing without DB connection. mysql_escape_string is deprecated and theref..

Convert string to datetime in vb.net

I have a datetime that looks like this: 201210120956 ccyyMMDDhhmm When I try this: Dim convertedDate As Date = Date.Parse(DateString) Return convertedDate I get back this: #10/12/2012# I'm lo..

Password hash function for Excel VBA

I need a function written in Excel VBA that will hash passwords using a standard algorithm such as SHA-1. Something with a simple interface like: Public Function CreateHash(Value As String) As Strin..

ASP.NET Identity's default Password Hasher - How does it work and is it secure?

I am wondering wether the Password Hasher that is default implemented in the UserManager that comes with MVC 5 and ASP.NET Identity Framework, is secure enough? And if so, if you could explain to me h..

Count number of rows within each group

I have a dataframe and I would like to count the number of rows within each group. I reguarly use the aggregate function to sum data as follows: df2 <- aggregate(x ~ Year + Month, data = df1, sum)..

How to prevent robots from automatically filling up a form?

I'm trying to come up with a good enough anti-spamming mechanism to prevent automatically generated input. I've read that techniques like captcha, 1+1=? stuff work well, but they also present an extra..

Calling one method from another within same class in Python

I am very new to python. I was trying to pass value from one method to another within the class. I searched about the issue but i could not get proper solution. Because in my code, "if" is calling cla..

Using RegEX To Prefix And Append In Notepad++

I have quite a large list of words in a txt file and I'm trying to do a regex find and replace in Notepad++. I need to add a string before each line and after each line.. So that: wordone wordtwo wo..

Fragment Inside Fragment

I need help regarding working on fragment inside fragment, actually I am facing a problem on pressing back button. Application Main screen has buttons and pressing on each button view replace with new..

Java Array, Finding Duplicates

I have an array, and am looking for duplicates. duplicates = false; for(j = 0; j < zipcodeList.length; j++){ for(k = 0; k < zipcodeList.length; k++){ if (zipcodeList[k] == zipcodeLi..

Updating a dataframe column in spark

Looking at the new spark dataframe api, it is unclear whether it is possible to modify dataframe columns. How would I go about changing a value in row x column y of a dataframe? In pandas this would..

deleting rows in numpy array

I have an array that might look like this: ANOVAInputMatrixValuesArray = [[ 0.96488889, 0.73641667, 0.67521429, 0.592875, 0.53172222], [ 0.78008333, 0.5938125, 0.481, 0.39883333, 0.]] Notice that ..

Launching an application (.EXE) from C#?

How can I launch an application using C#? Requirements: Must work on Windows XP and Windows Vista. I have seen a sample from DinnerNow.net sampler that only works in Windows Vista...

How to add ID property to Html.BeginForm() in asp.net mvc?

I want to validate my form using jquery but it doesn't have an ID property as of now how to add it to the form in asp.net mvc? I am using this... <% using (Html.BeginForm()) {%> and my jquery..

Android: textview hyperlink

I know that if you put a link in a textview it will work but if I want to display for example: google stackoverflow and not the whole link(just the tag) How do i make those links clickable?..

How can I easily switch between PHP versions on Mac OSX?

I would like to test my application on PHP 5.3 up to PHP 7.0. Where and how can I install the versions and how can I switch them by running a small script?..

Why does Eclipse complain about @Override on interface methods?

I have an existing project that uses @Override on methods that override interface methods, rather than superclass methods. I cannot alter this in code, but I would like Eclpse to stop complaining abou..

Find package name for Android apps to use Intent to launch Market app from web

I'm creating a mobile website that will include a page from which people can download relevant apps that we recommend. I've found instructions for creating the links to launch the Market but this assu..

How do I use T-SQL's Case/When?

I have a huge query which uses case/when often. Now I have this SQL here, which does not work. (select case when xyz.something = 1 then 'SOMETEXT' else (select case when xyz.somethingel..

How to initialize List<String> object in Java?

I can not initialize a List as in the following code: List<String> supplierNames = new List<String>(); supplierNames.add("sup1"); supplierNames.add("sup2"); supplierNames.add("sup3"); Sys..

Setting the User-Agent header for a WebClient request

What is the proper way of setting the User-Agent header for a WebClient request for Windows Phone 7? I found 2 options, but not sure which one is the correct one. Considering a WebClient object: WebC..

Tab separated values in awk

How do I select the first column from the TAB separated string? # echo "LOAD_SETTLED LOAD_INIT 2011-01-13 03:50:01" | awk -F'\t' '{print $1}' The above will return the entire line and not ..

Seeding the random number generator in Javascript

Is it possible to seed the random number generator (Math.random) in JavaScript?..

SQL Server: Filter output of sp_who2

Under SQL Server, is there an easy way to filter the output of sp_who2? Say I wanted to just show rows for a certain database, for example...

How to check if X server is running?

Is there any way to find out if the current session user is running an Xserver (under Linux) ? I'v started off with things like: ps -e | grep X but this doesn't work always and one more thing I ..

How do I find out my root MySQL password?

I just installed MySQL on Ubuntu and the root user can't log in :) How can I recover or find out my password? Using blank for password does not work...

Can I use DIV class and ID together in CSS?

Can I use DIV Class and ID together in CSS? For example: <div class="x" id="y"> -- </div> ..

Where's my invalid character (ORA-00911)

I'm trying to insert CLOBs into a database (see related question). I can't quite figure out what's wrong. I have a list of about 85 clobs I want to insert into a table. Even when inserting only the fi..

Regex credit card number tests

I'm testing one application where Regex pattern match credit card then such numbers should be highlighted. I'm using site http://regexpal.com/ to create test credit credit card numbers for my testing...

How to get current available GPUs in tensorflow?

I have a plan to use distributed TensorFlow, and I saw TensorFlow can use GPUs for training and testing. In a cluster environment, each machine could have 0 or 1 or more GPUs, and I want to run my Ten..

Heroku "psql: FATAL: remaining connection slots are reserved for non-replication superuser connections"

I'm developing an app on Heroku with a Postgresql backend. Periodically, I get this error message when trying to access the database, both from the CLI and from loading a page on the server: psql: FA..

Cannot read property 'addEventListener' of null

I have to use vanilla JavaScript for a project. I have a few functions, one of which is a button that opens a menu. It works on pages where the target id exists, but causes an error on pages where t..

Remove leading zeros from a number in Javascript

Possible Duplicate: Truncate leading zeros of a string in Javascript What is the simplest and cross-browser compatible way to remove leading zeros from a number in Javascript ? e.g. If I h..

In Go's http package, how do I get the query string on a POST request?

I'm using the httppackage from Go to deal with POST request. How can I access and parse the content of the query string from the Requestobject ? I can't find the answer from the official documentation..

LINQ to read XML

I got this XML file: <root> <level1 name="A"> <level2 name="A1" /> <level2 name="A2" /> </level1> <level1 name="B"> <level2 ..

How to replace blank (null ) values with 0 for all records?

MS Access: How to replace blank (null ) values with 0 for all records? I guess it has to be done using SQL. I can use Find and Replace to replace 0 with blank, but not the other way around (won't "fi..

Convert Uppercase Letter to Lowercase and First Uppercase in Sentence using CSS

How to convert UPPERCASE letter to lowercase and first letter Uppercase for each sentences like below only by using CSS? From: THIS IS AN EXAMPLE SENTENCE. To: This is an example sentence. Update:..

Javascript reduce on array of objects

Say I want to sum a.x for each element in arr. arr = [{x:1},{x:2},{x:4}] arr.reduce(function(a,b){return a.x + b.x}) >> NaN I have cause to believe that a.x is undefined at some point. The f..

How to convert a multipart file to File?

Can any one tell me what is a the best way to convert a multipart file (org.springframework.web.multipart.MultipartFile) to File (java.io.File) ? In my spring mvc web project i'm getting uploaded fi..

How to change Rails 3 server default port in develoment?

On my development machine, I use port 10524. So I start my server this way : rails s -p 10524 Is there a way to change the default port to 10524 so I wouldn't have to append the port each time I st..

How to get < span > value?

There are a piece of code,but can not use <id> tag. So,how do I get to the <span> 1 2 3 4? <div id="test"> <span>1</span> <span>2</span> <spa..

SQL JOIN and different types of JOINs

What is a SQL JOIN and what are different types?..

Can't perform a React state update on an unmounted component

Problem I am writing an application in React and was unable to avoid a super common pitfall, which is calling setState(...) after componentWillUnmount(...). I looked very carefully at my code and tr..

linux find regex

I'm having trouble using the regex of the find command. Probably something I don't understand about escaping on the command line. Why are these not the same? find -regex '.*[1234567890]' find -regex..

Gradle sync failed: failed to find Build Tools revision 24.0.0 rc1

As of today I've been running into an error setting up new projects in Android Studio. Right after creating a blank project the log mentions "Gradle sync failed: failed to find Build Tools revision 2..

error: Unable to find vcvarsall.bat

I tried to install the Python package dulwich: pip install dulwich But I get a cryptic error message: error: Unable to find vcvarsall.bat The same happens if I try installing the package manua..

Getting the object's property name

I was wondering if there was any way in JavaScript to loop through an object like so. for(var i in myObject) { // ... } But get the name of each property like this. for(var i in myObject) { ..

How do you set the startup page for debugging in an ASP.NET MVC application?

How do you start debugging the application at the application root? For example: http://localhost:49742/ I'm always getting a page which doesn't exist, such as: http://localhost:49742/Views/Home/Abou..

Set default option in mat-select

I have a simple select option form field in my Angular material project: component.html <mat-form-field> <mat-select [(value)]="modeSelect" placeholder="Mode"> <mat-option..

MySQL the right syntax to use near '' at line 1 error

hello i have a run a query using php it give error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 ..

How do I create an average from a Ruby array?

How would get find an average from an array? If I have the array: [0,4,8,2,5,0,2,6] Averaging would give me 3.375...

Among $_REQUEST, $_GET and $_POST which one is the fastest?

Which of these code will be faster? $temp = $_REQUEST['s']; or if (isset($_GET['s'])) { $temp = $_GET['s']; } else { $temp = $_POST['s']; } ..

How to check if a stored procedure exists before creating it

I have a SQL script that has to be run every time a client executes the "database management" functionality. The script includes creating stored procedures on the client database. Some of these clien..

javascript: optional first argument in function

I have a typical javascript function with some parameters my_function = function(content, options) { action } if I call the function as such : my_function (options) the argument "options" is pas..

How to efficiently use try...catch blocks in PHP

I have been using try..catch blocks in my PHP code, but I'm not sure if I've been using them correctly. For example, some of my code looks like: try { $tableAresults = $dbHandler->doSometh..

Java Object Null Check for method

I need to create a null check in this formula for the books[i] and I am not entirely sure how to go about this as I am not greatly familiar with null checks and very new at programming. Any and all he..

JDK was not found on the computer for NetBeans 6.5

I got the following message when I open the NetBeans. I have got the JDK installed, and set the bin directory in the environment. What I could do next to avoid this problem? Btw, I am using Windows 7 ..

Correct way to try/except using Python requests module?

try: r = requests.get(url, params={'s': thing}) except requests.ConnectionError, e: print e #should I also sys.exit(1) after this? Is this correct? Is there a better way to structure this? W..

How to make a dropdown readonly using jquery?

I am using the following statement to make it readonly but it is not working. $('#cf_1268591').attr("readonly", "readonly"); I don't want make it disabled, I want to make it readonly...

Embed Google Map code in HTML with marker

I have several places with their latitude and longitude. I want to display them in google map. Thats ok, what i can't is to display the marker at the specific lat,long position. e.g. if i've the foll..

Init function in javascript and how it works

I often see the following code: (function () { // init part })(); but I never could get my head around how it works. I find the last brackets especially confusing. Could someone explain how it wo..

How do I suspend painting for a control and its children?

I have a control which I have to make large modifications to. I'd like to completely prevent it from redrawing while I do that - SuspendLayout and ResumeLayout aren't enough. How do I suspend painti..

How can I create an object and add attributes to it?

I want to create a dynamic object (inside another object) in Python and then add attributes to it. I tried: obj = someobject obj.a = object() setattr(obj.a, 'somefield', 'somevalue') but this didn..

How to access PHP session variables from jQuery function in a .js file?

How to access PHP session variables from jQuery function in a .js file? In this code, I want to get "value" from a session variable $(function() { $("#progressbar").progressbar({ value: 37 ..

Insert and set value with max()+1 problems

I am trying to insert a new row and set the customer_id with max()+1. The reason for this is the table already has a auto_increatment on another column named id and the table will have multiple rows w..

CSS Inset Borders

I need to create a solid color inset border. This is the bit of CSS I'm using: border: 10px inset rgba(51,153,0,0.65); Unfortunately that creates a 3D ridged border (ignore the squares and dark descr..

Finding three elements in an array whose sum is closest to a given number

Given an array of integers, A1, A2, ..., An, including negatives and positives, and another integer S. Now we need to find three different integers in the array, whose sum is closest to the given inte..

How do I turn off Unicode in a VC++ project?

I have a VC++ project in Visual Studio 2008. It is defining the symbols for unicode on the compiler command line (/D "_UNICODE" /D "UNICODE"), even though I do not have this symbol turned on in the..

How do you add an action to a button programmatically in xcode

I know how to add an IBAction to a button by dragging from the interface builder, but I want to add the action programmatically to save time and to avoid switching back and forth constantly. The solut..

XMLHttpRequest status 0 (responseText is empty)

Cannot get data with XMLHttpRequest (status 0 and responseText is empty): xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET","http://www.w3schools.com/XML/cd_catalog.xml", true); xmlhttp.onreadystatec..

Change the URL in the browser without loading the new page using JavaScript

How would I have a JavaScript action that may have some effects on the current page but would also change the URL in the browser so if the user hits reload or bookmark, then the new URL is used? It..

Setting Curl's Timeout in PHP

I'm running a curl request on an eXist database through php. The dataset is very large, and as a result, the database consistently takes a long amount of time to return an XML response. To fix that, w..

"Use the new keyword if hiding was intended" warning

I have a warning at the bottom of my screen: Warning 1 'WindowsFormsApplication2.EventControlDataSet.Events' hides inherited member 'System.ComponentModel.MarshalByValueComponent.Events'...

ie8 var w= window.open() - "Message: Invalid argument."

I have a site that has an IE8-only problem: The code is: var w = window.open(urlstring, wname, wfeatures, 'false'); The error is: Message: Invalid argument. Line: 419 Char: 5 Code: 0 ..

Best practice for Django project working directory structure

I know there is actually no single right way. However I've found that it's hard to create a directory structure that works well and remain clean for every developer and administrator. There is some st..

Get index of array element faster than O(n)

Given I have a HUGE array, and a value from it. I want to get index of the value in array. Is there any other way, rather then call Array#index to get it? The problem comes from the need of keeping re..

How to implement infinity in Java?

Does Java have anything to represent infinity for every numerical data type? How is it implemented such that I can do mathematical operations with it? E.g. int myInf = infinity; //However it is done..

Why would $_FILES be empty when uploading files to PHP?

I have WampServer 2 installed on my Windows 7 computer. I'm using Apache 2.2.11 and PHP 5.2.11. When I attempt to upload any file from a form, it seems to upload, but in PHP, the $_FILES array is empt..

Output PowerShell variables to a text file

I'm new to PowerShell and have a script which loops through Active Directory searching for certain computers. I get several variables and then run functions to check things like WMI and registry setti..

How do I initialize a TypeScript Object with a JSON-Object?

I receive a JSON object from an AJAX call to a REST server. This object has property names that match my TypeScript class (this is a follow-on to this question). What is the best way to initialize it..

Find files and tar them (with spaces)

Alright, so simple problem here. I'm working on a simple back up code. It works fine except if the files have spaces in them. This is how I'm finding files and adding them to a tar archive: find . ..

Differences between contentType and dataType in jQuery ajax function

I have the following Jquery callback function and I have a litle doubt about it (I don't know very well Jquery): $("form.readXmlForm").submit(function() { // Riferimento all'elemento form che ha ..

JQUERY ajax passing value from MVC View to Controller

What I want is to pass the value of txtComments from View (using jquery/ajax) to Controller. The problem is the ajax/jquery doesn't accept script tags as string. Meaning, when I input any script/htm..

How to install Boost on Ubuntu

I'm on Ubuntu, and I want to install Boost. I tried with sudo apt-get install boost But there was no such package. What is the best way to install Boost on Ubuntu?..

Adjust UILabel height to text

I have some labels which I want to adjust their height to the text, this is the code I wrote for this now func heightForView(text:String, font:UIFont, width:CGFloat) -> CGFloat{ let label:UILa..

How to add browse file button to Windows Form using C#

I want to select a file on the local hard disk when I click a "Browse" button. I don't have any idea how to use the OpenFileDialog control. Can anyone help me?..

The specified DSN contains an architecture mismatch between the Driver and Application. JAVA

I'm trying to connect to a database made by MS Access using Java, but I cannot seem to manage. I am using ODBC and I'm getting this exception: java.sql.SQLException: [Microsoft][ODBC Driver Manager] ..

cout is not a member of std

I'm practicing using mulitple files and header files etc. So I have this project which takes two numbers and then adds them. Pretty simple. Here are my files: main.cpp #include <iostream> #in..

How do I read a file line by line in VB Script?

I have the following to read a file line by line: wscript.echo "BEGIN" filePath = WScript.Arguments(0) filePath = "C:\Temp\vblist.txt" Set ObjFso = CreateObject("Scripting.FileSystemObject") Set Obj..

How do you specify a debugger program in Code::Blocks 12.11?

I am trying to step through my program and I get the following message from Code::Blocks Selecting target: Debug ERROR: You need to specify a debugger program in the debuggers's settings. (For MinGW..

Can I have an IF block in DOS batch file?

In a DOS batch file we can only have 1 line if statement body? I think I found somewhere that I could use () for an if block just like the {} used in C-like programming languages, but it is not execut..

Best way to incorporate Volley (or other library) into Android Studio project

I've seen different advice on the best way to do this This question covers creating a jar. Elsewhere, I've seen advice to simply copy the volley source into your own project. This section on libraries..

How to position a table at the center of div horizontally & vertically

We can set a image as background image of a <div> like: <style> #test { background-image: url(./images/grad.gif); background-repeat: no-repeat; background-p..

Getting HTTP headers with Node.js

Is there a built in way to get the headers of a specific address via node.js? something like, var headers = getUrlHeaders("http://stackoverflow.com"); would return HTTP/1.1 200 OK. Cache-Control:..

Things possible in IntelliJ that aren't possible in Eclipse?

I have heard from people who have switched either way and who swear by the one or the other. Being a huge Eclipse fan but having not had the time to try out IntelliJ, I am interested in hearing from ..

Getting "A potentially dangerous Request.Path value was detected from the client (&)"

I've got a legacy code issue that requires that I support random urls as if they were requests for the home page. Some of the URLs have characters in them that generate the error "A potentially danger..

Vim 80 column layout concerns

The way I do 80-column indication in Vim seems incorrect:set columns=80. At times I also set textwidth, but I want to be able to see and anticipate line overflow with the set columns alternative. Th..

relative path to CSS file

I have a css folder at the root of my Java Web Application. My import statement looks like this: <link rel="stylesheet" type="text/css" href="/css/styles.css"/> The style is not being applied..

How to use the priority queue STL for objects?

class Person { public: int age; }; I want to store objects of the class Person in a priority queue. priority_queue< Person, vector<Person>, ??? > I think I need to define a class ..

R : how to simply repeat a command?

I'm trying to repeat this simple command 10,000 times (via a simple and easy solution): Tandem <- sample(OUT, size = 815, replace = TRUE, prob = NULL); mean(Tandem) Any advice would be greatly a..

Actionbar notification count icon (badge) like Google has

Is there a android standard badge or method to show action bar notification icon with a count like on Google examples? If not, then what is the best way to make it? I'm new to android, please help...

Generating sql insert into for Oracle

The only thing I don't have an automated tool for when working with Oracle is a program that can create INSERT INTO scripts. I don't desperately need it so I'm not going to spend money on it. I'm ju..

Preprocessing in scikit learn - single sample - Depreciation warning

On a fresh installation of Anaconda under Ubuntu... I am preprocessing my data in various ways prior to a classification task using Scikit-Learn. from sklearn import preprocessing scaler = preproces..

Port 80 is being used by SYSTEM (PID 4), what is that?

I am trying to use port 80 for my application server, but when I perform netstat -aon I get: TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4 When I look up the process in task manager, it shows PID 4 is SYSTEM..

The type or namespace name 'DbContext' could not be found

I am VERY new to ASP.NET MVC (3) and am having a hard time resolving a build error in Visual Studio: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an..

Calling startActivity() from outside of an Activity context

I have implemented a ListView in my Android application. I bind to this ListView using a custom subclass of the ArrayAdapter class. Inside the overridden ArrayAdapter.getView(...) method, I assign a..

C linked list inserting node at the end

I'm having some trouble with my insertion method for a linked list in C. It seems to only add at the beginning of the list. Any other insertion I make fail. And this CodeBlocks debugger is so hard to ..

How do you find the row count for all your tables in Postgres

I'm looking for a way to find the row count for all my tables in Postgres. I know I can do this one table at a time with: SELECT count(*) FROM table_name; but I'd like to see the row count for all..

HTML/Javascript change div content

I have simple HTML code with some javascript, it looks like: _x000D_ _x000D_ <html>_x000D_ _x000D_ <head>_x000D_ <script type="text/javascript">_x000D_ function changeDivConte..

JavaScript unit test tools for TDD

I've looked into and considered many JavaScript unit tests and testing tools, but have been unable to find a suitable option to remain fully TDD compliant. So, is there a JavaScript unit test tool tha..

How do I explicitly specify a Model's table-name mapping in Rails?

I have a Model class called Countries and I want it to map to a DB table called 'cc'. How is that done in Rails?..

What does character set and collation mean exactly?

I can read the MySQL documentation and it's pretty clear. But, how does one decide which character set to use? On what data does collation have an effect? I'm asking for an explanation of the two and..

how to convert String into Date time format in JAVA?

How to convert a string in the form of 03/24/2013 21:54 into a Date object in java?..

How to get name of calling function/method in PHP?

I am aware of function debug_backtrace, but I am looking for some ready to use implementation of function like GetCallingMethodName()? It would be perfect if it gave method's class too (if it is indee..

Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable

When trying to reference a managed bean in EL like so #{bean.entity.property}, sometimes a javax.el.PropertyNotFoundException: Target Unreachable exception is being thrown, usually when a bean propert..

Execute action when back bar button of UINavigationController is pressed

I need to execute an action (emptying an array), when the back button of a UINavigationController is pressed, while the button still causes the previous ViewController on the stack to appear. How coul..

How to install Android Studio on Ubuntu?

I have to install Android Studio on Ubuntu and I have used this link to download Android Studio. Is there any easy way to install Studio on Ubuntu?..

jQuery Find and List all LI elements within a UL within a specific DIV

I have 3 Columns of ULs each a Dynamic UL container that can have anywhere from 0-9 LI containers (eventually more). All my LI elements have an attribute "rel" which I am trying to ultimately find tha..

Comparing strings, c++

I have a question: Let's say there are two std::strings and I want to compare them, there is the option of using the compare() function of the string class but I also noticed that it is possible usin..

How is a CRC32 checksum calculated?

Maybe I'm just not seeing it, but CRC32 seems either needlessly complicated, or insufficiently explained anywhere I could find on the web. I understand that it is the remainder from a non-carry-based..

Windows Scipy Install: No Lapack/Blas Resources Found

I am trying to install python and a series of packages onto a 64bit windows 7 desktop. I have installed Python 3.4, have Microsoft Visual Studio C++ installed, and have successfully installed numpy, p..

How to confirm RedHat Enterprise Linux version?

I am a bit confused by the fact that although I installed RHEL 5.1 from DVD (RedHat/5.1.x86_64), when I issue command: cat /etc/redhat-release I got: Red Hat Enterprise Linux Server release 5.5 (T..

Visual Studio 2015 doesn't have cl.exe

I downloaded Visual C++ and Visual Studio, but I cannot find cl.exe to compile my C++ file. The path to the install is `C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin. Where can I find t..

VBA error 1004 - select method of range class failed

First time poster, so if there is any formatting, or guidelines I failed to adhere to, please let me know so that I can fix it. So I am basically asking the user for the file directory of the excel ..

Test if string is a number in Ruby on Rails

I have the following in my application controller: def is_number?(object) true if Float(object) rescue false end and the following condition in my controller: if mystring.is_number? end The c..

Change connection string & reload app.config at run time

When I change the connection string using this code, it does not reload app.config at runtime. I expected it to reload similarly to how we reload app.config. config.ConnectionStrings.ConnectionString..

Reading values from DataTable

I have a DataTable populated with samo data/values and I want to read data from DataTable and pass it to a string variable. I have this code: DataTable dr_art_line_2 = ds.Tables["QuantityInIssueUni..

adb command for getting ip address assigned by operator

I need to fetch the IPaddress assigned by the operator after a successful 3G or LTE data call. $adb shell netcfg >> doesnt have the assigned IP address. I tried adb shell dumpsys and grep ip ..

Inserting Image Into BLOB Oracle 10g

I am trying to insert an image into an BLOB field in a signatures which i will then select from the table and render on a report. I cannot seem to figure how to get the image into the table. I did an ..

How do I add my bot to a channel?

I'm using my bot to tell important news, but when I using sendMessage to the channel I'm receiving the following error: {"ok":false,"error_code":403,"description":"Error: Forbidden: bot is not a part..

Fastest way to check if a string matches a regexp in ruby?

What is the fastest way to check if a string matches a regular expression in Ruby? My problem is that I have to "egrep" through a huge list of strings to find which are the ones that match a regexp t..

onNewIntent() lifecycle and registered listeners

I'm using a singleTop Activity to receive intents from a search-dialog via onNewIntent(). What I noticed is that onPause() is called before onNewIntent(), and then afterwards it calls onResume(). Vi..

PHP code to convert a MySQL query to CSV

What is the most efficient way to convert a MySQL query to CSV in PHP please? It would be best to avoid temp files as this reduces portability (dir paths and setting file-system permissions required)..

mysql data directory location

I installed mysql in Mac after downloding its dmg file version 64 bit. While trying to create a database it gave me error 1006 -- can't create database. After browsing a number of website, it seems du..

What is difference between mutable and immutable String in java

As per my knowledge, a mutable string can be changed, and an immutable string cannot be changed. Here I want to change the value of String like this, String str="Good"; str=str+" Morning"; and ot..

Switch role after connecting to database

Is it possible to change the postgresql role a user is using when interacting with postgres after the initial connection? The database(s) will be used in a web application and I'd like to employ data..

How to read a CSV file from a URL with Python?

when I do curl to a API call link http://example.com/passkey=wedsmdjsjmdd curl 'http://example.com/passkey=wedsmdjsjmdd' I get the employee output data on a csv file format, like: "Steve","421","0..

Check for internet connection with Swift

When I try to check for an internet connection on my iPhone I get a bunch of errors. Can anyone help me to fix this? The code: import Foundation import SystemConfiguration public class Reachability..

Java: How to read a text file

I want to read a text file containing space separated values. Values are integers. How can I read it and put it in an array list? Here is an example of contents of the text file: 1 62 4 55 5 6 77 ..

Is it possible to use 'else' in a list comprehension?

Here is the code I was trying to turn into a list comprehension: table = '' for index in xrange(256): if index in ords_to_keep: table += chr(index) else: table += replace_with..

Protecting cells in Excel but allow these to be modified by VBA script

I am using Excel where certain fields are allowed for user input and other cells are to be protected. I have used Tools Protect sheet, however after doing this I am not able to change the values in th..

How do I change the font-size of an <option> element within <select>?

I have built this fiddle as an example of what I am doing. What I am trying to do works fine in Firefox. With the font-size being 14px when you open up the select options. However looking at it in Goo..

Strings and character with printf

I was confused with usage of %c and %s in the following C program #include <stdio.h> void main() { char name[]="siva"; printf("%s\n",name); printf("%c\n..

How to get the ASCII value in JavaScript for the characters

Possible Duplicate: Convert character to ASCII code in Javascript my requirement is to get the ASCII value of the alphabet letters... Can anyone suggest how to do this in JavaScript?..

Shell command to tar directory excluding certain files/folders

Is there a simple shell command/script that supports excluding certain files/folders from being archived? I have a directory that need to be archived with a sub directory that has a number of very la..

How to change the author and committer name and e-mail of multiple commits in Git?

I was writing a simple script in the school computer, and committing the changes to Git (in a repo that was in my pendrive, cloned from my computer at home). After several commits I realized I was com..

How can I tell if a DOM element is visible in the current viewport?

Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the viewport)? (The question refers to Firefox.)..

Insert the same fixed value into multiple rows

I've got a table with a column, lets call it table_column that is currently null for all rows of the table. I'd like to insert the value "test" into that column for all rows. Can someone give me the..

An existing connection was forcibly closed by the remote host - WCF

I have a WCF web service that is working fine. However there is one particular call that is failing - but only failing for certain users. The call is pretty simple - it is a call to get a list of Pe..

DB2 Date format

I just want to format current date into yyyymmdd in DB2. I see the date formats available, but how can I use them? http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.d..

Remove commas from the string using JavaScript

I want to remove commas from the string and calculate those amount using JavaScript. For example, I have those two values: 100,000.00 500,000.00 Now I want to remove commas from those string a..

Arrays.fill with multidimensional array in Java

How can I fill a multidimensional array in Java without using a loop? I've tried: double[][] arr = new double[20][4]; Arrays.fill(arr, 0); This results in java.lang.ArrayStoreException: java.lang.D..

How can I display a list view in an Android Alert Dialog?

In an Android application, I want to display a custom list view in an AlertDialog. How can I do this?..

Using jquery to delete all elements with a given id

I have a form with several spans with id="myid". I'd like to be able to remove all elements with this id from the DOM, and I think jQuery is the best way to do it. I figured out how to use the $.remov..

Rails 4: before_filter vs. before_action

In rails >4.0.0 generators creates CRUD operations with before_action not before_filter. It seems to do the same thing. So what's the difference between these two? ..

How to write ternary operator condition in jQuery?

In this fiddle http://jsfiddle.net/mjmitche/6nar4/3/, if you drag, for example, the little blue box into the yellow box, then the big black box will turn pink. All of the 4 boxes along the left can be..

How can I URL encode a string in Excel VBA?

Is there a built-in way to URL encode a string in Excel VBA or do I need to hand roll this functionality? ..

Equivalent to AssemblyInfo in dotnet core/csproj

Since dotnet core moved back to the .csproj format, there is a new autogenerated MyProject.AssemblyInfo.cs which contains, among others: [assembly: AssemblyCompany("MyProject")] [assembly: A..

How do I resolve a path relative to an ASP.NET MVC 4 application root?

How do I resolve paths relative to an ASP.NET MVC 4 application's root directory? That is, I want to open files belonging to the application from controller actions, referenced like ~/Data/data.html. ..

Ansible - Save registered variable to file

How would I save a registered Variable to a file? I took this from the tutorial: - hosts: web_servers tasks: - shell: /usr/bin/foo register: foo_result ignore_errors: True ..

Delete branches in Bitbucket

I've created lots of branches in one of our repositories. Those branches are for testing before it will be pulled to the master. Now I see lots of them on the list and they we will never use it again...

How to find the sum of an array of numbers

Given an array [1, 2, 3, 4], how can I find the sum of its elements? (In this case, the sum would be 10.) I thought $.each might be useful, but I'm not sure how to implement it...

I just discovered why all ASP.Net websites are slow, and I am trying to work out what to do about it

I just discovered that every request in an ASP.Net web application gets a Session lock at the beginning of a request, and then releases it at the end of the request! In case the implications of this ..

What's the difference between getPath(), getAbsolutePath(), and getCanonicalPath() in Java?

What's the difference between getPath(), getAbsolutePath(), and getCanonicalPath() in Java? And when do I use each one?..

Sound alarm when code finishes

I am in a situation where my code takes extremely long to run and I don't want to be staring at it all the time but want to know when it is done. How can I make the (Python) code sort of sound an "al..

React.js, wait for setState to finish before triggering a function?

Here's my situation: on this.handleFormSubmit() I am executing this.setState() inside this.handleFormSubmit(), I am calling this.findRoutes(); - which depends on the successful completion of this.se..

Opposite of append in jquery

I use .append to add to a div $(this).append('<ul><li>test</li></ul>'); how can I search for a <ul> and remove it if it exists in the children of $(this)?..

Is it possible to assign numeric value to an enum in Java?

Is anything like this possible in Java? Can one assign custom numeric values to enum elements in Java? public enum EXIT_CODE { A=104, B=203; } ..

How to make div occupy remaining height?

I have this problem, I have two divs: <div style="width:100%; height:50px;" id="div1"></div> <div style="width:100%;" id="div2"></div> How do I make div2 occupy remaining he..

How can I restart a Java application?

How can I restart a Java AWT application? I have a button to which I have attached an event handler. What code should I use to restart the application? I want to do the same thing that Application.Re..

How to get selected value from Dropdown list in JavaScript

How can you get the selected value from drop down list using JavaScript? I have tried the following but it does not work. var sel = document.getElementById('select1'); var sv = sel.options[sel.select..

WPF loading spinner

The goal is to display the information that the application is working. So I'm looking for an intelligent implementation sample of a loading spinner using WPF / MVVM...

Use of document.getElementById in JavaScript

Can someone explain what the document.getElementById("demo") line does in the example below? I understand getElementById gets the id of demo but the id is <p id="demo"></p> What exactly i..

Get record counts for all tables in MySQL database

Is there a way to get the count of rows in all tables in a MySQL database without running a SELECT count() on each table?..

Detecting value change of input[type=text] in jQuery

I want to execute a function every time the value of a specific input box changes. It almost works with $('input').keyup(function), but nothing happens when pasting text into the box, for example. $in..

Read a Csv file with powershell and capture corresponding data

Using PowerShell I would like to capture user input, compare the input to data in a comma delimited CSV file and write corresponding data to a variable. Example: A user is prompted for a “Store..

How to get the clicked link's href with jquery?

Does anyone know how can I get the clicked link's href with jquery? I have the link as following: <a href="ID=1" class="testClick">Test1.</a> <br /> <a href="ID=2" ..

What are invalid characters in XML

I am working with some XML that holds strings like: <node>This is a string</node> Some of the strings that I am passing to the nodes will have characters like &, #, $, etc.: <no..

Using PropertyInfo.GetValue()

I have a class that creates a static array of all properties, using a static constructor. I also have a function -- GetNamesAndTypes() -- that lists the name & type of each property in that array..

Print string and variable contents on the same line in R

Is there a way to print text and variable contents on the same line? For example, wd <- getwd() print("Current working dir: ", wd) I couldn't find anything about the syntax that would allow me t..

How to uninstall a windows service and delete its files without rebooting

My current project involves deploying an upgraded .exe file that runs as a Windows Service. In order to overwrite the existing .exe with the new version, I currently need to: Stop the service Unins..

Apache: client denied by server configuration

I am getting [Tue Apr 24 12:12:55 2012] [error] [client 127.0.0.1] client denied by server configuration: /labs/Projects/Nebula/bin/ My directory structure looks like (I am using Symfony 2, sho..

What is the difference between an annotated and unannotated tag?

If I want to tag the current commit. I know both of the following command lines work: git tag <tagname> and git tag -a <tagname> -m '<message>' What is the difference between t..

Copy / Put text on the clipboard with FireFox, Safari and Chrome

In Internet Explorer I can use the clipboardData object to access the clipboard. How can I do that in FireFox, Safari and/or Chrome?..

Write lines of text to a file in R

In the R scripting language, how do I write lines of text, e.g. the following two lines Hello World to a file named "output.txt"?..

Ruby 'require' error: cannot load such file

I've one file, main.rb with the following content: require "tokenizer.rb" The tokenizer.rb file is in the same directory and its content is: class Tokenizer def self.tokenize(string) r..