Examples On Programing Languages

Converting NSString to NSDate (and back again)

How would I convert an NSString like "01/02/10" (meaning 1st February 2010) into an NSDate? And how could I turn the NSDate back into a string?...

ASP.net vs PHP (What to choose)

I have been assigned a task to develop a new web application. Its a kind of social web applications, for the sake of understanding you can say its similar to facebook. Now before start developing such huge application i have few questions to ask: F...

R dplyr: Drop multiple columns

I have a dataframe and list of columns in that dataframe that I'd like to drop. Let's use the iris dataset as an example. I'd like to drop Sepal.Length and Sepal.Width and use only the remaining columns. How do I do this using select or select_ from ...

Setting state on componentDidMount()

I know that it is an anti-pattern to set state on componentDidMount and a state should be set on componentWillMount but suppose I want to set the length of the number of li tags as a state. In that case, I can't set the state on componentWillMount si...

Android: How to rotate a bitmap on a center point

I've been looking for over a day for a solution to this problem but nothing helps, even the answers here. Documentation doesn't explain anything too. I am simply trying to get a rotation in the direction of another object. The problem is that the bi...

Importing text file into excel sheet

I'm writing a VBA code which supposed to delete the data on a selected excel sheet, open a dialog box for text file selection, and then import the data from that text file to the same exact sheet I've deleted the data from. So far I can only open the...

Specifying row names when reading in a file

I have a .txt file that contains row names. However, R set the row names as the first column....

Compare two date formats in javascript/jquery

I have the following : var fit_start_time = $("#fit_start_time").val(); //2013-09-5 var fit_end_time = $("#fit_end_time").val(); //2013-09-10 if(Date.parse(fit_start_time)>=Date.parse(fit_end_time)){ alert("Please select a different End...

MySQL check if a table exists without throwing an exception

What is the best way to check if a table exists in MySQL (preferably via PDO in PHP) without throwing an exception. I do not feel like parsing the results of "SHOW TABLES LIKE" et cetera. There must be some sort of boolean query?...

How to write character & in android strings.xml

I wrote the following in the strings.xml file: <string name="game_settings_dragNDropMove_checkBox">Move by Drag&Drop</string> I got the following error: The reference to entity "Drop" must end with the ';' delimiter. How can I w...

Ng-model does not update controller value

Probably silly question, but I have my html form with simple input and button: <input type="text" ng-model="searchText" /> <button ng-click="check()">Check!</button> {{ searchText }} Then in the controller (template and controlle...

Angular.js How to change an elements css class on click and to remove all others

i'm trying to make my two elements toggle, so if one element is clicked it will remove all references of my-class and apply it to its self. Any ideas? <span id="1" ng-style="my-class" ng-click="tog=my-class"></span> <span id="2" ng-s...

Set selected option of select box

I want to set a option that was selected previously to be displayed on page load. I tried it with the following code: $("#gate").val('Gateway 2'); with <select id="gate"> <option value='null'>- choose -</option> <opti...

Mock MVC - Add Request Parameter to test

I am using spring 3.2 mock mvc to test my controller.My code is @Autowired private Client client; @RequestMapping(value = "/user", method = RequestMethod.GET) public String initUserSearchForm(ModelMap modelMap) { User...

Scale an equation to fit exact page width

I have an equation that is only a tiny bit too wide for one line. I'd really like to avoid having the equation number on the next line. How do you achieve this? Currently I'm using \small, but this is overkill. Please note. I have tried scalebox and...

aspx page to redirect to a new page

What is the code required to redirect the browser to a new page with an ASPX page? I have tried this on my page default.aspx : <% Response.Redirect("new.aspx", true); %> or <%@ Response.Redirect("new.aspx", true); %> And these resu...

PHPUnit assert that an exception was thrown?

Does anyone know whether there is an assert or something like that which can test whether an exception was thrown in the code being tested?...

How to create PDF files in Python

I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images. Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> P...

How to use delimiter for csv in python

I'm having trouble with figuring out how to use the delimiter for csv.writer in Python. I have a csv file in which the strings separated by commas are in single cell and I need to have each word in each individual cell. For ex: 100 , 2559 ,,Mai...

jquery: $(window).scrollTop() but no $(window).scrollBottom()

I want to place an element to the bottom of the page whenever the user scrolls the page. It's like "fixed position" but I can't use "position: fixed" css as many of my clients' browser can't support that. I noticed jquery can get current viewport's ...

What is a thread exit code?

What exactly is a thread exit code in the Output window while debugging? What information it gives me? Is it somehow useful or just an internal stuff which should not bother me? The thread 0x552c has exited with code 259 (0x103). The thread 0x4440 h...

How to use "/" (directory separator) in both Linux and Windows in Python?

I have written a code in python which uses / to make a particular file in a folder, if I want to use the code in windows it will not work, is there a way by which I can use the code in Windows and Linux. In python I am using this code: pathfile=os....

What is the difference between git pull and git fetch + git rebase?

Another question says that git pull is like a git fetch + git merge. But what is the difference between git pull and git fetch + git rebase?...

Model summary in pytorch

Is there any way, I can print the summary of a model in PyTorch like model.summary() method does in Keras as follows? Model Summary: ____________________________________________________________________________________________________ Layer (type) ...

what does "error : a nonstatic member reference must be relative to a specific object" mean?

int CPMSifDlg::EncodeAndSend(char *firstName, char *lastName, char *roomNumber, char *userId, char *userFirstName, char *userLastName) { ... return 1; } extern "C" { __declspec(dllexport) int start(char *firstName, char *lastName, char ...

What are all the different ways to create an object in Java?

Had a conversation with a coworker the other day about this. There's the obvious using a constructor, but what are the other ways there?...

Printing PDFs from Windows Command Line

I'm trying to print all pdfs in current dir. When I call this bash script in cmd (singlepdf.sh): '"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"' /t Gemeinde_348_BioID_842_alt.pdf everything's working fine. When calling multiplepdfs...

Removing MySQL 5.7 Completely

I am trying to uninstall mysql from my ubuntu 12.04 completely. But not able to. I tried a lot of commands. But nothing is working. Can anyone help out here! sudo apt-get remove mysql-server mysql-client mysql-common sudo apt-get autoremove I am ...

How does one target IE7 and IE8 with valid CSS?

I want to target IE7 and IE8 with W3C-compliant CSS. Sometimes fixing CSS for one version does not fix for the other. How can I achieve this?...

how to generate a unique token which expires after 24 hours?

I have a WCF Webservice which checks if the user is valid. If the user is valid I want to generate a token which expires after 24 hours. public bool authenticateUserManual(string userName, string password,string language,string token) { if (Me...

How to store custom objects in NSUserDefaults

Alright, so I've been doing some poking around, and I realize my problem, but I don't know how to fix it. I have made a custom class to hold some data. I make objects for this class, and I need to them to last between sessions. Before I was puttin...

How to add Action bar options menu in Android Fragments

I am trying to have a options menu in Android Fragments. ActionBar options menu are not displaying in my Fragments. Here is my code and I have both onCreateOptionsMenu() and onOptionSelected() function. My code doesn't shows any error. But options m...

Chrome Extension: Make it run every page load

I want to make a chrome extension that executes some scripts after one page is loaded, I am not sure whether I have to implement this logic on the background page or it can be anywhere else, any help here will be greatly appreciated....

Using comma as list separator with AngularJS

I need to create a comma-separated list of items: <li ng-repeat="friend in friends"> <b ng-repeat="email in friend.email">{{email}}{{$last ? '' : ', '}}</b>... </li> According to the AngularJS documentation, no co...

CSS "and" and "or"

I've got quite big trouble, because i need to anathematise from styling some input types. I had something like: .registration_form_right input:not([type="radio") { //Nah. } But i don't want to style checkboxes too. I've tried: .registration_for...

Gradle: Could not determine java version from '11.0.2'

I ran the following comment: ./gradlew app:installDebug only to be met with the log: FAILURE: Build failed with an exception. * What went wrong: Could not determine java version from '11.0.2'. * Try: Run with --stacktrace option to get the sta...

How to remove unused imports in Intellij IDEA on commit?

Is there a way to remove unused imports in Intellij IDEA on commit? It is not very optimal to do it manually, CTRL + ALT + O helps but it's still manual....

Deck of cards JAVA

I have created my deck of cards that deals every card and a suit until there is no card remaining. For my project, I need to split it up into 3 classes which includes a driver class. I first created one class with everything so I knew how to make it ...

Spring Boot without the web server

I have a simple Spring Boot application that gets messages from a JMS queue and saves some data to a log file, but does not need a web server. Is there any way of starting Spring Boot without the web server?...

Convert timedelta to total seconds

I have a time difference import time import datetime time1 = datetime.datetime.fromtimestamp(time.mktime(time.gmtime())) ... time2 = datetime.datetime.fromtimestamp(time.mktime(time.gmtime())) diff = time2 - time1 Now, how do I find the total numbe...

What ports need to be open for TortoiseSVN to authenticate (clear text) and commit?

What ports need to be open for TortoiseSVN to authenticate (basic) in order to commit? I know it is not a good thing, but I believe username and password are in the clear right now. Let me describe as much as I know about set-up, and what seems to b...

Convert np.array of type float64 to type uint8 scaling values

I have a particular np.array data which represents a particular grayscale image. I need to use SimpleBlobDetector() that unfortunately only accepts 8bit images, so I need to convert this image, obviously having a quality-loss. I've already tried: i...

Replacing column values in a pandas DataFrame

I'm trying to replace the values in one column of a dataframe. The column ('female') only contains the values 'female' and 'male'. I have tried the following: w['female']['female']='1' w['female']['male']='0' But receive the exact same copy of ...

Android. Fragment getActivity() sometimes returns null

In developer console error reports sometimes I see reports with NPE issue. I do not understand what is wrong with my code. On emulator and my device application works good without forcecloses, however some users get NullPointerException in fragment ...

Export table data from one SQL Server to another

I have two SQL Servers (both 2005 version). I want to migrate several tables from one to another. I have tried: On source server I have right clicked on the database, selected Tasks/Generate scripts. The problem is that under Table/View options t...

GROUP BY and COUNT in PostgreSQL

The query: SELECT COUNT(*) as count_all, posts.id as post_id FROM posts INNER JOIN votes ON votes.post_id = posts.id GROUP BY posts.id; Returns n records in Postgresql: count_all | post_id -----------+--------- 1 | 6 3 ...

Caching a jquery ajax response in javascript/browser

I would like to enable caching of an ajax response in javascript/browser. From the jquery.ajax docs: By default, requests are always issued, but the browser may serve results out of its cache. To disallow use of the cached results, set cache...

Difference between two dates in years, months, days in JavaScript

I've been searching for 4 hours now, and have not found a solution to get the difference between two dates in years, months, and days in JavaScript, like: 10th of April 2010 was 3 years, x month and y days ago. There are lots of solutions, but they ...

Formatting a number with leading zeros in PHP

I have a variable which contains the value 1234567. I would like it to contain exactly 8 digits, i.e. 01234567. Is there a PHP function for that?...

Function to Calculate a CRC16 Checksum

I'm working on a library to provide simple reliable communication over an RS232 or RS485 connection. Part of this code involves using a CRC16 checksum on the data to detect corruption from line noise. I've created a function to calculate a CRC16 ch...

Check if a key exists inside a json object

amt: "10.00" email: "[email protected]" merchant_id: "sam" mobileNo: "9874563210" orderID: "123456" passkey: "1234" The above is the JSON object I'm dealing with. I want to check if the 'merchant_id' key exists. I tried the below code, but it's not wor...

How do you Programmatically Download a Webpage in Java

I would like to be able to fetch a web page's html and save it to a String, so I can do some processing on it. Also, how could I handle various types of compression. How would I go about doing that using Java?...

ERROR 1064 (42000): You have an error in your SQL syntax; Want to configure a password as root being the user

I have just downloaded WAMP. I want to configure a password for the MySQL root user using MySQL console. No password has been set previously. The following is the input mysql-> use mysql Database changed mysql-> UPDATE user ...

Making a UITableView scroll when text field is selected

After a lot of trial and error, I'm giving up and asking the question. I've seen a lot of people with similar problems but can't get all the answers to work right. I have a UITableView which is composed of custom cells. The cells are made of 5 text ...

How to get the hostname of the docker host from inside a docker container on that host without env vars

What are the ways get the docker host's hostname from inside a container running on that host besides using environment variables? I know I can pass the hostname as an environment variable to the container at container creation time. I'm wondering ho...

Retrieve Button value with jQuery

A simple one, I'm trying to retrieve the value attribute of a button when its been pressed using jQuery, here's what I have: <script type="text/javascript"> $(document).ready(function() { $('.my_button').click(function() { ...

Stretch background image css?

<td class="style1" align='center' height='35'> <div style='overflow: hidden; width: 230px;'> <a class='link' herf='' onclick='topic(<?=$key;?>)'> <span id='name<?=$key;?>'><?=$name;?></span>...

How to get a complete list of ticker symbols from Yahoo Finance?

I've googled endlessly for a method of getting a complete (and daily updated) list of all Yahoo ticker symbols available through http://finance.yahoo.com Yahoo has information for stocks, futures etc for a lot of exchanges worldwide, and I'd like a ...

How do I prevent a form from being resized by the user?

I have a form that needs to be maximized in VB.net. I don't want the user to be able to change its size or move it around. How can I do this?...

C# IPAddress from string

I need to define the IP address in the class System.Net.IPAddress but the method: IPAddress ipaddress = IPAddress.Parse("127.0.0.1"); //127.0.0.1 as an example doesn't work, is there another method? How can I define the IP address?...

How to PUT a json object with an array using curl

I have a series of data to enter into database. The user interface to enter the data isn't good for bulk entry, so I'm trying to formulate a command line equivalent. When I examine the network request of the UI in chrome, I see a PUT request of a j...

How to fix UITableView separator on iOS 7?

UITableView draws with ragged lines on iOS 7: How to fix it? The line between cells should be on the full width of the screen....

Can you force Visual Studio to always run as an Administrator in Windows 8?

In Windows 7, you could go into a programs compatibility settings and check off to always run as an Administrator. Is there a similar option in Windows 8? I've always disabled UAC on my machines, and did the same after my Windows 8 upgrade, or so I...

Hibernate Auto Increment ID

I have a j2ee application using hibernate with annotation. How do I annotate the Id field in my pojo class to set it as auto increment or auto generated. and in adding the bean do I leave that field in my bean null?...

Using IS NULL or IS NOT NULL on join conditions - Theory question

Theory question here: Why does specifying table.field IS NULL or table.field IS NOT NULL not work on a join condition (left or right join for instance) but only in the where condition? Non working Example: -this should return all shipments with an...

Common sources of unterminated string literal

I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a "unterminated string literal." I checked the line and...

Concat scripts in order with Gulp

Say, for example, you are building a project on Backbone or whatever and you need to load scripts in a certain order, e.g. underscore.js needs to be loaded before backbone.js. How do I get it to concat the scripts so that they’re in order? // JS...

How to dynamically create columns in datatable and assign values to it?

I will have to create columns in datatable during runtime and assign values to it. How can i do it in vb.net. Any sample please......

Access nested dictionary items via a list of keys?

I have a complex dictionary structure which I would like to access via a list of keys to address the correct item. dataDict = { "a":{ "r": 1, "s": 2, "t": 3 }, "b":{ "u": 1, "v": { ...

Remote Procedure call failed with sql server 2008 R2

I am working with SQL Server 2008 R2. I am unable to connect to my database remotely. I got the following error. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or w...

force browsers to get latest js and css files in asp.net application

Some browsers cache js and css files, failing to refresh them unless you force them to. What's the easiest way. I just implemented this solution that seems to work. Declare a version variable on your page public string version { get; set; } ...

Why am I getting this error Premature end of file?

I am trying to parse an XML response, but I am failing miserably. I thought initially that the xml was just not being returned in the response, so I crafted up the code below with a direct link to my xml file online. I am able to print the XML to sc...

How does the bitwise complement operator (~ tilde) work?

Why is it that ~2 is equal to -3? How does ~ operator work?...

Is there an alternative to string.Replace that is case-insensitive?

I need to search a string and replace all occurrences of %FirstName% and %PolicyAmount% with a value pulled from a database. The problem is the capitalization of FirstName varies. That prevents me from using the String.Replace() method. I've seen web...

How to check if object has any properties in JavaScript?

Assuming I declare var ad = {}; How can I check whether this object will contain any user-defined properties?...

User Control - Custom Properties

I have developed a User Control in Visual Studio (WinForms C#) and have a question. I need the user of my User Control to be able to change certain string values and I would like them to be able to add the user control to their Form and click on it ...

Find and replace entire mysql database

i would like to do a find and replace inside an entire database not just a table. How can i alter the script below to work? update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]'); Do i just use an a...

ExecuteReader: Connection property has not been initialized

ExecuteReader: Connection property has not been initialized. my coding is protected void Button2_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=Si-6\\SQLSERVER2005;Initial Catalog=rags;Inte...

How do I add an integer value with javascript (jquery) to a value that's returning a string?

I have a simple html block like: <span id="replies">8</span> Using jquery I'm trying to add a 1 to the value (8). var currentValue = $("#replies").text(); var newValue = currentValue + 1; $("replies").text(newValue); What's happenin...

Django - what is the difference between render(), render_to_response() and direct_to_template()?

Whats the difference (in language a python/django noob can understand) in a view between render(), render_to_response() and direct_to_template()? e.g. from Nathan Borror's basic apps examples def comment_edit(request, object_id, template_name='comm...

How do you add an ActionListener onto a JButton in Java

private JButton jBtnDrawCircle = new JButton("Circle"); private JButton jBtnDrawSquare = new JButton("Square"); private JButton jBtnDrawTriangle = new JButton("Triangle"); private JButton jBtnSelection = new JButton("Selection"); How do I add actio...

Nth word in a string variable

In Bash, I want to get the Nth word of a string hold by a variable. For instance: STRING="one two three four" N=3 Result: "three" What Bash command/script could do this?...

How to count the number of set bits in a 32-bit integer?

8 bits representing the number 7 look like this: 00000111 Three bits are set. What are algorithms to determine the number of set bits in a 32-bit integer?...

ByRef argument type mismatch in Excel VBA

I'm working with VBA. I wrote a user define function that takes a string, process it and return a cleaned string. I am not sure what is wrong with it. I am not able to call it and ask it to process my string and return it. I am thinking there are a m...

How to git reset --hard a subdirectory?

UPDATE²: With Git 2.23 (August 2019), there's a new command git restore that does this, see the accepted answer. UPDATE: This will work more intuitively as of Git 1.8.3, see my own answer. Imagine the following use case: I want to get rid ...

Use jQuery to change an HTML tag?

Is this possible? example: $('a.change').click(function(){ //code to change p tag to h5 tag }); <p>Hello!</p> <a id="change">change</a> So clicking the change anchor should cause the <p>Hello!</p> section to ...

How to build PDF file from binary string returned from a web-service using javascript

I am trying to build a PDF file out of a binary stream which I receive as a response from an Ajax request. Via XmlHttpRequest I receive the following data: %PDF-1.4.... ..... ....hole data representing the file .... %% EOF What I tried so far was...

Disabling swap files creation in vim

Is there a way to disable .swp files creation in vim? or at least create them all in one place so I can find and delete them easily. I find them especially annoying when I copy the parent directory while editing at the same time. Of course I know th...

How to check if a string contains text from an array of substrings in JavaScript?

Pretty straight forward. In javascript, I need to check if a string contains any substrings held in an array....

accessing a docker container from another container

i created two docker containers based on two different images. one of db and another for webserver. both containers are running on my mac osx. i can access db container from host machine and same way can access webserver from host machine. howeve...

Brew doctor says: "Warning: /usr/local/include isn't writable."

Brew doctor says: Warning: /usr/local/include isn't writable. This can happen if you "sudo make install" software that isn't managed by Homebrew. If a brew tries to write a header file to this directory, the install will fail during the l...

How to create friendly URL in php?

Normally, the practice or very old way of displaying some profile page is like this: www.domain.com/profile.php?u=12345 where u=12345 is the user id. In recent years, I found some website with very nice urls like: www.domain.com/profile/12345 ...

Convert JSON format to CSV format for MS Excel

I received a JSON file but don't know how to read it. Is there a converter where I can produce a nice CSV file so it can be loaded into MS Excel? I don't understand JSON, so it would be awesome if someone wrote a script or link me to one that would d...

ORA-12505: TNS:listener does not currently know of SID given in connect descriptor (DBD ERROR: OCIServerAttach)

I created a Windows 2003 R2 Virtual Machine running on VirtualBox and I installed Oracle (10201_database_win32). I assigned a static IP on the Virtual Ethernet too. Everything worked great right after installation. I listed(lsnrctl services) the ...

How to send JSON instead of a query string with $.ajax?

Can someone explain in an easy way how to make jQuery send actual JSON instead of a query string? $.ajax({ url : url, dataType : 'json', // I was pretty sure this would do the trick data : data, type : 'POST', comple...

How to copy multiple files in one layer using a Dockerfile?

The following Dockerfile contains four COPY layers: COPY README.md ./ COPY package.json ./ COPY gulpfile.js ./ COPY __BUILD_NUMBER ./ How to copy these files using one layer instead? The following was tried: COPY [ "__BUILD_NUMBER ./", "R...

Javascript window.print() in chrome, closing new window or tab instead of cancelling print leaves javascript blocked in parent window

In the application I work on, we have several different places a user can print from. In all these cases we are using the same workflow of opening a new window(or tab), writing whatever we need to print to the document of the new window, and then we...

CRON command to run URL address every 5 minutes

I'm newbie in cron commands and I need help. I have a script on http://example.com/check/. Whats is command for cron to run this URL every 5 minutes? I tried */5 * * * * /home/test/check.php But I want to run URL not relative script addres...

How can I INSERT data into two tables simultaneously in SQL Server?

Let's say my table structure looks something like this: CREATE TABLE [dbo].[table1] ( [id] [int] IDENTITY(1,1) NOT NULL, [data] [varchar](255) NOT NULL, CONSTRAINT [PK_table1] PRIMARY KEY CLUSTERED ([id] ASC) ) CREATE TABLE [dbo].[table...

Difference between Running and Starting a Docker container

In practice to start a container I do: docker run a8asd8f9asdf0 If thats the case, what does: docker start do? In the manual it says Start one or more stopped containers ...

How to make a radio button unchecked by clicking it?

Unlike check boxes, it is impossible for the user to deselect radio buttons once they are clicked. Is there any way so that they can be toggled programmatically using Javascript? This would be preferably without using jQuery....

Arrays in type script

I am finding difficulty declaring array in typescript and accessing it. below is the code working for me class Book { public BookId: number; public Title: string; public Author: string; public Price: number; public Description: ...

How can I suppress the newline after a print statement?

I read that to suppress the newline after a print statement you can put a comma after the text. The example here looks like Python 2. How can it be done in Python 3? For example: for item in [1,2,3,4]: print(item, " ") What needs to change so...

Inserting a Python datetime.datetime object into MySQL

I have a date column in a MySQL table. I want to insert a datetime.datetime() object into this column. What should I be using in the execute statement? I have tried: now = datetime.datetime(2009,5,5) cursor.execute("INSERT INTO table (name, id, da...

How to commit a change with both "message" and "description" from the command line?

I'm new to both git and GitHub. I managed to set up everything locally on my Mac, so that now I can push commits to GitHub via git (on the command line, not the Mac app). When I push commits directly from the GitHub web interface (e.g. quickly fixin...

sizing div based on window width

I have kind of a weird question. On my page I have a main image of a planet in some heavy duty nebula. I have it set up so the min width is 1000px and max is 1500px. I have the sides fading out and this looks great with larger screens. What I'd like...

Find files containing a given text

In bash I want to return file name (and the path to the file) for every file of type .php|.html|.js containing the case-insensitive string "document.cookie" | "setcookie" How would I do that?...

How to remove all numbers from string?

I'd like to remove all numbers from a string [0-9]. I wrote this code that is working: $words = preg_replace('/0/', '', $words ); // remove numbers $words = preg_replace('/1/', '', $words ); // remove numbers $words = preg_replace('/2/', '', $words ...

MySQL CURRENT_TIMESTAMP on create and on update

I want to define table which will have 2 TIMESTAMP fields, someting like this: CREATE TABLE `msgs` ( `id` INT PRIMARY KEY AUTO_INCREMENT, `msg` VARCHAR(256), `ts_create` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `ts_update` TIMESTAMP DEFA...

What is the difference between logical data model and conceptual data model?

What is the difference between logical data model and conceptual data model?...

Node.js global variables

I asked here: Does Node.js require inheritance? And I was told that I can set variables to the global scope by leaving out the variable. This does not work for me. That is, the following does not make the _ available on required files. _ = require('u...

How to refer to Excel objects in Access VBA?

What declarations I have to make in order to be able to use Excel objects and constants from my Access 2007 VBA script? Dim wb As Workbook or Set objExcelApp = New Excel.Application or .Borders(xlEdgeBottom) Thanks...

Add new element to an existing object

I was looking for a way to add new elements to an an existing object like what push does with arrays I have tried this and it didn't work : var myFunction = { Author: 'my name ', date: '15-12-2012', doSomething: function(){ ale...

How do I get Month and Date of JavaScript in 2 digit format?

When we call getMonth() and getDate() on date object, we will get the single digit number. For example : For january, it displays 1, but I need to display it as 01. How to do that?...

Checking if an input field is required using jQuery

What would be the easiest way to check if an input is required? I have been trying stuff along these lines but always comes up with all required (only 4/6 are). $('form#register').find('input').each(function(){ if($(this).prop('required') == 'un...

Exporting functions from a DLL with dllexport

I'd like a simple example of exporting a function from a C++ Windows DLL. I'd like to see the header, the .cpp file, and the .def file (if absolutely required). I'd like the exported name to be undecorated. I'd like to use the most standard calling...

How to parse a String containing XML in Java and retrieve the value of the root node?

I have XML in the form of a String that contains <message>HELLO!</message> How can I get the String "Hello!" from the XML? It should be ridiculously easy but I am lost. The XML isn't in a doc, it is simply a String. ...

Get all messages from Whatsapp

I'm trying to implement an app that will show in a textview all the messages received from Whatsapp. Is there any way to do it? Is it possible to extract all the messages from Whatsapp?...

How to fix a locale setting warning from Perl

When I run perl, I get the warning: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl:...

IsNullOrEmpty with Object

IsNullOrEmpty is used with strings to check if a string is null or empty. Is there an equivalent with an object to see if any object is null or not? I assume we can do obj1 != null but not sure if there is any other way......

How to play a local video with Swift?

I have a short mp4 video file that I've added to my current Xcode6 Beta project. I want to play the video in my app. After hours searching, I can't find anything remotely helpful. Is there a way to accomplish this with Swift or do you have to use O...

How to stop an animation (cancel() does not work)

I need to stop a running translate animation. The .cancel() method of Animation has no effect; the animation goes until the end anyway. How do you cancel a running animation?...

Formatting numbers (decimal places, thousands separators, etc) with CSS

Is it possible to format numbers with CSS? That is: decimal places, decimal separator, thousands separator, etc....

Regular Expression for alphanumeric and underscores

I would like to have a regular expression that checks if a string contains only upper and lowercase letters, numbers, and underscores....

Fetch frame count with ffmpeg

Does anyone know how to fetch the number of total frames from a video file using ffmpeg? The render output of ffmpeg shows the current frame and I need the frame count to calculate the progress in percent....

Deleting row from datatable in C#

I'm having a problem deleting rows from a datatable. In my program, I am reading info from a database into a datatable using an sql query. I use an oledb connection and the code dt.Load(command.ExecuteReader()); to do this. Later, I want to delete ro...

Incorrect integer value: '' for column 'id' at row 1

I am trying to insert into my mySQL database. The first column is the 'id' column, since its an auto_increment field, I left it blank. For some reason, I am unable to insert and I am getting the error mentioned below. I appreciate any help with this....

How to force HTTPS using a web.config file

I have searched around Google and StackOverflow trying to find a solution to this, but they all seem to relate to ASP.NET etc. I usually run Linux on my servers but for this one client I am using Windows with IIS 7.5 (and Plesk 10). This being the r...

how can I Update top 100 records in sql server

I want to update the top 100 records in SQL Server. I have a table T1 with fields F1 and F2. T1 has 200 records. I want to update the F1 field in the top 100 records. How can I update based on TOP 100 in SQL Server?...

Getting Python error "from: can't read /var/mail/Bio"

I am running a (bio)python script which results in the following error: from: can't read /var/mail/Bio seeing as my script doesn't have anything to with mail, I don't understand why my script is looking in /var/mail. What seems to be the problem ...

Get all inherited classes of an abstract class

I have an abstract class: abstract class AbstractDataExport { public string name; public abstract bool ExportData(); } I have classes which are derived from AbstractDataExport: class XmlExport : AbstractDataExport { new public...

Creation timestamp and last update timestamp with Hibernate and MySQL

For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this? What data types would you use in the database (assuming MySQL, possibly in a different timezone that the J...

OnItemCLickListener not working in listview

Activity class code: conversationList = (ListView)findViewById(android.R.id.list); ConversationArrayAdapter conversationArrayAdapter=new ConversationArrayAdapter(this, R.layout.conversation_list_item_format_left, conversationDetails); conversationL...

Test if numpy array contains only zeros

We initialize a numpy array with zeros as bellow: np.zeros((N,N+1)) But how do we check whether all elements in a given n*n numpy array matrix is zero. The method just need to return a True if all the values are indeed zero....

Determine if a String is an Integer in Java

I'm trying to determine if a particular item in an Array of strings is an integer or not. I am .split(" ")'ing an infix expression in String form, and then trying to split the resultant array into two arrays; one for integers, one for operators, whi...

Open a file with Notepad in C#

How I open a file in c#? I don't mean reading it by textreader and readline(). I mean open it as an independent file in notepad....

What is the difference between "is None" and "== None"

I recently came across this syntax, I am unaware of the difference. I would appreciate it if someone could tell me the difference....

Stopping a windows service when the stop option is grayed out

I have created a windows service and in the service in control panel -> administrative tools -> services, its status is starting. I want to stop this service, but the stop option is grayed out. How can I start/stop the service? Every time I restart...

Check if a temporary table exists and delete if it exists before creating a temporary table

I am using the following code to check if the temporary table exists and drop the table if it exists before creating again. It works fine as long as I don't change the columns. If I add a column later, it will give an error saying "invalid column". P...

Convert row to column header for Pandas DataFrame,

The data I have to work with is a bit messy.. It has header names inside of its data. How can I choose a row from an existing pandas dataframe and make it (rename it to) a column header? I want to do something like: header = df[df['old_header_name1...

Fast check for NaN in NumPy

I'm looking for the fastest way to check for the occurrence of NaN (np.nan) in a NumPy array X. np.isnan(X) is out of the question, since it builds a boolean array of shape X.shape, which is potentially gigantic. I tried np.nan in X, but that seems ...

What does file:///android_asset/www/index.html mean?

I want to know what does file:/// mean while loading a html file from the assets folder in android Is it an absolute path name which points to the root directory? I saw this in the tutorial for phonegap by the way....

var.replace is not a function

I'm using the below code to try to trim the string in Javascript but am getting the error mentioned in the title: function trim(str) { return str.replace(/^\s+|\s+$/g,''); } Edit: I fixed the problem.... sorry I should have put the code on ho...

How do I update a formula with Homebrew?

How do I update a formula? I ran brew update. Then, running brew outdated, outputs: mongodb (1.4.3-x86_64 < 1.6.5-x86_64) Thus, mongodb is outdated. How do I upgrade it? Do I just uninstall and then install?...

An Authentication object was not found in the SecurityContext - Spring 3.2.2

I'm trying to invoke a protected method from a class that implements the ApplicationListener<AuthenticationSuccessEvent> interface on successful login (Spring 3.2.2 and Spring Security 3.2.0 M1). This is my previous question. The application r...

How can I reconcile detached HEAD with master/origin?

I'm new at the branching complexities of Git. I always work on a single branch and commit changes and then periodically push to my remote origin. Somewhere recently, I did a reset of some files to get them out of commit staging, and later did a reba...

I just assigned a variable, but echo $variable shows something else

Here are a series of cases where echo $var can show a different value than what was just assigned. This happens regardless of whether the assigned value was "double quoted", 'single quoted' or unquoted. How do I get the shell to set my variable cor...

Open page in new window without popup blocking

Hope you can help a bit here... I have a form that translate a word in a field, populate the field with the translated term and then do submit action all in one submit button. the submit is being made by jquery. problem is the target page is being b...

How can I detect if this dictionary key exists in C#?

I am working with the Exchange Web Services Managed API, with contact data. I have the following code, which is functional, but not ideal: foreach (Contact c in contactList) { string openItemUrl = "https://" + service.Url.Host + "/owa/" + c.WebC...

Are there any worse sorting algorithms than Bogosort (a.k.a Monkey Sort)?

My co-workers took me back in time to my University days with a discussion of sorting algorithms this morning. We reminisced about our favorites like StupidSort, and one of us was sure we had seen a sort algorithm that was O(n!). That got me starte...

Android Respond To URL in Intent

I want my intent to be launched when the user goes to a certain url: for example, the android market does this with http://market.android.com/ urls. so does youtube. I want mine to do that too....

Install python 2.6 in CentOS

I have a shell that runs CentOS. For a project I'm doing, I need python 2.5+, but centOS is pretty dependent on 2.4. From what I've read, a number of things will break if you upgrade to 2.5. I want to install 2.5 separately from 2.4, but I'm not s...

How to delete specific characters from a string in Ruby?

I have several strings that look like this: "((String1))" They are all different lengths. How could I remove the parentheses from all these strings in a loop?...

OpenCV Error: (-215)size.width>0 && size.height>0 in function imshow

I am trying to make a face tracker that combines Haar Cascade Classification with Lucas Kanade good feature detection. However, I keep getting an error that I cannot figure out what it means nor how to solve it. Can anyone help me here? Error: lin...

How to fix "The ConnectionString property has not been initialized"

When I start my application I get: The ConnectionString property has not been initialized. Web.config: <connectionStrings> <add name="MyDB" connectionString="Data Source=localhost\sqlexpress;Initial Catalog=mydatabase;User I...

Android Fatal signal 11 (SIGSEGV) at 0x636f7d89 (code=1). How can it be tracked down?

I've been reading the other posts on tracking down the reasons for getting a SIGSEGV in an Android app. I plan to scour my app for possible NullPointers related to Canvas use, but my SIGSEGV barfs up a different memory address each time. Plus I've se...

How can you create multiple cursors in Visual Studio Code

What are the keyboard shortcuts for creating multiple cursors in VS Code?...

iterating over each character of a String in ruby 1.8.6 (each_char)

I am new to ruby and currently trying to operate on each character separately from a base String in ruby. I am using ruby 1.8.6 and would like to do something like: "ABCDEFG".each_char do |i| puts i end This produces a undefined method `each_cha...

What is Scala's yield?

I understand Ruby and Python's yield. What does Scala's yield do?...

How to stop the task scheduled in java.util.Timer class

I am using java.util.Timer class and I am using its schedule method to perform some task, but after executing it for 6 times I have to stop its task. How should I do that?...

Disable submit button ONLY after submit

I have the following HTML and jquery: <html dir="ltr" lang="en"> <head> </head> <body> <h2>Test disabling submit button for 1 minute...</h2> <br/> <p style="text-align:center"> <form id="yourFor...

Convert string to ASCII value python

How would you convert a string to ASCII values? For example, "hi" would return 104105. I can individually do ord('h') and ord('i'), but it's going to be troublesome when there are a lot of letters. ...

Assertion failure in dequeueReusableCellWithIdentifier:forIndexPath:

So I was making an rss reader for my school and finished the code. I ran the test and it gave me that error. Here is the code it's referring to: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)i...

How do you access a website running on localhost from iPhone browser

I am working on a mobile website and would like to test it using my iPhone browser. My Windows 7 machine and iPhone are on the same wireless network. How do I access localhost from the iPhone? Right now I get a 404 error....

How to compare oldValues and newValues on React Hooks useEffect?

Let's say I have 3 inputs: rate, sendAmount, and receiveAmount. I put that 3 inputs on useEffect diffing params. The rules are: If sendAmount changed, I calculate receiveAmount = sendAmount * rate If receiveAmount changed, I calculate sendAmount = ...

How to apply Hovering on html area tag?

I am trying to hover the area tag of HTML. I tried this in CSS: area:hover { border:1px solid black; } This is the HTML on which it should be applied. <!-- This imagemap inserted by Gwyn's Imagemap Selector http://gwynethllewelyn.net/gwyns...

ASP.NET postback with JavaScript

I have several small divs which are utilizing jQuery draggable. These divs are placed in an UpdatePanel, and on dragstop I use the _doPostBack() JavaScript function, where I extract necessary information from the page's form. My problem is that when ...

Play sound file in a web-page in the background

I want to play a sound file on my web-page in the back-ground(don't want Media player UI to appear), my web-site will run on Fire-Fox, i used the Embed element and set the Hidden attribute to be true <embed name="myMusic" src="Masgon.mp3" type="au...

Vbscript list all PDF files in folder and subfolders

Well here is my code but I just can not filter the listing using the objFile.Extension i am sure it is some thing silly Set objFSO = CreateObject("Scripting.FileSystemObject") objStartFolder = "C:\dev" Set objFolder = objFSO.GetFolder(objStartFolde...

How to remove a key from HashMap while iterating over it?

I am having HashMap called testMap which contains String, String. HashMap<String, String> testMap = new HashMap<String, String>(); When iterating the map, if value is match with specified string, I need to remove the key from map. i.e...

Semaphore vs. Monitors - what's the difference?

What are the major differences between a Monitor and a Semaphore?...

What do curly braces mean in Verilog?

I am having a hard time understanding the following syntax in Verilog: input [15:0] a; // 16-bit input output [31:0] result; // 32-bit output assign result = {{16{a[15]}}, {a[15:0]}}; I know the assign statement will wire something up to the...

What is difference between arm64 and armhf?

Raspberry Pi Type 3 has 64-bit CPU, but its architecture is not arm64 but armhf. What is the difference between arm64 and armhf?...

Convert int to char in java

Below is a code snippet, int a = 1; char b = (char) a; System.out.println(b); But what I get is empty output. int a = '1'; char b = (char) a; System.out.println(b); I will get 1 as my output. Can somebody explain this? And if I want to conver...

Java: Date from unix timestamp

I need to convert a unix timestamp to a date object. I tried this: java.util.Date time = new java.util.Date(timeStamp); Timestamp value is: 1280512800 The Date should be "2010/07/30 - 22:30:00" (as I get it by PHP) but instead I get Thu Jan 15 23...

Can I call methods in constructor in Java?

I have situation, where I want to read configuration file only one time, when class is instantiated. Suppose I have a method named readConfig(), that reads configuration and puts it into a Map object. When the program is required to use configuratio...

Is there a performance difference between CTE , Sub-Query, Temporary Table or Table Variable?

In this excellent SO question, differences between CTE and sub-queries were discussed. I would like to specifically ask: In what circumstance is each of the following more efficient/faster? CTE Sub-Query Temporary Table Table Variable Traditio...

What's the difference between "app.render" and "res.render" in express.js?

Docs for app.render: Render a view with a callback responding with the rendered string. This is the app-level variant of res.render(), and otherwise behaves the same way. Docs for res.render: Render a view with a callback responding with th...

if variable contains

Possible Duplicate: JavaScript: string contains I have a postcode variable and want to use JS to add a location into a different variable when the postcode is changed/entered. So for example if ST6 is entered I would want Stoke North to b...

Get current time in seconds since the Epoch on Linux, Bash

I need something simple like date, but in seconds since 1970 instead of the current date, hours, minutes, and seconds. date doesn't seem to offer that option. Is there an easy way?...

Script to get the HTTP status code of a list of urls?

I have a list of URLS that I need to check, to see if they still work or not. I would like to write a bash script that does that for me. I only need the returned HTTP status code, i.e. 200, 404, 500 and so forth. Nothing more. EDIT Note that t...

Nginx: Job for nginx.service failed because the control process exited

I got a problem which I have been trying to fix for a few days now and I don't know what to do, have been looking for answers but all of those I found didn't help me. I am kinda new here and I really hope that someone can help me. You can tell me wh...

How to disable SSL certificate checking with Spring RestTemplate?

I am trying to write an integration test where our test launches an embedded HTTPS server using Simple. I created a self-signed certificate using keytool and am able to access the server using a browser (specifically Chrome, and I do get a warning ab...

jsonify a SQLAlchemy result set in Flask

I'm trying to jsonify a SQLAlchemy result set in Flask/Python. The Flask mailing list suggested the following method http://librelist.com/browser//flask/2011/2/16/jsonify-sqlalchemy-pagination-collection-result/#04a0754b63387f87e59dda564bde426e : r...

TypeError: Invalid dimensions for image data when plotting array with imshow()

For the following code # Numerical operation SN_map_final = (new_SN_map - mean_SN) / sigma_SN # Plot figure fig12 = plt.figure(12) fig_SN_final = plt.imshow(SN_map_final, interpolation='nearest') plt.colorbar() fig12 = plt.savefig(outname12) w...

base_url() function not working in codeigniter

In my web application using codeigniter. I am trying to use base_url() function but it shows empty results. I have also used autoload helper through autoload file, but then too it doesn't seem to work. Also I had defined base constants but all in vai...

Plot multiple columns on the same graph in R

I have the following data frame: A B C D Xax 0.451 0.333 0.034 0.173 0.22 0.491 0.270 0.033 0.207 0.34 0.389 0.249 0.084 0.271 0.54 0.425 0.819 0.077 0.281 0.34 0.457 0.429 ...

Customizing Bootstrap CSS template

I am just getting started with Bootstrap from Twitter and am wondering what the ‘best practices’ is for customization. I want to develop a system that will take advantage of all the power of a css template (Bootstrap or other), be completely (and...

How to configure heroku application DNS to Godaddy Domain?

I have created a heroku application and wants to give domain to it from godaddy.com. I have configured all three hosts provided by heroku but now I am getting error saying: Heroku | No such app There is no app configured at that hostname. ...

Chrome Fullscreen API

According to this article Google Chrome 15 has a fullscreen JavaScript API. I have tried to make it work but failed. I have also searched for official documentation in vain. What does the fullscreen JavaScript API look like?...

Reset select value to default

I have select box <select id="my_select"> <option value="a">a</option> <option value="b" selected="selected">b</option> <option value="c">c</option> </select> <div id="reset"> re...

SQL permissions for roles

I'm a bit confused about permissions in SQL I have created a medical database. As a script I'm creating a doctor role and I want to say they can perform updates on tables 1,2 and 3. The database though actually contains 5 tables. does it mean tha...

PHP if not statements

This may be the way my server is set up, but I'm banging my head against the wall. I'm trying to say that if $action has no value or has a value that is not "add" or "delete" then have an error, else keep running the script. However, I get an error n...

Import SQL dump into PostgreSQL database

We are switching hosts and the old one provided a SQL dump of the PostgreSQL database of our site. Now, I'm trying to set this up on a local WAMP server to test this. The only problem is that I don't have an idea how to import this database in the ...

Excel Date Conversion from yyyymmdd to mm/dd/yyyy

I have been searching for about an hour on how to do this in Excel. I have an Excel file that was created from an old system and I am pulling information from a SQL Server Database, I will be inputting the information back into the SQL Server Databa...

Volley JsonObjectRequest Post request not working

I am using android Volley for making a request. So I use this code. I don't understand one thing. I check in my server that params is always null. I consider that getParams() not working. What should I do to solve this issue. RequestQueue queue = M...

Evaluate empty or null JSTL c tags

How can I validate if a String is null or empty using the c tags of JSTL? I have a variable of name var1 and I can display it, but I want to add a comparator to validate it. <c:out value="${var1}" /> I want to validate when it is null or em...

How to enable DataGridView sorting when user clicks on the column header?

I have a datagridview on my form and I populate it with this: dataGridView1.DataSource = students.Select(s => new { ID = s.StudentId, RUDE = s.RUDE, Nombre = s.Name, Apellidos = s.LastNameFather + " " + s.LastNameMother, Nacido = s.DateOfBirth })...

Install a Nuget package in Visual Studio Code

How can I install a Nuget Package in Visual Studio Code? I know in Visual Studio, we can do this through the Nuget Package Manager console, but how do I do it in VS Code?...

How to use Java property files?

I have a list of key/value pairs of configuration values I want to store as Java property files, and later load and iterate through. Questions: Do I need to store the file in the same package as the class which will load them, or is there any spec...

I have Python on my Ubuntu system, but gcc can't find Python.h

I am on a school computer, so I can't install anything. I am trying to create C code which can be run in Python. It seems all the articles I am finding on it require you to use #include <Python.h> I do this, but when I compile it complains...

Is it possible to modify a string of char in C?

I have been struggling for a few hours with all sorts of C tutorials and books related to pointers but what I really want to know is if it's possible to change a char pointer once it's been created. This is what I have tried: char *a = "This is a s...

Prevent jQuery UI dialog from setting focus to first textbox

I have setup a jQuery UI modal dialog to display when a user clicks a link. There are two textboxes (I only show the code for 1 for brevity) in that dialog div tag and it is changed to be a jQuery UI DatePicker textbox that reacts on focus. The pro...

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",*name); } Output is siva s Why we need to...

How to update record using Entity Framework Core?

What is the best approach to update database table data in Entity Framework Core? Retrieve the table row, do the changes and save Use keyword Update in DB context and handle exception for item not exist What are the improved features we can use ove...

How to check the input is an integer or not in Java?

In my program I want an integer input by the user. I want an error message to be show when user inputs a value which is not an integer. How can I do this. My program is to find area of circle. In which user will input the value of radius. But if use...

Jquery to get SelectedText from dropdown

I am trying to get the selected Text from the dropdownlist using Jquery. <div> @Html.DropDownList("SelectedCountryId", Model.CountryList, "(Select one Country)") </div> Given below is the Jquery that I am using. But this is not wor...

Angular 2 router.navigate

I'm trying to navigate to a route in Angular 2 with a mix of route and query parameters. Here is an example route where the route is the last part of the path: { path: ':foo/:bar/:baz/page', component: AComponent } Attempting to link using the a...

Javascript: How to check if a string is empty?

I know this is really basic, but I am new to javascript and can't find an answer anywhere. How can I check if a string is empty?...

How to execute a java .class from the command line

I have a compiled java class: Echo.class public class Echo { public static void main (String arg) { System.out.println(arg); } } I cd to the directory and enter: java Echo "hello" I get this error: C:\Documents and Settings...

Where does Hive store files in HDFS?

I'd like to know how to find the mapping between Hive tables and the actual HDFS files (or rather, directories) that they represent. I need to access the table files directly. Where does Hive store its files in HDFS?...

Not an enclosing class error Android Studio

I am new in android development and do not have an in depth knowledge of Java. I am stuck on a problem for a long time. I am trying to open a new activity on button click. But I am getting an error that error: not an enclosing class: Katra_home. Her...

Mosaic Grid gallery with dynamic sized images

I have just received the following design for a project, for an image grid gallery, with dynamic width & height images (user submitted images). (Screenshot at the end of post) I have tried jQuery Masonry, Tympanus Automatic Image Montage and CSS...

Convert an array to string

How do I make this output to a string? List<string> Client = new List<string>(); foreach (string listitem in lbClients.SelectedItems) { Client.Add(listitem); } ...

What is the fastest way to compare two sets in Java?

I am trying to optimize a piece of code which compares elements of list. Eg. public void compare(Set<Record> firstSet, Set<Record> secondSet){ for(Record firstRecord : firstSet){ for(Record secondRecord : secondSet){ ...

MySQL: Can't create/write to file '/tmp/#sql_3c6_0.MYI' (Errcode: 2) - What does it even mean?

For some reason my production DB decided to spew out this message. All application calls fail to the DB with the error: PreparedStatementCallback; SQL [ /*long sql statement here*/ ]; Can't create/write to file '/tmp/#sql_3c6_0.MYI' (Errcode: 2); ...

Java: How to convert a File object to a String object in java?

Possible Duplicate: How to create a Java String from the contents of a file I have a html file which I want to use to extract information. For that I am using Jsoup. Now for using Jsoup, I need to convert the html file into a string. How c...

How do you remove Subversion control for a folder?

I have a folder, c:\websites\test, and it contains folders and files that were checked out from a repository that no longer exists. How do I get Subversion to stop tracking that folder and any of the subfolders and files? I know I could simply dele...

Prevent textbox autofill with previously entered values

I have an asp page with some Textbox controls on it. By default, the browser will suggest previously entered values for each box. I'd like to prevent that behavior for some of the textboxes. Is there a way to reliably do that across all major brow...

Skipping Incompatible Libraries at compile

When I try to compile a copy of my project on my local machine, I get an error stating that it 's skipping over incompatible libraries. This isn't the case when I'm messing around with the live version hosted on the server at work [it makes perfectl...

Disable activity slide-in animation when launching new activity?

I have an activity which launches another activity, via a button click. By default, on newer OS versions of android, the OS will animate the new activity sliding in from right to left. Is there a way to disable this animation? I just want the new ac...

How do I change the background color with JavaScript?

Anyone know a simple method to swap the background color of a webpage using JavaScript?...

What is "string[] args" in Main class for?

In C# the Main class has string[] args parameter. What is that for and where does it get used?...

Reducing video size with same format and reducing frame size

This question might be very basic Is there a way to reduce the frame size/rate of Lossy compressed (WMV, MPEG) format, to get a smaller video, of lesser size, with same format. Are there any open source or proprietary apis for this?...

How to SSH into Docker?

I'd like to create the following infrastructure flow: How can that be achieved using Docker?...

How to find the privileges and roles granted to a user in Oracle?

I am using Linux, Oracle10g. I have created one user called test. and granted create session and select any dictionary permission to the same user. i also granted sysdba and sysoper roles to the same users. Now i want to display all the privileges ...

How to use LINQ to select object with minimum or maximum property value

I have a Person object with a Nullable DateOfBirth property. Is there a way to use LINQ to query a list of Person objects for the one with the earliest/smallest DateOfBirth value. Here's what I started with: var firstBornDate = People.Min(p => ...

How to format a duration in java? (e.g format H:MM:SS)

I'd like to format a duration in seconds using a pattern like H:MM:SS. The current utilities in java are designed to format a time but not a duration....

Binding to static property

I'm having a hard time binding a simple static string property to a TextBox. Here's the class with the static property: public class VersionManager { private static string filterString; public static string FilterString { get ...

Finding what methods a Python object has

Given a Python object of any kind, is there an easy way to get the list of all methods that this object has? Or, if this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error oc...

Best practices for adding .gitignore file for Python projects?

I'm trying to collect some of my default settings, and one thing I realized I don't have a standard for is .gitignore files. There's a great thread showing a good .gitignore for Visual Studio projects, but I don't see many recommendations for Python ...

Simple GUI Java calculator

I am building a simple GUI Java calculator. I have an issue finding a package or figuring out a method to do the actual calculation. So far I've figured that when I do a math operation, the number in the text box gets saved in a temporary location. ...

Using find to locate files that match one of multiple patterns

I was trying to get a list of all python and html files in a directory with the command find Documents -name "*.{py,html}". Then along came the man page: Braces within the pattern (‘{}’) are not considered to be special (that is, find . -nam...

How to hide TabPage from TabControl

How to hide TabPage from TabControl in WinForms 2.0?...

Rollback transaction after @Test

First of all, I've found a lot of threads on StackOverflow about this, but none of them really helped me, so sorry to ask possibly duplicate question. I'm running JUnit tests using spring-test, my code looks like this @RunWith(SpringJUnit4ClassRunn...

Can Mockito stub a method without regard to the argument?

I'm trying to test some legacy code, using Mockito. I want to stub a FooDao that is used in production as follows: foo = fooDao.getBar(new Bazoo()); I can write: when(fooDao.getBar(new Bazoo())).thenReturn(myFoo); But the obvious problem is th...

XML element with attribute and content using JAXB

How can I generate the following XML using JAXB? <sport type="" gender=""> sport description </sport> ...

How to ignore certain files in Git

I have a repository with a file, Hello.java. When I compile it, an additional Hello.class file is generated. I created an entry for Hello.class in a .gitignore file. However, the file still appears to be tracked. How can I make Git ignore Hello.cla...

Error: Specified cast is not valid. (SqlManagerUI)

I have a backup from database in SQL Server 2008 R2. When I want to restore this backup to SQL Server, I get this error: "Error: Specified cast is not valid. (SqlManagerUI)" How to I resolve this error? Thanks....

Round number to nearest integer

I've been trying to round long float numbers like: 32.268907563; 32.268907563; 31.2396694215; 33.6206896552; ... With no success so far. I tried math.ceil(x), math.floor(x) (although that would round up or down, which is not what I'm looking for) ...

How do I pretty-print existing JSON data with Java?

I have a compact JSON string, and I want to format it nicely in Java without having to deserialize it first -- e.g. just like jsonlint.org does it. Are there any libraries out there that provides this? A similar solution for XML would also be nice....

Drawing a dot on HTML5 canvas

Drawing a line on the HTML5 canvas is quite straightforward using the context.moveTo() and context.lineTo() functions. I'm not quite sure if it's possible to draw a dot i.e. color a single pixel. The lineTo function wont draw a single pixel line (ob...

Killing a process using Java

I would like to know how to "kill" a process that has started up. I am aware of the Process API, but I am not sure, If I can use that to "kill" an already running process, such as firefox.exe etc. If the Process API can be used, can you please point ...

OnclientClick and OnClick is not working at the same time?

I have a button like the following, <asp:Button ID="pagerLeftButton" runat="server" OnClientClick="disable(this)" onclick="pager_Left_Click" Text="<" /> When I use my button like that, onclick is not firing. When I remove OnClientClick, t...

Capture the close event of popup window in JavaScript

I need to perform some action before a popup window(using window.open ) closes. Something like will be good: var new_window = window.open('some url') new_window.onBeforeUnload = function(){ my code} How can I achieve that?...

Include CSS,javascript file in Yii Framework

How to include a Javascript or CSS file in Yii Framework? I want to create a page on my site that has a little Javascript application running, so I want to include .js and .css files in a specific view....

Running Python in PowerShell?

I am attempting to learn the very basics of Python using the guide "Learn Python the hard way" by Zed A. Shaw. The problem that I am having is that I can run Python scripts, but only when using .\ in front of the name. This opens up CMD for a split s...

CSS table column autowidth

Given the following how do i make my last column auto size to its content? (The last column should autosize-width to the content. Suppose i have only 1 li element it should shrink vs. having 3 li elements etc): <table cellspacing="0" ...

Different color for each bar in a bar chart; ChartJS

I'm using ChartJS in a project I'm working on and I need a different color for each bar in a Bar Chart. Here's an example of the bar chart data set: var barChartData = { labels: ["001", "002", "003", "004", "005", "006", "007"], datasets: [{ ...

How to use the DropDownList's SelectedIndexChanged event

I have two DropDownLists in my webform and when I select a value in the first dropdownlist, I would like a related value to be automatically selected in the second dropdownlist. This is what I currently have: <table> <tr>...

How to loop through key/value object in Javascript?

var user = {}; now I want to create a setUsers() method that takes a key/value pair object and initializes the user variable. setUsers = function(data) { // loop and init user } where data is like: 234: "john", 23421: "smith", .... ...

Please explain the exec() function and its family

What is the exec() function and its family? Why is this function used and how does its work? Please anyone explain these functions....

Python: Random numbers into a list

Create a 'list' called my_randoms of 10 random numbers between 0 and 100. This is what I have so far: import random my_randoms=[] for i in range (10): my_randoms.append(random.randrange(1, 101, 1)) print (my_randoms) Unfortunately Python'...

Create a File object in memory from a string in Java

I have a function that accepts File as an argument. I don't want to create/write a new File (I don't have write access to filesystem) in order to pass my string data to the function. I should add that the String data don't exist in a file (so I canno...

Can I mask an input text in a bat file?

I am writing a batch file to execute some other programs. In this case I need to prompt for a password. Do I have any way to mask the input text? I don't need to print ******* characters instead of input characters. Linux's Password prompt behavior (...

Gradle - Could not find or load main class

I'm trying to run a very simple project using Gradle and running into the following error when using the gradlew run command: could not find or load main class 'hello.HelloWorld' Here is my file structure: SpringTest -src -hello ...

Is it necessary to use # for creating temp tables in SQL server?

Is it necessary to use # before creating a temporary table in SQL server? Example: SELECT column1, column2, someInt, someVarChar INTO ItemBack1 FROM table2 WHERE table2.ID = 7 For ItemBack1 is it necessary to use the # symbol? If not, then wh...

How to install bcmath module?

How do I install the bcmath module on a server? I tried yum update php-bcmath but it said it found nothing....

Add another class to a div

I have a function that checks the age of a form submission and then returns new content in a div depending on their age. Right now I am just using getElementById to replace the HTML content. BUt I think would work better for me if I could also add a ...

How can I fix the 'Missing Cross-Origin Resource Sharing (CORS) Response Header' webfont issue?

For some reason fonts have stopped rendering on my sites. The fonts are stored locally, on the same server as the site. I looked up the problem and it seems to be a Missing Cross-Origin Resource Sharing (CORS) Response Header but I cannot understand...

SOAP or REST for Web Services?

Is REST a better approach to doing Web Services or is SOAP? Or are they different tools for different problems? Or is it a nuanced issue - that is, is one slightly better in certain arenas than another, etc? I would especially appreciate informat...

Catch multiple exceptions at once?

It is discouraged to simply catch System.Exception. Instead, only the "known" exceptions should be caught. Now, this sometimes leads to unnecessary repetitive code, for example: try { WebId = new Guid(queryString["web"]); } ca...

Css Move element from left to right animated

I have an element that needs to be move from left to right and right to left when I change the left, right variables. Here is an jsfiddle example that I'm working on it. It moves left to right and right to left but there is no animation. What I am ...

How to remove all white spaces in java

I have a programming assignment and part of it requires me to make code that reads a line from the user and removes all the white space within that line. the line can consist of one word or more. What I was trying to do with this program is hav...

Where do I put image files, css, js, etc. in Codeigniter?

Where is it acceptable to put css folders and image file folders? I was thinking inside the view folder? However the controller always reroutes the path to the base url so I have to specify the path in the .html file to where it sits, which is redund...

Eclipse: Enable autocomplete / content assist

How can I enable autocomplete in Eclipse? I can't find it!...

Block direct access to a file over http but allow php script access

I'm loading my files (pdf, doc, flv, etc) into a buffer and serving them to my users with a script. I need my script to be able to access the file but not allow direct access to it. Whats the best way to achieve this? Should I be doing something w...

How can I toggle word wrap in Visual Studio?

Does Visual Studio .NET have a way to toggle word-wrap on and off? I am used to this feature in Eclipse which allows you to right click and toggle word wrap on and off so that when you have long lines that extend out to the right, you don't have to ...

How to use SharedPreferences in Android to store, fetch and edit values

I want to store a time value and need to retrieve and edit it. How can I use SharedPreferences to do this?...

Export query result to .csv file in SQL Server 2008

How can I export a query result to a .csv file in SQL Server 2008?...

xlrd.biffh.XLRDError: Excel xlsx file; not supported

I am trying to read a macro-enabled Excel worksheet using pandas.read_excel with the xlrd library. It's running fine in local, but when I try to push the same into PCF, I am getting this error: 2020-12-11T21:09:53.441+05:30 [APP/PROC/WEB/0] [ERR] df1...

Arrays.asList() of an array

What is wrong with this conversion? public int getTheNumber(int[] factors) { ArrayList<Integer> f = new ArrayList(Arrays.asList(factors)); Collections.sort(f); return f.get(0)*f.get(f.size()-1); } I made this after reading the ...

How to set and reference a variable in a Jenkinsfile

I have a declarative pipeline script for my multibranch project in which I would like to read a text file and store the result as a string variable to be accessed by a later step in the pipeline. Using the snippet generator I tried to do something li...

Python: How to create a unique file name?

I have a python web form with two options - File upload and textarea. I need to take the values from each and pass them to another command-line program. I can easily pass the file name with file upload options, but I am not sure how to pass the value...

Directory index forbidden by Options directive

I'm using the dompdf plugin for codeigniter: http://codeigniter.com/wiki/PDF_generation_using_dompdf/ to generate pdfs from a form. This works on localhost, but on the live server I get this in the error log: Directory index forbidden by Options di...

'python3' is not recognized as an internal or external command, operable program or batch file

I am using Python 3.5.2 version on Windows 7 and tried using python3 app.py. I am getting this error message: 'python3' is not recognized as an internal or external command, operable program or batch file. Is there any specific cause about why the ...

Finding the average of an array using JS

I've been looking and haven't found a simple question and answer on stack overflow looking into finding the average of an array. This is the array that I have var grades = [80, 77, 88, 95, 68]; I first thought that the answer to this problem wou...

Call javascript from MVC controller action

Can I call javascript function from MVC controller action (not from view page) and get return value? How? I need to make request to server from code (.cs) using javascript like here (but this is aspx page) function getInitData() { var code; code...

Count the number of times a string appears within a string

I simply have a string that looks something like this: "7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false" All I want to do is to count how many times the string "true" appears in that string. I'm feeling like the answer is someth...

SQL Server 2008 R2 Express permissions -- cannot create database or modify users

Recently just upgraded to SQL Server 2008 R2 Express. When I attempt to create a database after logging in using Windows Authentication with my id myuser I receive this error: An exception occurred while executing a Transact-SQL statement or batc...

Loading DLLs at runtime in C#

I am trying to figure out how you could go about importing and using a .dll at runtime inside a C# application. Using Assembly.LoadFile() I have managed to get my program to load the dll (this part is definitely working as I am able to get the name o...

PowerShell The term is not recognized as cmdlet function script file or operable program

I am implementing a script in powershell and getting the below error. The sceen shot is there exactly what I entered and the resulting error. At this path there is file Get-NetworkStatistics.ps1 which I got from here. I am following the steps from ...

Is it possible to dynamically compile and execute C# code fragments?

I was wondering if it is possible to save C# code fragments to a text file (or any input stream), and then execute those dynamically? Assuming what is provided to me would compile fine within any Main() block, is it possible to compile and/or execute...

Video streaming over websockets using JavaScript

What is the fastest way to stream live video using JavaScript? Is WebSockets over TCP a fast enough protocol to stream a video of, say, 30fps?...

setTimeout / clearTimeout problems

I try to make a page to go to the startpage after eg. 10sec of inactivity (user not clicking anywhere). I use jQuery for the rest but the set/clear in my test function are pure javascript. In my frustation I ended up with something like this functio...

Tomcat manager/html is not available?

Hi I just installed Tomcat and and am trying to get it up and running however whenever I try to navigate to manager/html it gives me this error "The requested resource (/manager/html) is not available". The homepage, /docs, /examples all work fine ...

What is a "method" in Python?

Can anyone, please, explain to me in very simple terms what a "method" is in Python? The thing is in many Python tutorials for beginners this word is used in such way as if the beginner already knew what a method is in the context of Python. While I...

MIN and MAX in C

Where are MIN and MAX defined in C, if at all? What is the best way to implement these, as generically and type safely as possible? (Compiler extensions/builtins for mainstream compilers preferred.)...

No appenders could be found for logger(log4j)?

I have put log4j to my buildpath, but I get the following message when I run my application: log4j:WARN No appenders could be found for logger (dao.hsqlmanager). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.a...

How to use a dot "." to access members of dictionary?

How do I make Python dictionary members accessible via a dot "."? For example, instead of writing mydict['val'], I'd like to write mydict.val. Also I'd like to access nested dicts this way. For example mydict.mydict2.val would refer to mydict...

Converting Integers to Roman Numerals - Java

This is a homework assignment I am having trouble with. I need to make an integer to Roman Numeral converter using a method. Later, I must then use the program to write out 1 to 3999 in Roman numerals, so hardcoding is out. My code below is very bar...

COPY with docker but with exclusion

In a Dockerfile, I have COPY . . I want to exclude an entire directory, in my case, node_modules directory. Something like this: COPY [all but **/node_modules/**] . Is this possible with Docker?...

File Not Found when running PHP with Nginx

Recently I installed the latest version of Nginx and looks like I'm having hard time running PHP with it. Here is the configuration file I'm using for the domain: server { listen 80; server_name localhost; location / { root /usr/share...

How do I import a .bak file into Microsoft SQL Server 2012?

Been Googling this for awhile and no answer....can anyone help?...

How to do a https request with bad certificate?

Say I want to get https://golang.org programatically. Currently golang.org (ssl) has a bad certificate which is issued to *.appspot.com So when I run this: package main import ( "log" "net/http" ) func main() { _, err := http.Get("http...

OPENSSL file_get_contents(): Failed to enable crypto

I'm building a personal stock platform (not distributed). A component I would like to have is the EPS graph on this page: https://eresearch.fidelity.com/eresearch/evaluate/fundamentals/earnings.jhtml?stockspage=earnings&symbols=AAPL&showPric...

Iterating through a golang map

I have a map of type: map[string]interface{} And finally, I get to create something like (after deserializing from a yml file using goyaml) mymap = map[foo:map[first: 1] boo: map[second: 2]] How can I iterate through this map? I tried the followi...

bash: pip: command not found

I downloaded pip and ran python setup.py install and everything worked just fine. The very next step in the tutorial is to run pip install <lib you want> but before it even tries to find anything online I get an error "bash: pip: command not fo...

C++ convert hex string to signed integer

I want to convert a hex string to a 32 bit signed integer in C++. So, for example, I have the hex string "fffefffe". The binary representation of this is 11111111111111101111111111111110. The signed integer representation of this is: -65538. ...

How to copy and paste code without rich text formatting?

I used to often find myself coping a piece of code from a website/Word document etc only to discover that when doing Paste I would end up with the desired code plus some extra HTML tags/text, basically extra formatting information. To get rid of tha...

Log4j2 configuration - No log4j2 configuration file found

Lately I decided to learn how to use the log4j2 logger. I downloaded required jar files, created library, xml comfiguration file and tried to use it. Unfortunately i get this statement in console (Eclipse) : ERROR StatusLogger No log4j2 configurati...

using statement with multiple variables

Is it possible to make this code a little more compact by somehow declaring the 2 variable inside the same using block? using (var sr = new StringReader(content)) { using (var xtr = new XmlTextReader(sr)) { obj = XmlSerializer.Deseri...

How are echo and print different in PHP?

Possible Duplicate: Reference: Comparing PHP's print and echo Is there any major and fundamental difference between these two functions in PHP?...

PHP syntax question: What does the question mark and colon mean?

Possible Duplicate: quick php syntax question return $add_review ? FALSE : $arg; What do question mark and colon mean? Thanks...

What happened to console.log in IE8?

According to this post it was in the beta, but it's not in the release?...

IndexError: index 1 is out of bounds for axis 0 with size 1/ForwardEuler

I am numerically solving for x(t) for a system of first order differential equations. The system is: dy/dt=(C)\*[(-K\*x)+M*A] I have implemented the Forward Euler method to solve this problem as follows: Here is my code: import matplotlib import n...

Numpy array dimensions

I'm currently trying to learn Numpy and Python. Given the following array: import numpy as np a = np.array([[1,2],[1,2]]) Is there a function that returns the dimensions of a (e.g.a is a 2 by 2 array)? size() returns 4 and that doesn't help very ...

No Such Element Exception?

So here is my code: public static void getArmor(String treasure) throws FileNotFoundException{ Random rand=new Random(); Scanner file=new Scanner(new File ("armor.txt")); while(!file.next().equals(treasure)){ file.next(); //s...

Visual Studio keyboard shortcut to automatically add the needed 'using' statement

What is the keyboard shortcut to expand the little red line that gives you the menu where you can choose to have the necessary using statement added to the top of the file?...

How to select/get drop down option in Selenium 2

I am converting my selenium 1 code to selenium 2 and can't find any easy way to select a label in a drop down menu or get the selected value of a drop down. Do you know how to do that in Selenium 2? Here are two statements that work in Selenium 1 bu...

HTML button to NOT submit form

I have a form. Outside that form, I have a button. A simple button, like this: <button>My Button</button> Nevertheless, when I click it, it submits the form. Here's the code: <form id="myform"> <input /> </form> ...

How to permanently add a private key with ssh-add on Ubuntu?

I have a private key protected with a password to access a server via SSH. I have 2 linux (ubuntu 10.04) machines and the behavior of ssh-add command is different in both of them. In one machine, once I use "ssh-add .ssh/identity" and entered my ...

How do I tell Python to convert integers into words

I'm trying to tell Python to convert integers into words. Example: (using the song 99 bottles of beer on the wall) I used this code to write the program: for i in range(99,0,-1): print i, "Bottles of beer on the wall," print i, "bottles of...

Adding Google Play services version to your app's manifest?

I'm following this tutorial: https://developers.google.com/maps/documentation/android/start#overview on how to add Google Maps to an app within the Android SDK. The only problem I seem to be having is during this bit (I've done everything else wit...

Is it a good idea to index datetime field in mysql?

I am working on designing a large database. In my application I will have many rows for example I currently have one table with 4 million records. Most of my queries use datetime clause to select data. Is it a good idea to index datetime fields in my...

How to install a gem or update RubyGems if it fails with a permissions error

I'm trying to install a gem using gem install mygem or update RubyGems using gem update --system, and it fails with this error: ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2....

Getting the textarea value of a ckeditor textarea with javascript

I'm a learner as far as JS goes and although I've spent a good few hours reading through tutorials which has helped lots but I'm still having problems figuring out exactly how I find out what a user is typing into a ckeditor textarea. What I'm tryin...

Save byte array to file

I have a byte array (an IEnumerable actually), and I need to save it to a new file containing this data. How do I do that? I found some answers telling how to create a MemoryStream from that, but still can't save it to a brand new file....

LaTeX: Prevent line break in a span of text

How can I prevent LaTeX from inserting linebreaks in my \texttt{...} or \url{...} text regions? There's no spaces inside I can replace with ~, it's just breaking on symbols. Update: I don't want to cause line overflows, I'd just rather LaTeX insert...

Python module for converting PDF to text

Is there any python module to convert PDF files into text? I tried one piece of code found in Activestate which uses pypdf but the text generated had no space between and was of no use. ...

How to use TLS 1.2 in Java 6

It seems that Java 6 supports TLS up to v1.0, is there any way to use TLS 1.2 in Java 6? Maybe a patch or a particular update of Java 6 will have support for it?...

How do I join two lines in vi?

I have two lines in a text file like below: S<Switch_ID>_F<File type> _ID<ID number>_T<date+time>_O<Original File name>.DAT I want to append the two lines in vi like below: S<Switch_ID>_F<File type>_ID<...

WITH (NOLOCK) vs SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

Could someone give me some guidance on when I should use WITH (NOLOCK) as opposed to SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED What are the pros/cons of each? Are there any unintended consequences you've run into using one as opposed to the ...

How to make String.Contains case insensitive?

How can I make the following case insensitive? myString1.Contains("AbC") ...

Sticky and NON-Sticky sessions

I want to know the difference between sticky- and non-sticky sessions. What I understood after reading from internet: Sticky : only single session object will be there. Non-sticky session : session object for each server node...

Exact time measurement for performance testing

What is the most exact way of seeing how long something, for example a method call, took in code? The easiest and quickest I would guess is this: DateTime start = DateTime.Now; { // Do some work } TimeSpan timeItTook = DateTime.Now - start; B...

How to use google maps without api key

Hi i am using this code to use get-directions in google maps. but when i run this from other machines it is showing the error invalid api key. how to use this same map without an api key. <script src="http://maps.google.com/maps?file=api&amp;...

Understanding the basics of Git and GitHub

I don't fully understand the purpose of using Git or Github; I know it helps to keep track of your changes and it's helpful for people collaborating with other people, but I don't collaborate with anybody so I don't know if this would be helpful for ...

How do I keep CSS floats in one line?

I want to have two items on the same line using float: left for the item on the left. I have no problems achieving this alone. The problem is, I want the two items to stay on the same line even when you resize the browser very small. You know... lik...

Calculate size of Object in Java

I want to record how much memory (in bytes, hopefully) an object takes up for a project (I'm comparing sizes of data structures) and it seems like there is no method to do this in Java. Supposedly, C/C++ has sizeOf() method, but this is nonexistant i...

How to edit Docker container files from the host?

Now that I found a way to expose host files to the container (-v option) I would like to do kind of the opposite: How can I edit files from a running container with a host editor? sshfs could probably do the job but since a running container is al...

Uninstalling an MSI file from the command line without using msiexec

msiexec is command prompt software that installs an MSI program. But I have found that you can install an MSI file from the command line by just typing in the name of the MSI file on the command line. But in order to uninstall the MSI file, it seems...

Running Java Program from Command Line Linux

I am not very experience with java and this is driving me crazy. I wrote a java program FileManagement and I need to run it from the command line. I can compile it from the command line with javac FileManagement/*.java which will create all the clas...

Sending simple message body + file attachment using Linux Mailx

I am writing a shell script to send an email using Linux Mailx, the email must contain a file attachment and a message body. Currently sending an email with an attachment: output.txt | mail -s "Daily Monitoring" [email protected] I wish to add a mes...

SQL: How to get the count of each distinct value in a column?

I have a SQL table called "posts" that looks like this: id | category ----------------------- 1 | 3 2 | 1 3 | 4 4 | 2 5 | 1 6 | 1 7 | 2 Each category number corresponds to a category. How would I go about counting the number of times each c...

What is the meaning of the term "thread-safe"?

Does it mean that two threads can't change the underlying data simultaneously? Or does it mean that the given code segment will run with predictable results when multiple threads are executing that code segment?...

How to use WHERE IN with Doctrine 2

I have the following code which gives me the error: Message: Invalid parameter number: number of bound variables does not match number of tokens Code: public function getCount($ids, $outcome) { if (!is_array($ids)) { $ids = array($id...

Is there a query language for JSON?

Is there a (roughly) SQL or XQuery-like language for querying JSON? I'm thinking of very small datasets that map nicely to JSON where it would be nice to easily answer queries such as "what are all the values of X where Y > 3" or to do the usual SUM...

How to open an existing project in Eclipse?

I have just created several project using Eclipse. Now restart Eclipse and want to see one of the projects. How can I do it? I have tried File -> Import -> General -> Existing Project into Workspace. Then I select the directory of the project that ...

how to download file in react js

I receive file url as response from api. when user clicks on download button, the file should be downloaded without opening file preview in a new tab. How to achieve this in react js? ...

Why won't eclipse switch the compiler to Java 8?

I checked out a Java project from SVN in eclipse and realized that it requires Java 8 because it uses lambdas etc. I installed the eclipse addon for Java 8 and restarted eclipse and and have the project set up like so: I noticed that near the bot...

Current date and time as string

I wrote a function to get a current date and time in format: DD-MM-YYYY HH:MM:SS. It works but let's say, its pretty ugly. How can I do exactly the same thing but simpler? string currentDateToString() { time_t now = time(0); tm *ltm = localt...

What are the possible values of the Hibernate hbm2ddl.auto configuration and what do they do

I really want to know more about the update, export and the values that could be given to hibernate.hbm2ddl.auto I need to know when to use the update and when not? And what is the alternative? These are changes that could happen over DB: new tabl...

Image comparison - fast algorithm

I'm looking to create a base table of images and then compare any new images against that to determine if the new image is an exact (or close) duplicate of the base. For example: if you want to reduce storage of the same image 100's of times, you co...

MVC4 DataType.Date EditorFor won't display date value in Chrome, fine in Internet Explorer

I'm using the DataType.Date attribute on my model and an EditorFor in my view. This is working fine in Internet Explorer 8 and Internet Explorer 9, but in Google Chrome it is showing a date picker and instead of displaying the val...

Eclipse : Maven search dependencies doesn't work

I created a new simple Maven project in a new Workspace. When I open the pom.xml's Dependencies view in Eclipse editor, and I choose Add.. dependency, there's no search results no matter what search criteria I input in the search fields: It instan...

How do you configure HttpOnly cookies in tomcat / java webapps?

After reading Jeff's blog post on Protecting Your Cookies: HttpOnly. I'd like to implement HttpOnly cookies in my web application. How do you tell tomcat to use http only cookies for sessions?...

Format an Integer using Java String Format

I am wondering if it is possible, using the String.format method in Java, to give an integer preceding zeros? For example: 1 would become 001 2 would become 002 ... 11 would become 011 12 would become 012 ... 526 would remain as 526 ...etc At the ...

How can I switch themes in Visual Studio 2012

The Visual Studio 2012 offers two themes, Light and Dark. I want to switch the theme to Dark, but I'm not able to find any menus or options to do that. I found out a way importing settings from: Microsoft Visual Studio 11.0\Common7\IDE\ FontsAndCol...

What is the proper way to URL encode Unicode characters?

I know of the non-standard %uxxxx scheme but that doesn't seem like a wise choice since the scheme has been rejected by the W3C. Some interesting examples: The heart character. If I type this into my browser: http://www.google.com/search?q=? The...

laravel Eloquent ORM delete() method

Hi I am studying laravel. I use Eloquent ORM delete method but I get a different result.Not true or false but null. I set an resource route and there is a destroy method in UsersController. public function destroy($id){ $res=User::find($id)->d...

Prompt Dialog in Windows Forms

I am using System.Windows.Forms but strangely enough don't have the ability to create them. How can I get something like a javascript prompt dialog, without javascript? MessageBox is nice, but there is no way for the user to enter an input. I want...

Angular 4 checkbox change value

how could you achieve in Angular 4 that when you register in a checkbox save an "A" or "B" value. As much as I try, he is only sending me true or false, I hope someone can help me. registry.component.ts this.userForm = new FormG...

How to get DataGridView cell value in messagebox?

How can I get DataGridView cell value to be written in the MessageBox in C#?...

Connection refused on docker container

I'm new to Docker and trying to make a demo Rails app. I made a dockerfile that looks like this: FROM ruby:2.2 MAINTAINER [email protected] # Install apt based dependencies required to run Rails as # well as RubyGems. As the Ruby image itself is...

Cannot find vcvarsall.bat when running a Python script

I am working on Vista, and using Python 2.6.4. I am using a software that utilizes a Python script, but bumped into the message: cannot find vcvarsall.bat So, I installed visual c++ 2010. Still the file is not found - though, it is there. My guess...

How do you comment out code in PowerShell?

How do you comment out code in PowerShell (1.0 or 2.0)?...

How do I automatically play a Youtube video (IFrame API) muted?

<iframe class="youtube-player" type="text/html" src="http://www.youtube.com/embed/JW5meKfy3fY?wmode=opaque&autohide=1&autoplay=1&volume=0&vol=0&mute=1" frameborder="0">&lt;br /&gt;</iframe> The video isn't mu...

What does int argc, char *argv[] mean?

In many C++ IDE's and compilers, when it generates the main function for you, it looks like this: int main(int argc, char *argv[]) When I code C++ without an IDE, just with a command line compiler, I type: int main() without any parameters. Wh...

How to compile C program on command line using MinGW?

What command does one have to enter at the command line in Windows 7 to compile a basic C program? Like I am literally wondering what you type in the command prompt, to compile a .c file. I tried: > gcc foo.c But it says: 'gcc' is not recog...

Spring JSON request getting 406 (not Acceptable)

this is my javascript: function getWeather() { $.getJSON('getTemperature/' + $('.data option:selected').val(), null, function(data) { alert('Success'); }); } this is my controller:...

How to force an entire layout View refresh?

I want to force the main layout resource view to redraw / refresh, in say the Activity.onResume() method. How can I do this ? By main layout view, I mean the one ('R.layout.mainscreen' below) that is called in my Activity.onCreate(), like this:- p...

Select Top and Last rows in a table (SQL server)

I'm using this statement in SQLServer and it works fine: SELECT TOP 1000 * FROM [SomeTable] It gives me the TOP 1000 records from SomeTable, now which keyword should I use instead of Top if I need the Bottom 1000 records from the table?...

Open URL in Java to get the content

I´m searching for a opportunity to open a url in java. URL url = new URL("http://maps.google.at/maps?saddr=4714&daddr=Marchtrenk&hl=de"); InputStream is = url.openConnection().getInputStream(); BufferedReader reader = new BufferedR...

Get current URL/URI without some of $_GET variables

How, in Yii, to get the current page's URL. For example: http://www.yoursite.com/your_yii_application/?lg=pl&id=15 but excluding the $GET_['lg'] (without parsing the string manually)? I mean, I'm looking for something similar to the Yii::app(...

Angular: Cannot find a differ supporting object '[object Object]'

Im following this tutorial. On the way to get list of users from api.github Im getting error: Cannot find a differ supporting object '[object Object]' I think its related to <ul> <li *ngFor = "#user of users"> {{user | json}}...

Attaching click event to a JQuery object not yet added to the DOM

I've been having a lot of trouble attaching the click event to a JQuery object before adding it to the DOM. Basically I have this button that my function returns, then I append it to the DOM. What I want is to return the button with its own click ha...

Convert HashBytes to VarChar

I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command: SELECT HashBytes('MD5', 'HelloWorld') However, this returns a VarBinary instead of a VarChar value. If I attempt to convert 0x68E109F0F40CA72A15...

How does autowiring work in Spring?

I'm a little confused as to how the inversion of control (IoC) works in Spring. Say I have a service class called UserServiceImpl that implements UserService interface. How would this be @Autowired? And in my Controllers, how would I instantiate a...

Convert integer into its character equivalent, where 0 => a, 1 => b, etc

I want to convert an integer into its character equivalent based on the alphabet. For example: 0 => a 1 => b 2 => c 3 => d etc. I could build an array and just look it up when I need it but I’m wondering if there’s a built in funct...

Android WebView Cookie Problem

I have a server that sends my android app a session cookie to be used for authenticated communication. I am trying to load a WebView with a URL pointing to that same server and I'm trying to pass in the session cookie for authentication. I am ob...

Show div #id on click with jQuery

When a div is clicked, I want different div to appear. Thus, when '#music' is clicked, I want '#musicinfo' to appear. Here is the css: #music { float:left; height:25px; margin-left:25px; margin-top:25px; margin-right:80px; ...

How to Change color of Button in Android when Clicked?

I am working on Android Application. I want to have 4 buttons to be placed horizontally at the bottom of the screen. In these 4 buttons 2 buttons are having images on them. The border of the buttons should be black color and the border should be as t...

Using SUMIFS with multiple AND OR conditions

I would like to create a succinct Excel formula that SUMS a column based on a set of AND conditions, plus a set of OR conditions. My Excel table contains the following data and I used defined names for the columns. Quote_Value (Worksheet!$A:$A) ho...

Managing jQuery plugin dependency in webpack

I'm using Webpack in my application, in which I create two entry points - bundle.js for all my JavaScript files/codes, and vendors.js for all libraries like jQuery and React. What do I do in order to use plugins which have jQuery as their dependencie...

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/...

Executing JavaScript after X seconds

I am building a interstitial page, using <div> and JavaScript, really simple script but neat. Everything is working, but I also would like to close the div's after a few seconds (like 10 seconds, for example). Here what I have so far: I have tw...

Format y axis as percent

I have an existing plot that was created with pandas like this: df['myvar'].plot(kind='bar') The y axis is format as float and I want to change the y axis to percentages. All of the solutions I found use ax.xyz syntax and I can only place code be...

Get folder name from full file path

How do I get the folder name from the full path of the application? This is the file path below, c:\projects\root\wsdlproj\devlop\beta2\text Here "text" is the folder name. How can I get that folder name from this path?...

Submit form without page reloading

I have a classifieds website, and on the page where ads are showed, I am creating a "Send a tip to a friend" form... So anybody who wants can send a tip of the ad to some friends email-adress. I am guessing the form must be submitted to a php page ...

jQuery check if attr = value

I seem to be having trouble with my code. I need to say: if ( $('html').attr('lang').val() == 'fr-FR' ) { // do this } else { // do that } When I check the console, I just get an error telling me this isn't a function. Help would be apprec...

How to frame two for loops in list comprehension python

I have two lists as below tags = [u'man', u'you', u'are', u'awesome'] entries = [[u'man', u'thats'],[ u'right',u'awesome']] I want to extract entries from entries when they are in tags: result = [] for tag in tags: for entry in entries: ...

Jenkins could not run git

I've installed Jenkins on my mac (osx lion). But I couldn't get it work. This is the stacktrace I've got: Started by user anonymous Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847 Using st...

Add a scrollbar to a <textarea>

I would like to add a scrollbar to a textarea, so that it always appears, even when there is nothing to scroll down to. If there is nothing for it to scroll down to, I would prefer if it could be greyed out, indicating that there is nothing below. H...

Does a valid XML file require an XML declaration?

I am parsing an XML file using Sax Parser of Xerces. Is the XML declaration <?xml version="1.0" encoding="UTF-8"?> required?...

https with WCF error: "Could not find base address that matches scheme https"

I go to https://mywebsite/MyApp/Myservice.svc and get the following error: (The link works if I use http:// ) "The service '/MyApp/MyService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not find ...

how to use concatenate a fixed string and a variable in Python

I want to include file name 'main.txt' in the subject for that I am passing file name from command line. but getting error in doing so python sample.py main.txt #running python with argument msg['Subject'] = "Auto Hella Restart Report "sys.argv[1...

Convert a matrix to a 1 dimensional array

I have a matrix (32X48). How can I convert the matrix into a single dimensional array?...

Is there a version of JavaScript's String.indexOf() that allows for regular expressions?

In javascript, is there an equivalent of String.indexOf() that takes a regular expression instead of a string for the first first parameter while still allowing a second parameter ? I need to do something like str.indexOf(/[abc]/ , i); and str....

Amazon S3 and Cloudfront cache, how to clear cache or synchronize their cache

I have a cron job that runs every 10 minutes and updates the content-type and x-amz-meta. But since yesterday it seems like after the cron job run, Amazon is not picking up the changes made (refreshing his cache). I even went and made the changes ma...

How to capture a JFrame's close button click event?

I want to call a method confirmExit() when the red close button of the title bar of a JFrame is clicked. How can I capture that event? I'd also like to prevent the window from closing if the user chooses not to proceed....

create table with sequence.nextval in oracle

i created a sequence using the following query, create sequence qname_id_seq start with 1 increment by 1 nocache; Now when i try to create a table which uses the above sequence, it is throwing the following error, Error report: SQL Error: ORA-009...

Are HTTPS URLs encrypted?

Are all URLs encrypted when using TLS/SSL (HTTPS) encryption? I would like to know because I want all URL data to be hidden when using TLS/SSL (HTTPS). If TLS/SSL gives you total URL encryption then I don't have to worry about hiding confidential in...

PostgreSQL unnest() with element number

When I have a column with separated values, I can use the unnest() function: myTable id | elements ---+------------ 1 |ab,cd,efg,hi 2 |jk,lm,no,pq 3 |rstuv,wxyz select id, unnest(string_to_array(elements, ',')) AS elem from myTable id | elem --...

How to zero pad a sequence of integers in bash so that all have the same width?

I need to loop some values, for i in $(seq $first $last) do does something here done For $first and $last, i need it to be of fixed length 5. So if the input is 1, i need to add zeros in front such that it becomes 00001. It loops till 99999 fo...

How can I replace newlines using PowerShell?

Given test.txt containing: test message I want to end up with: testing a message I think the following should work, but it doesn't: Get-Content test.txt |% {$_-replace "t`r`n", "ting`r`na "} How can I do a find and replace where what I'm fin...

C# string does not contain possible?

This is what I have going on. I have a crawler that reads html, and i'm looking to know when it does not contain two strings. For example. string firstString = "pineapple" string secondString = "mango" string compareString = "The wheels on the bu...

Sending SOAP request using Python Requests

Is it possible to use Python's requests library to send a SOAP request?...

Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x197870>

I read SO about another user encountering similar error, but this error is in different case. I received this message when I added a View Controller initially: Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x1978...

Code for printf function in C

Possible Duplicate: source code of c/c++ functions I was wondering where I can find the C code that's used so that when I write printf("Hello World!"); in my C programm to know that it has to print that string to STDOUT. I looked in <st...

How to evaluate a boolean variable in an if block in bash?

I have defined the following variable: myVar=true now I'd like to run something along the lines of this: if [ myVar ] then echo "true" else echo "false" fi The above code does work, but if I try to set myVar=false it will still outp...

Remove empty strings from a list of strings

I want to remove all empty strings from a list of strings in python. My idea looks like this: while '' in str_list: str_list.remove('') Is there any more pythonic way to do this?...

Passing an Object from an Activity to a Fragment

I have an Activity which uses a Fragment. I simply want to pass an object from this Activity to the Fragment. How could I do it? All the tutorials I've seen so far where retrieving data from resources. EDIT : Let's be a bit more precise: My Activ...

List of lists into numpy array

How do I convert a simple list of lists into a numpy array? The rows are individual sublists and each row contains the elements in the sublist....

What is a PDB file?

What is a PDB file and how can I exclude it from the release folder when I rebuild my solution?...

How do I properly set the permgen size?

I have this VM with tomcat, java, and grails in it. I've been getting permgen errors so I looked around and found the solution: set JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m" I use SSH to access the vm and type the argum...

Facebook share link - can you customize the message body text?

I'm trying to create a link that will share a page on Facebook. So far I've got: href="http://www.facebook.com/sharer.php ?u=http%3A%2F%2Fwww.cnn.com%2F &t=CNN%26s+website" However, I'd really like to add some text that will go in the 'What's...

PHP prepend leading zero before single digit number, on-the-fly

PHP - Is there a quick, on-the-fly method to test for a single character string, then prepend a leading zero? Example: $year = 11; $month = 4; $stamp = $year.add_single_zero_if_needed($month); // Imaginary function echo $stamp; // 1104 ...

Source file not compiled Dev C++

I just installed Dev C++ and I am learning C programming. the code i used was #include <stdio.h> int main() { printf("Hello world"); getch(); } I saved it as a .c file. When I compile it works fine, but when I compile and run it say...

node.js: read a text file into an array. (Each line an item in the array.)

I would like to read a very, very large file into a JavaScript array in node.js. So, if the file is like this: first line two three ... ... I would have the array: ['first line','two','three', ... , ... ] The function would look like this: ...

Find and extract a number from a string

I have a requirement to find and extract a number contained within a string. For example, from these strings: string test = "1 test" string test1 = " 1 test" string test2 = "test 99" How can I do this?...

Managing SSH keys within Jenkins for Git

I'm trying to get Jenkins up and running with a GitHub hosted repository (using the Jenkins Git plugin). The repository has multiple git submodules, so I'm not sure I want to try and manage multiple deploy keys. My personal GitHub user account is a ...

How to maximize a plt.show() window using Python

Just for curiosity I would like to know how to do this in the code below. I have been searching for an answer but is useless. import numpy as np import matplotlib.pyplot as plt data=np.random.exponential(scale=180, size=10000) print ('el valor medio...

Move all files except one

How can I move all files except one? I am looking for something like: 'mv ~/Linux/Old/!Tux.png ~/Linux/New/' where I move old stuff to new stuff -folder except Tux.png. !-sign represents a negation. Is there some tool for the job?...

Remove .php extension with .htaccess

Yes, I've read the Apache manual and searched here. For some reason I simply cannot get this to work. The closest I've come is having it remove the extension, but it points back to the root directory. I want this to just work in the directory that co...

How to implode array with key and value without foreach in PHP

Without foreach, how can I turn an array like this array("item1"=>"object1", "item2"=>"object2",......."item-n"=>"object-n"); to a string like this item1='object1', item2='object2',.... item-n='object-n' I thought about implode() alre...

What does `unsigned` in MySQL mean and when to use it?

What does "unsigned" mean in MySQL and when should I use it?...

Execute a command line binary with Node.js

I am in the process of porting a CLI library from Ruby over to Node.js. In my code I execute several third party binaries when necessary. I am not sure how best to accomplish this in Node. Here's an example in Ruby where I call PrinceXML to convert ...

Running AMP (apache mysql php) on Android

I currently work on an open source e-commerce platform (www.oscmax.com) and I am trying to work out if I can deploy an offline version that can run on an tablet. I was hoping to use an iPad but this has proved very difficult (impossible?) a) Does a...

Pass element ID to Javascript function

I have seen many threads related to my question title. Here is HTML Codes : <button id="button1" class="MetroBtn" onClick="myFunc(this.id);">Btn1</button> <button id="button2" class="MetroBtn" onClick="myFunc(this.id);">Btn2</b...

JavaScript URL Decode function

What's the best JavaScript URL decode utility? Encoding would be nice too and working well with jQuery is an added bonus....

How to set tbody height with overflow scroll

I am facing problem while setting tbody height width overflow scroll. <style> tbody{ height:50px;display:block;overflow:scroll } </style> <h3>Table B</h3> <table style="border: 1px solid r...

Change one value based on another value in pandas

I'm trying to reprogram my Stata code into Python for speed improvements, and I was pointed in the direction of PANDAS. I am, however, having a hard time wrapping my head around how to process the data. Let's say I want to iterate over all values i...

Pointer to a string in C?

char *ptrChar; I know that ptrChar is a pointer to char. What's the command for a pointer to string? Edit: If it's the same (ptr to char vs. ptr to string) — what does the variable definition below represent? char (*ptr)[N]; I'm confused....

Counting the number of option tags in a select tag in jQuery

How do I count the number of <option>s in a <select> DOM element using jQuery? <select data-attr="dropdown" id="input1"> <option value="Male" id="Male">Male</option> <option value="Female" id="Female">Fema...

Convert Xml to DataTable

I have an XML file I want to insert that in a Datatable. The format of the xml file is like below: <userid ID="37729"> <TestId ID="84" TimeRemaining="60" /> <QuestId ID="1"> <Answer1> </Answer1> <Answ...

How do I clear a C++ array?

How do I clear/empty a C++ array? Theres array::fill, but looks like its C++11 only? I am using VC++ 2010. How do I empty it (reset to all 0)? ...

outline on only one border

How to apply an inset border into an HTML element, but just only on one side of it. Until now, I've been using an image to do that (GIF/PNG) that I would then use as a background and stretch it (repeat-x) and position a little off from the top of my...

Git Pull While Ignoring Local Changes?

Is there a way to do a git pull that ignores any local file changes without blowing the directory away and having to perform a git clone?...

How to avoid mysql 'Deadlock found when trying to get lock; try restarting transaction'

I have a innoDB table which records online users. It gets updated on every page refresh by a user to keep track of which pages they are on and their last access date to the site. I then have a cron that runs every 15 minutes to DELETE old records. I...

How to force a view refresh without having it trigger automatically from an observable?

Note: this is mostly for debugging and understanding KnockoutJS. Is there a way to explicitly request Knockout to refresh the view from (already bound) view model? I am looking for something like: ko.refreshView(); I understand that this is not ...

Why aren't python nested functions called closures?

I have seen and used nested functions in Python, and they match the definition of a closure. So why are they called nested functions instead of closures? Are nested functions not closures because they are not used by the external world? UPDATE: I ...

How to open a new form from another form

I have form which is opened using ShowDialog Method. In this form i have a Button called More. If we click on More it should open another form and it should close the current form. on More Button's Click event Handler i have written the following co...

How to vertically align text with icon font?

I have a very basic HTML which mix plain text and icon fonts. The problem is that icons are not exactly rendered at the same height than the text: _x000D_ _x000D_ <div class="ui menu">_x000D_ <a href="t" class="item"><i class="large...

Converting Float to Dollars and Cents

First of all, I have tried this post (among others): Currency formatting in Python. It has no affect on my variable. My best guess is that it is because I am using Python 3 and that was code for Python 2. (Unless I overlooked something, because I ...

What is the "__v" field in Mongoose

I'm using Mongoose version 3 with MongoDB version 2.2. I've noticed a __v field has started appearing in my MongoDB documents. Is it something to do with versioning? How is it used?...

Get DateTime.Now with milliseconds precision

How can I exactly construct a time stamp of actual time with milliseconds precision? I need something like 16.4.2013 9:48:00:123. Is this possible? I have an application, where I sample values 10 times per second, and I need to show them in a graph...

How do I do a case-insensitive string comparison?

How can I do case insensitive string comparison in Python? I would like to encapsulate comparison of a regular strings to a repository string using in a very simple and Pythonic way. I also would like to have ability to look up values in a dict hash...

How should I cast in VB.NET?

Are all of these equal? Under what circumstances should I choose each over the others? var.ToString() CStr(var) CType(var, String) DirectCast(var, String) EDIT: Suggestion from NotMyself… TryCast(var, String) ...

Recursive sub folder search and return files in a list python

I am working on a script to recursively go through subfolders in a mainfolder and build a list off a certain file type. I am having an issue with the script. Its currently set as follows for root, subFolder, files in os.walk(PATH): for item in f...

How to simulate a real mouse click using java?

I'm attempting to perform a mouse click in Java, to click something in an external program. To do this, I'm using java.awt.robot, and the following code: Robot bot = new Robot(); int mask = InputEvent.MOUSE_BUTTON1_DOWN; bot.mouseMove(x, y); ...

An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll

When I execute my code below, this error message occurs: "An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code Additional information: Incorrect syntax near '='. " And this...

How to search for an element in an stl list?

Is there a find() function for list as there was in vector? Is there a way to do that in list?...

Centering in CSS Grid

I'm trying to create a simple page with CSS Grid. What I'm failing to do is center the text from the HTML to the respective grid cells. I've tried placing content in separate divs both inside and outside of the left_bg and right_bg selectors and pl...

How can getContentResolver() be called in Android?

I want to know the context in which getContentResolver() is called? I have a scenario like this: I have an activity A that calls a method myFunc() of class B which is not an activity. So, in class B I have to use getContentResolver(). I directly cal...

How to programmatically set style attribute in a view

I'm getting a view from the XML with the code below: Button view = (Button) LayoutInflater.from(this).inflate(R.layout.section_button, null); I would like to set a "style" for the button how can I do that in java since a want to use several style...

How do a send an HTTPS request through a proxy in Java?

I am trying to send a request to a server using the HttpsUrlConnection class. The server has certificate issues, so I set up a TrustManager that trusts everything, as well as a hostname verifier that is equally lenient. This manager works just fine...

Find if a textbox is disabled or not using jquery

I need to find if a textbox is disabled or enabled using Jquery....

Ways to save enums in database

What is the best way to save enums into a database? I know Java provides name() and valueOf() methods to convert enum values into a String and back. But are there any other (flexible) options to store these values? Is there a smart way to make enum...

Shall we always use [unowned self] inside closure in Swift

In WWDC 2014 session 403 Intermediate Swift and transcript, there was the following slide The speaker said in that case, if we don't use [unowned self] there, it will be a memory leak. Does it mean we should always use [unowned self] inside closur...

Facebook Architecture

I have been scrounging for articles/info about the architecture at Facebook, the challenges & ways they tackle them. What they use & why they use. How do they scale & what are the design decisions for what they do etc. Main underpinning b...

How to trigger click event on href element

I am trying to trigger click event on hyperlink with jQuery like the way below. Hyperlink does not have any id but it does have cssclass $(document).ready(function () { $('.cssbuttongo').trigger('click'); }); The function above is not working. ...

How to detect the screen resolution with JavaScript?

Is there a way that works for all browsers?...

Convert negative data into positive data in SQL Server

The current data of the table is: a b --------- -1 5 -11 2 -5 32 My request is to convert every data into a positive value. Unfortunately, I forgot the name of the built-in function of SQL Server that enables to convert....

Android ADB doesn't see device

I'm trying to run my applications on OMEGA T107 tablet. But adb doesn't see my device. I tried almost everything....

Passing on command line arguments to runnable JAR

I built a runnable JAR from an Eclipse project that processes a given XML file and extracts the plain text. However, this version requires that the file be hard-coded in the code. Is there a way to do something like this java -jar wiki2txt enwiki-...

Most efficient way to reverse a numpy array

Believe it or not, after profiling my current code, the repetitive operation of numpy array reversion ate a giant chunk of the running time. What I have right now is the common view-based method: reversed_arr = arr[::-1] Is there any other way to ...

Execution order of events when pressing PrimeFaces p:commandButton

I am trying to execute a JSF2 bean method and show a dialog box after completion of the method on click of PrimeFaces <p:commandButton>. <p:commandButton id="viewButton" value="View" actionlistener="#{userBean.setResultsForSelectedRow}"...

How to install JRE 1.7 on Mac OS X and use it with Eclipse?

I want to use the JRE 1.7 that I downloaded from Oracle website. So I correctly install the .pkg file, and when I try /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version in the terminal I get this : java version "...

programming a servo thru a barometer

i have a script which gets the air pressure from a website. and i wrote this function which says if the pressure gets different value if it rains or sunny weather or else now i have a servo which should change the angle depending on each value. We...

Background images: how to fill whole div if image is small and vice versa

I have three problems: When I tried to use a background image in a smaller size div, the div shows only part of image. How can I show the full or a specific part of image? I have a smaller image and I want to use in a bigger div. But don't want to ...

x86 Assembly on a Mac

Does anyone know of any good tools (I'm looking for IDEs) to write assembly on the Mac. Xcode is a little cumbersome to me. Also, on the Intel Macs, can I use generic x86 asm? Or is there a modified instruction set? Any information about post Intel...

How do I reset a sequence in Oracle?

In PostgreSQL, I can do something like this: ALTER SEQUENCE serial RESTART WITH 0; Is there an Oracle equivalent?...

Python loop counter in a for loop

In my example code below, is the counter = 0 really required, or is there a better, more Python, way to get access to a loop counter? I saw a few PEPs related to loop counters, but they were either deferred or rejected (PEP 212 and PEP 281). This is...

Angular 2 two way binding using ngModel is not working

Can't bind to 'ngModel' since it isn't a know property of the 'input' element and there are no matching directives with a corresponding property Note: im using alpha.31 import { Component, View, bootstrap } from 'angular2/angular2' @Component({ ...

How to strip HTML tags with jQuery?

I want to remove HTML tags from a string. For example assume we have the string: <p> example ive got a string</P> How can I write a function that removes the <p><p> and returns just "example ive got a string"?...

Should I use "camel case" or underscores in python?

So which is better and why? def my_function(): or def myFunction(): ...

How to check if a table exists in a given schema

Postgres 8.4 and greater databases contain common tables in public schema and company specific tables in company schema. company schema names always start with 'company' and end with the company number. So there may be schemas like: public company1 ...

Open Jquery modal dialog on click event

The below code works fine for only the first click event. However for any subsequent click nothing happens. I tested this on firefox, ie7 but still the same. Am I missing something? <script type="text/javascript"> $(document).ready(function()...

Adding a new SQL column with a default value

I am looking for the syntax to add a column to a MySQL database with a default value of 0 Reference...

What is Options +FollowSymLinks?

I am using a Lamp server on my computer. I started to use Laravel php framework. In my .htaccess , If I use Options +FollowSymLinks , I get 500 error. And If I comment out , I have to use index.php in my all addresses ..example: /~ytsejam/blog/pu...

DISTINCT for only one column

Let's say I have the following query. SELECT ID, Email, ProductName, ProductModel FROM Products How can I modify it so that it returns no duplicate Emails? In other words, when several rows contain the same email, I want the results to include on...

Get values from label using jQuery

I want to get month and year value from label. How can i get these using jquery? <label year="2010" month="6" id="current Month"> June &nbsp;2010</label> ...

How to post object and List using postman

I am using postman packaged app to send a post request. I want to request the following controller. How to send a post requestbody using postman object(with values) and a list using the raw format? @RequestMapping(value = "register", method = ...

Hashmap with Streams in Java 8 Streams to collect value of Map

Let consider a hashmap Map<Integer, List> id1 = new HashMap<Integer,List>(); I inserted some values into both hashmap. For Example, List<String> list1 = new ArrayList<String>(); list1.add("r1"); list1.add("r4...

An "and" operator for an "if" statement in Bash

I'm trying to create a simple Bash script to check if the website is down and for some reason the "and" operator doesn't work: #!/usr/bin/env bash WEBSITE=domain.com SUBJECT="$WEBSITE DOWN!" EMAILID="[email protected]" STATUS=$(curl -sI $WEBSITE | awk '...

Batch files: How to read a file?

How you can read a file (text or binary) from a batch file? There is a way to read it in a binary mode or text mode?...

Is there more to an interface than having the correct methods

So lets say I have this interface: public interface IBox { public void setSize(int size); public int getSize(); public int getArea(); //...and so on } And I have a class that implements it: public class Rectangle implements IBox { p...

How to run a .awk file?

I am converting a CSV file into a table format, and I wrote an AWK script and saved it as my.awk. Here is the my script: #AWK for test awk -F , ' BEGIN { aa = 0; } { hdng = "fname,lname,salary,city"; l1 = length($...

How can I find script's directory?

Consider the following Python code: import os print os.getcwd() I use os.getcwd() to get the script file's directory location. When I run the script from the command line it gives me the correct path whereas when I run it from a script run by code...

Getting input values from text box

I'm trying to get the text from a text box. I have 2 input text boxes that are not in a form, and I'm trying to retrieve the value and store it in a variable. This code returns undefined in the alert box that pops up. <script> var us...

Android - how do I investigate an ANR?

Is there a way of finding out where my app threw an ANR (Application Not Responding). I took a look at the traces.txt file in /data and I see a trace for my application. This is what I see in the trace. DALVIK THREADS: "main" prio=5 tid=3 TIMED_WAIT...

Entity Framework Migrations renaming tables and columns

I renamed a a couple entities and their navigation properties and generated a new Migration in EF 5. As is usual with renames in EF migrations, by default it was going to drop objects and recreate them. That isn't what I wanted so I pretty much had t...

how to convert object into string in php

Possible Duplicate: PHP ToString() equivalent how to convert object into string in php Actually i am dealing with web service APIs.i want to use output of one API as a input for another API. when i am trying to do this i got error like th...

No plot window in matplotlib

I just installed matplotlib in Ubuntu 9.10 using the synaptic package system. However, when I try the following simple example >>> from pylab import plot; >>> plot([1,2,3],[1,2,3]) [<matplotlib.lines.Line2D object at 0x9aa78ec&...

Use getElementById on HTMLElement instead of HTMLDocument

I've been playing around with scraping data from web pages using VBS/VBA. If it were Javascript I'd be away as its easy, but it doesn't seem to be quite as straight forward in VBS/VBA. This is an example I made for an answer, it works but I had pla...

Returning http status code from Web Api controller

I'm trying to return a status code of 304 not modified for a GET method in a web api controller. The only way I succeeded was something like this: public class TryController : ApiController { public User GetUser(int userId, DateTime lastM...

How to make a simple rounded button in Storyboard?

I just started learning iOS development, cannot find how to make simple rounded button. I find resources for old versions. Do I need to set a custom background for a button? In Android, I would just use a 9 patch, but I know iOS does not have this ca...

Eclipse 3.5 Unable to install plugins

I really don't know what's going on with Eclipse 3.5 (3.5.0 or 3.5.1, same issues), but it's been now 2 days that I'm struggling with Eclipse to find a way to make the plugins installation work via the "Install New Software screen"!!! I have visited ...

Rails - How to use a Helper Inside a Controller

While I realize you are supposed to use a helper inside a view, I need a helper in my controller as I'm building a JSON object to return. It goes a little like this: def xxxxx @comments = Array.new @c_comments.each do |comment| @comments &...

How to submit form on change of dropdown list?

I am creating a page in JSP where I have a dropdown list and once the user selects a value he has to click on the go button and then the value is sent to the Servlet. </select> <input type="submit" name="GO" value="G...

How to delete a remote tag?

How do you delete a Git tag that has already been pushed?...

How to create a RelativeLayout programmatically with two buttons one on top of the other?

I'm adding two buttons to the UI, but they appear on top of one another. I want them to appear next to each other. What am I missing in this code? m_btnCrown = new ImageButton(this); m_btnCrown.setImageResource(R.drawable.king_crown_thumb); m_btnCro...

Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

Before anything, please note that I have found several similar questions on Stack Overflow and articles all over the web, but none of those helped me fix my issue: PG Error could not connect to server: Connection refused Is the server running on po...

Increasing Heap Size on Linux Machines

I work on Ubuntu desktop machine and I'd like to increase heap size for Java. The RAM is 16GB and the current Max Heap Size is 3GB I checked this post post Increasing Tomcat Heap Size Not much found about Ubuntu, so I tried this command: java -Xmx...

IntelliJ and Tomcat.. Howto..?

Using Netbeans, I develop sites with Tomcat as the local server to manage it. In Netbeans it was "Install, write hit Run and it works" How do I pull the same thing off in IntelliJ? I can't find step-by-step instructions for this....

Add content to a new open window

I don't know how to solve this issue, I've trying reading many post but no one answer to it. I need to open a new window with a page already coded (inside the same domain) and add some content. The problem is that if I use OpenWindow.write() the pa...

SyntaxError: Unexpected token function - Async Await Nodejs

I was experimenting on using Node version 6.2.1 with some of my code. Had plans to migrate most of the hyper-callback oriented codes to something that looks cleaner and maybe performs better. I have no clue why, the terminal throws up an error when ...

'Field required a bean of type that could not be found.' error spring restful API using mongodb

So I've been learning Spring in the couples of week, been following this tutorial Building a RESTful Web Service All was well until I tried to integrate it to mongodb. So I follow this tutorial. Accessing Data with MongoDB But my practice is part...

scrollTop animation without jquery

I'm trying to make an animated "scroll to top" effect without using jQuery. In jQuery, I usually use this code: $('#go-to-top').click(function(){ $('html,body').animate({ scrollTop: 0 }, 400); return false; }); How do I animate scro...