Examples On Programing Languages

Access HTTP response as string in Go

I'd like to parse the response of a web request, but I'm getting trouble accessing it as string. func main() { resp, err := http.Get("http://google.hu/") if err != nil { // handle error } defer resp.Body.Close() body, er...

C# how to wait for a webpage to finish loading before continuing

I'm trying to create a program to clone multiple bugs at a time through the web interface of our defect tracking system. How can I wait before a page is completely loaded before I continue? //This is pseudo code, but this should give you an idea of...

Extend contigency table with proportions (percentages)

I have a contingency table of counts, and I want to extend it with corresponding proportions of each group. Some sample data (tips data set from ggplot2 package): library(ggplot2) head(tips, 3) # total_bill tip sex smoker day time size # 1 ...

Trying to get property of non-object in

on Control page: <?php include 'pages/db.php'; $results = mysql_query("SELECT * FROM sidemenu WHERE `menu_id`='".$menu."' ORDER BY `id` ASC LIMIT 1", $con); $sidemenus = mysql_fetch_object($results); ?> on View Page: <?php foreach...

How to use vim in the terminal?

How does one setup and start using vim in the terminal on OS X? I want to start writing my C code using vim in the terminal rather than a separate text editor. How does one get started on this? The basics like: opening, creating, saving files via t...

How to display the first few characters of a string in Python?

Hi I just started learning Python but I'm sort of stuck right now. I have hash.txt file containing thousands of malware hashes in MD5, Sha1 and Sha5 respectively separated by delimiters in each line. Below are 2 examples lines I extracted from the ...

Clear dropdownlist with JQuery

I wrote this little function to fill a drop down list with data from the server. function fillDropDown(url, dropdown) { $.ajax({ url: url, dataType: "json" }).done(function (data) { // Clear drop down list $(d...

Javascript array search and remove string?

I have: var array = new Array(); array.push("A"); array.push("B"); array.push("C"); I want to be able to do something like: array.remove("B"); but there is no remove function. How do I accomplish this?...

Command to list all files in a folder as well as sub-folders in windows

I tried searching for a command that could list all the file in a directory as well as subfolders using a command prompt command. I have read the help for "dir" command but coudn't find what I was looking for. Please help me what command could get th...

RuntimeError on windows trying python multiprocessing

I am trying my very first formal python program using Threading and Multiprocessing on a windows machine. I am unable to launch the processes though, with python giving the following message. The thing is, I am not launching my threads in the main mo...

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...

CSS last-child(-1)

I am looking for a css selector that lets me select the pre-last child of list. <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <!-- select the...

Which method performs better: .Any() vs .Count() > 0?

in the System.Linq namespace, we can now extend our IEnumerable's to have the Any() and Count() extension methods. I was told recently that if i want to check that a collection contains 1 or more items inside it, I should use the .Any() extension me...

conversion from infix to prefix

I am preparing for an exam where i couldn't understand the convertion of infix notation to polish notation for the below expression: (a–b)/c*(d + e – f / g) Can any one tell step by step how the given expression will be converted to prefix?...

Codeigniter $this->input->post() empty while $_POST is working correctly

On a codeigniter installation, I am trying to use the inbuilt $this->input->post('some_data') function, however $this->input->post() is an empty array. A print_r($_POST) gives all the variables fully and correctly? According to the code...

How to remove all listeners in an element?

I have a button, and I added some eventlistners to it: document.getElementById("btn").addEventListener("click", funcA, false); document.getElementById("btn").addEventListener("click", funcB, false); document.getElementById("btn").addEventListener("c...

Simple way to find if two different lists contain exactly the same elements?

What is the simplest way to find if two Lists contain exactly the same elements, in the standard Java libraries? It shouldn't matter if the two Lists are the same instance or not, and it shouldn't matter if the type parameter of the Lists are diffe...

How do I create a right click context menu in Java Swing?

I'm currently creating a right-click context menu by instantiating a new JMenu on right click and setting its location to that of the mouse's position... Is there a better way?...

How to get the real path of Java application at runtime?

I am creating a Java application where I am using log4j. I have given the absolute path of configuration log4j file and also an absolute path of generated log file(where this log file are generated). I can get the absolute path of a Java web applicat...

Cause of a process being a deadlock victim

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

Getting request URL in a servlet

I want to know the difference between the below two methods of getting a request URL in servlet. Method 1: String url = request.getRequestURL().toString(); Method 2: url = request.getScheme() + "://" + request.getServerName() +...

How to respond with HTTP 400 error in a Spring MVC @ResponseBody method returning String?

I'm using Spring MVC for a simple JSON API, with @ResponseBody based approach like the following. (I already have a service layer producing JSON directly.) @RequestMapping(value = "/matches/{matchId}", produces = "application/json") @ResponseBody pu...

Check play state of AVPlayer

Is there a way to know whether an AVPlayer playback has stalled or reached the end?...

Java AES encryption and decryption

I would like to encrypt and decrypt a password using 128 bit AES encryption with 16 byte key. I am getting javax.crypto.BadPaddingException error while decrypting the value. Am I missing anything while decrypting? public static void main(String ar...

Pure CSS checkbox image replacement

I've got a checkbox list in a table. (one of a number of CB's on the row) <tr><td><input type="checkbox" class="custom_image" value="1" id="CB1" /><label for='CB1'>&nbsp;</label></td></tr> <tr>&...

How to change target build on Android project?

I currently have an Android project in Eclipse. I created it with a target build of 1.5 (sdk 3). Now I want to change it so that it has a minSdk of 3 and targetSdk of 8. To do this I see that I must build against the newest SDK (2.2) To do this i...

Selectors in Objective-C?

First, I'm not sure I really understand what a selector is. From my understanding, it's the name of a method, and you can assign it to a class of type 'SEL' and then run methods such as respondToSelector to see if the receiver implements that metho...

Swift - How to convert String to Double

I'm trying to write a BMI program in swift language. And I got this problem: how to convert a String to a Double? In Objective-C, I can do like this: double myDouble = [myString doubleValue]; But how can I achieve this in Swift language?...

Could not reliably determine the server's fully qualified domain name

I have just installed Apache 2.2.17, and I am using it first time. Now when I try to start the server using the command service httpd start it gives me the message: httpd: Could not reliably determine the server's fully qualified domain name, u...

How can I perform an inspect element in Chrome on my Galaxy S3 Android device?

How can I perform an inspect element in Chrome on my Galaxy S3 Android device? I've tried a couple of guides online, one saying to use this android SDK thing to run adb forward tcp:9222 localabstract:chrome_devtools_remote, but all that says is "err...

The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'

I am trying to configure JSF+Spring+hibernate and I'm tying to run a test but when I use this "tx:annotation-driven" on my application-context.xml file, I get this error: The matching wildcard is strict, but no declaration can be found for eleme...

How to check if a string is a valid JSON string in JavaScript without using Try/Catch

Something like: var jsonString = '{ "Id": 1, "Name": "Coke" }'; //should be true IsJsonString(jsonString); //should be false IsJsonString("foo"); IsJsonString("<div>foo</div>") The solution should not contain try/catch. Some of us tu...

Correct way to override Equals() and GetHashCode()

I have never really done this before so i was hoping that someone could show me the correct what of implementing a override of Except() and GetHashCode() for my class. I'm trying to modify the class so that i can use the LINQ Except() method. publ...

Executing Batch File in C#

I'm trying to execute a batch file in C#, but I'm not getting any luck doing it. I've found multiple examples on the Internet doing it, but it is not working for me. public void ExecuteCommand(string command) { int ExitCode; ProcessStartInf...

Remove trailing zeros from decimal in SQL Server

I have a column DECIMAL(9,6) i.e. it supports values like 999,123456. But when I insert data like 123,4567 it becomes 123,456700 How to remove those zeros?...

alternative to "!is.null()" in R

my R code ends up containing plethora of statements of the form: if (!is.null(aVariable)) { do whatever } But this kind of statement is hard to read because it contains two negations. I would prefer something like: if (is.defined(aVariab...

MySQL - Rows to Columns

I tried to search posts, but I only found solutions for SQL Server/Access. I need a solution in MySQL (5.X). I have a table (called history) with 3 columns: hostid, itemname, itemvalue. If I do a select (select * from history), it will return +-...

How can I make a HTML a href hyperlink open a new window?

This is my code: <a href="http://www.google.com" onClick="window.location.href='http://www.yahoo.com';return false;" target="_blank">test</a> When you click it, it takes you to Yahoo but it does not open a new window?...

Python For loop get index

I am writing a simple Python for loop to prnt the current character in a string. However, I could not get the index of the character. Here is what I have, does anyone know a good way to get the current index of the character in the loop? loopme = '...

What is the benefit of zerofill in MySQL?

I just want to know what is the benefit/usage of defining ZEROFILL for INT DataType in MySQL? `id` INT UNSIGNED ZEROFILL NOT NULL ...

Best way to increase heap size in catalina.bat file

I have tomcat 6 server on windows xp ,And I start tomcat through console i.e. using startup.bat. AFAIK catalina.bat file is for windows so I am changing bat file for memory management.I don't have tomcat configuration window. Now I want to increase...

Use mysql_fetch_array() with foreach() instead of while()

i want to know how do we convert the following code to work with foreach $query_select = "SELECT * FROM shouts ORDER BY id DESC LIMIT 8;"; $result_select = mysql_query($query_select) or die(mysql_error()); while($row = mysql_fetch_array($...

Storing data into list with class

I have the following class: public class EmailData { public string FirstName{ set; get; } public string LastName { set; get; } public string Location{ set; get; } } I then did the following but was not working properly: List<EmailD...

Convert string to variable name in python

I have any string. like 'buffalo', x='buffalo' I want to convert this string to some variable name like, buffalo=4 not only this example, I want to convert any input string to some variable name. How should I do that (in python)?...

Cygwin - Makefile-error: recipe for target `main.o' failed

I am currently failing to write a good makefile and don't know the reason why.. -.- This is my main.c: #include <windows.h> #include <stdio.h> int main(int argc, char *argv[]) { printf("MEEEEEP"); return (0); } This is my mak...

How to refer to relative paths of resources when working with a code repository

We are working with a code repository which is deployed to both Windows and Linux - sometimes in different directories. How should one of the modules inside the project refer to one of the non-Python resources in the project (CSV files, etc.)? If ...

Connect to Amazon EC2 file directory using Filezilla and SFTP

I have created an AWS EC2 Instance and I want to be able to upload files to the server directory using FileZilla in the simplest and most straightforward fashion possible. ...

exception.getMessage() output with class name

I'm trying to fix an issue, in my application I have this code try { object1.method1(); } catch(Exception ex) { JOptionPane.showMessageDialog(nulll, "Error: "+ex.getMessage()); } and the object1 would do something like that: public void meth...

What is the difference between square brackets and parentheses in a regex?

Here is a regular expression I created to use in JavaScript: var reg_num = /^(7|8|9)\d{9}$/ Here is another one suggested by my team member. var reg_num = /^[7|8|9][\d]{9}$/ The rule is to validate a phone number: It should be of only ten num...

How can I clear console

As in the title. How can I clear console in C++?...

How to apply border radius in IE8 and below IE8 browsers?

I would like to know how to apply border-radius to IE8 and below IE8 browsers. I know that border-radius is a HTML5 feature and IE8 doesn't support it. I found that by using .htc we can achieve this but by using htc I am encountering the problem of...

numpy division with RuntimeWarning: invalid value encountered in double_scalars

I wrote the following script: import numpy d = numpy.array([[1089, 1093]]) e = numpy.array([[1000, 4443]]) answer = numpy.exp(-3 * d) answer1 = numpy.exp(-3 * e) res = answer.sum()/answer1.sum() print res But I got this result and with the error ...

How to process a file in PowerShell line-by-line as a stream

I'm working with some multi-gigabyte text files and want to do some stream processing on them using PowerShell. It's simple stuff, just parsing each line and pulling out some data, then storing it in a database. Unfortunately, get-content | %{ whate...

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...

Has anyone gotten HTML emails working with Twitter Bootstrap?

I'm using the premailer-rails3 gem which pulls styles inline for html emails, and I'm trying to get it working with Twitter bootstrap. https://github.com/fphilipe/premailer-rails3 It looks like some styles come in correctly, but not all of them. I...

REST API - Use the "Accept: application/json" HTTP Header

When I make a request, I get a response in XML, but what I need is JSON. In the doc it is stated in order to get a JSON in return: Use the Accept: application/json HTTP Header. Where do I find the HTTP Header to put Accept: application/json inside? ...

Which concurrent Queue implementation should I use in Java?

From the JavaDocs: A ConcurrentLinkedQueue is an appropriate choice when many threads will share access to a common collection. This queue does not permit null elements. ArrayBlockingQueue is a classic "bounded buffer", in which a fixed-sized array...

mysql delete under safe mode

I have a table instructor and I want to delete the records that have salary in a range An intuitive way is like this: delete from instructor where salary between 13000 and 15000; However, under safe mode, I cannot delete a record without providin...

How to assign a value to a TensorFlow variable?

I am trying to assign a new value to a tensorflow variable in python. import tensorflow as tf import numpy as np x = tf.Variable(0) init = tf.initialize_all_variables() sess = tf.InteractiveSession() sess.run(init) print(x.eval()) x.assign(1) pri...

How to replace all spaces in a string

I have two html text input, out of that what ever user type in first text box that need to reflect on second text box while reflecting it should replace all spaces to semicolon. I did to some extant and it replacing for first space not for all, I thi...

"error: assignment to expression with array type error" when I assign a struct field (C)

I'm a beginner C programmer, yesterday I learned the use of C structs and the possible application of these ones about the resolution of specific problems. However when I was experimenting with my C IDE (Codeblocks 16.01) in order to learn this aspec...

How to get the row number from a datatable?

I am looping through every row in a datatable: foreach (DataRow row in dt.Rows) {} I would like to get the index of the current row within the dt datatable. for example: int index = dt.Rows[current row number] How do i do this?...

How to properly URL encode a string in PHP?

I'm making a search page, where you type a search query and the form is submitted to search.php?query=your query. What PHP function is the best and that I should use for encoding/decoding the search query?...

Custom Listview Adapter with filter Android

Please am trying to implement a filter on my listview. But whenever the text change, the list disappears.Please Help Here are my codes. The adapter class. package com.talagbe.schymn; import java.util.ArrayList; import android.content.Context; imp...

How to log as much information as possible for a Java Exception?

There's a common problem I've come across a few times when logging Exceptions. There seem to be various different types to deal with. E.g. some wrap other Exceptions, some don't have a message at all - just a type. Most code I've seen logs Exception...

Find if a textbox is disabled or not using jquery

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

How do I call a non-static method from a static method in C#?

I have the following code, I want to call data1() from data2(). Is this possible in C#? If so, how? private void data1() { } private static void data2() { data1(); //generates error } ...

How to get the connection String from a database

I have created a database with SQL Server Management Studio, I would like to now use it in my C# application. I need the connection string? Where can I find the connection string, and where is my database stored? Do I have to publish it or somethin...

How to Load Ajax in Wordpress

I'm familiar with using ajax in the ordinary way with jQuery. I've played around it for a while, but don't understand what Wordpress needs to get it to work... What I have here is taken from some tutorial or article. This is in functions.php (in a ch...

Global variables in Javascript across multiple files

A bunch of my JavaScript code is in an external file called helpers.js. Inside the HTML that calls this JavaScript code I find myself in need of knowing if a certain function from helpers.js has been called. I have attempted to create a global varia...

How can I use interface as a C# generic type constraint?

Is there a way to get the following function declaration? public bool Foo<T>() where T : interface; ie. where T is an interface type (similar to where T : class, and struct). Currently I've settled for: public bool Foo<T>() where T :...

How to append to the end of an empty list?

I have a list: list1=[] the length of the list is undetermined so I am trying to append objects to the end of list1 like such: for i in range(0, n): list1=list1.append([i]) But my output keeps giving this error: AttributeError: 'NoneType' ...

Update or Insert (multiple rows and columns) from subquery in PostgreSQL

I'm trying to do something like this in postgres: UPDATE table1 SET (col1, col2) = (SELECT col2, col3 FROM othertable WHERE othertable.col1 = 123); INSERT INTO table1 (col1, col2) VALUES (SELECT col1, col2 FROM othertable) But point 1 is not poss...

Where does PostgreSQL store the database?

Where are the files for a PostgreSQL database stored?...

Android: why setVisibility(View.GONE); or setVisibility(View.INVISIBLE); do not work

I want my DatePicker and the button to be invisible in the begining. And when I press my magic button I want to setVisibility(View.Visible); The problem here is when I setVisibility(View.GONE) or setVisibility(View.INVISIBLE) nothing changes and the...

How to add months to a date in JavaScript?

I want to add months to a date in JavaScript. For example: I am inserting date 06/01/2011 (format mm/dd/yyyy) and now I want to add 8 months to this date. I want the result to be 02/01/2012. So when adding months, the year may also increase....

How to add an action to a UIAlertView button using Swift iOS

I want to add another button other than the "OK" button which should just dismiss the alert. I want the other button to call a certain function. var logInErrorAlert: UIAlertView = UIAlertView() logInErrorAlert.title = "Ooops" logInErrorAlert.message...

How to Generate Unique Public and Private Key via RSA

I am building a custom shopping cart where CC numbers and Exp date will be stored in a database until processing (then deleted). I need to encrypt this data (obviously). I want to use the RSACryptoServiceProvider class. Here is my code to create my...

Zoom in on a point (using scale and translate)

I want to be able to zoom in on the point under the mouse in an HTML 5 canvas, like zooming on Google Maps. How can I achieve that?...

How do I get the title of the current active window using c#?

I'd like to know how to grab the Window title of the current active window (i.e. the one that has focus) using C#. ...

How can I get the key value in a JSON object?

How do I get the key value in a JSON object and the length of the object using JavaScript? For example: [ { "amount": " 12185", "job": "GAPA", "month": "JANUARY", "yea...

How to convert ZonedDateTime to Date?

I am trying to set a server agnostic date time in my database and I believe the best practice to do so is to set a UTC DateTime. My db server is Cassandra and the db driver for Java understands only the Date type. So assuming that in my code I am us...

Replace deprecated preg_replace /e with preg_replace_callback

$result = preg_replace( "/\{([<>])([a-zA-Z0-9_]*)(\?{0,1})([a-zA-Z0-9_]*)\}(.*)\{\\1\/\\2\}/iseU", "CallFunction('\\1','\\2','\\3','\\4','\\5')", $result ); The above code gives a deprecation warning after upgrading to PHP 5.5: ...

Convert integer to hexadecimal and back again

How can I convert the following? 2934 (integer) to B76 (hex) Let me explain what I am trying to do. I have User IDs in my database that are stored as integers. Rather than having users reference their IDs I want to let them use the hex value. Th...

Is There a Better Way of Checking Nil or Length == 0 of a String in Ruby?

Is there a better way than the following to check to see if a string is nil OR has a length of 0 in Ruby? if !my_string || my_string.length == 0 return true else return false end In C# there's the handy string.IsNullOrEmpty(myString) Anythi...

Hide all warnings in ipython

I need to produce a screencast of an ipython session, and to avoid confusing viewers, I want to disable all warnings emitted by warnings.warn calls from different packages. Is there a way to configure the ipythonrc file to automatically disable all s...

Limit results in jQuery UI Autocomplete

I am using jQuery UI Autocomplete. $("#task").autocomplete({ max:10, minLength:3, source: myarray }); The max parameter doesn't work and I still get more than 10 results. Am I missing something?...

Remove element of a regular array

I have an array of Foo objects. How do I remove the second element of the array? I need something similar to RemoveAt() but for a regular array....

javascript node.js next()

I see a lot of use next in node.js. What is it, where does it come from? What does it do? Can I use it client side? Sorry it's used for example here: http://dailyjs.com/2010/12/06/node-tutorial-5/ look for the loadUser function....

Declare a Range relative to the Active Cell with VBA

I need to declare a range object relative to the Active Cell. The problem is, the number of rows and columns I want to select is different each time the macro runs. For example, I have two variables: numRows and numCols. I want to select a range t...

Adding delay between execution of two following lines

I need to add delay between the execution of two lines in a(same) function. Is there is any favorable options to do this? Note: I don't need two different functions to do this, and the delay must not affect other functions' execution. eg: line 1:...

Oracle 11g Express Edition for Windows 64bit?

I registered on http://Oracle.com in order to download 11g R2 Express edition database. But http://Oracle.com offered me download links only for Windows 32bit and for Linux 64bit. Is there somewhere 64bit Windows version of Oracle 11g XE database? ...

How to find substring from string?

How do I find a substring from the string path "/user/desktop/abc/post/" using C/C++? I want to check if folder "abc" is present or not in that path. Path is character pointer char *ptr = "/user/desktop/abc/post/";...

Regex matching in a Bash if statement

What did I do wrong here? Trying to match any string that contains spaces, lowercase, uppercase, or numbers. Special characters would be nice too, but I think that requires escaping certain characters. TEST="THIS is a TEST title with some numbers 1...

jQuery: Return data after ajax call success

I have something like this, where it is a simple call to a script that gives me back a value, a string.. function testAjax() { $.ajax({ url: "getvalue.php", success: function(data) { return data; } }); } but if...

Java getting the Enum name given the Enum Value

How can I get the name of a Java Enum type given its value? I have the following code which works for a particular Enum type, can I make it more generic? public enum Category { APPLE("3"), ORANGE("1"), private final String identifie...

How to remove a virtualenv created by "pipenv run"

I am learning Python virtual environment. In one of my small projects I ran pipenv run python myproject.py and it created a virtualenv for me in C:\Users\USERNAME\.virtualenvs I found it also created or modified some files under my project source co...

Check if pull needed in Git

How do I check whether the remote repository has changed and I need to pull? Now I use this simple script: git pull --dry-run | grep -q -v 'Already up-to-date.' && changed=1 But it is rather heavy. Is there a better way? The ideal soluti...

How to convert a full date to a short date in javascript?

I have a date like this Monday, January 9, 2010 I now want to convert it to 1/9/2010 mm/dd/yyyy I tried to do this var startDate = "Monday, January 9, 2010"; var convertedStartDate = new Date(startDate); var month = convertedStartDa...

Docker Compose wait for container X before starting Y

I am using rabbitmq and a simple python sample from here together with docker-compose. My problem is that I need to wait for rabbitmq to be fully started. From what I searched so far, I don't know how to wait with container x (in my case worker) unti...

How can I "disable" zoom on a mobile web page?

I am creating a mobile web page that is basically a big form with several text inputs. However (at least on my Android cellphone), every time I click on some input the whole page zooms there, obscuring the rest of the page. Is there some HTML or CSS...

Can linux cat command be used for writing text to file?

Is something like this: cat "Some text here." > myfile.txt Possible? Such that the contents of myfile.txt would now be overwritten to: Some text here. This doesn't work for me, but also doesn't throw any errors. Specifically interested in a...

Scrollable Menu with Bootstrap - Menu expanding its container when it should not

I tried this method (their fiddle) to enable scrollable menu with Bootstrap, but with that approach, the scrollable menu expands its container -- fiddle -- the non-scrollable menu, correctly, does not do this. How can I fix this? Suggestions on othe...

How to avoid "RuntimeError: dictionary changed size during iteration" error?

I have checked all of the other questions with the same error yet found no helpful solution =/ I have a dictionary of lists: d = {'a': [1], 'b': [1, 2], 'c': [], 'd':[]} in which some of the values are empty. At the end of creating these lists, I...

Remove/ truncate leading zeros by javascript/jquery

Suggest solution for removing or truncating leading zeros from number(any string) by javascript,jquery....

How to read connection string in .NET Core?

I want to read just a connection string from a configuration file and for this add a file with the name "appsettings.json" to my project and add this content on it: { "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Data...

How to change the default port of mysql from 3306 to 3360

I want to change the default port number of MySQL server presently it is 3306. I want to change it to 3360. I have tried: -- port=3360 But things are not working for me. Please provide query to change port not any configuration. I am using Wind...

Laravel Eloquent ORM Transactions

The Eloquent ORM is quite nice, though I'm wondering if there is an easy way to setup MySQL transactions using innoDB in the same fashion as PDO, or if I would have to extend the ORM to make this possible?...

How do I declare a namespace in JavaScript?

How do I create a namespace in JavaScript so that my objects and functions aren't overwritten by other same-named objects and functions? I've used the following: if (Foo == null || typeof(Foo) != "object") { var Foo = new Object();} Is there a mor...

Condition within JOIN or WHERE

Is there any difference (performance, best-practice, etc...) between putting a condition in the JOIN clause vs. the WHERE clause? For example... -- Condition in JOIN SELECT * FROM dbo.Customers AS CUS INNER JOIN dbo.Orders AS ORD ON CUS.CustomerID...

Java enum with multiple value types

Basically what I've done is write an enum for States, and I want to not only be able to access them just as states but also access their abbreviation and whether or not they were an original colony. public enum States { ... MASSACHUS...

How can I parse a CSV string with JavaScript, which contains comma in data?

I have the following type of string var string = "'string, duppi, du', 23, lala" I want to split the string into an array on each comma, but only the commas outside the single quotation marks. I can't figure out the right regular expressio...

How to hide the border for specified rows of a table?

I want to hide the border for a specific rows of a table.How to do it? Any Idea? Sample code is Highly Appreciated....

Spring Boot Remove Whitelabel Error Page

I'm trying to remove white label error page, so what I've done was created a controller mapping for "/error", @RestController public class IndexController { @RequestMapping(value = "/error") public String error() { return "Error han...

How to display an error message in an ASP.NET Web Application

I have an ASP.NET web application, and I wanted to know how I could display an error message box when an exception is thrown. For example, try { do something } catch { messagebox.write("error"); //[Th...

Checking for Undefined In React

I have a scenario where I'm passing data from a reducer into my react state. data: { "id": 1, "title": "Test", "content": { "body": "sdfsdf" "image": "http://example.com" } } Using componentWillRecieveProps, this ...

multiple axis in matplotlib with different scales

How can multiple scales can be implemented in Matplotlib? I am not talking about the primary and secondary axis plotted against the same x-axis, but something like many trends which have different scales plotted in same y-axis and that can be identif...

How to add a 'or' condition in #ifdef

How can I add a 'or' condition in #ifdef ? I have tried: #ifdef CONDITION1 || CONDITION2 #endif This does not work....

What's the difference between equal?, eql?, ===, and ==?

I am trying to understand the difference between these four methods. I know by default that == calls the method equal? which returns true when both operands refer to exactly the same object. === by default also calls == which calls equal?... okay, s...

No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

I am getting this exception when I call a DAO method which uses SessionFactory.getCurrentSession(). The DAO class is annotated with @Transactional and I also have <tx:annotation-driven/> declared in the application context configuration file. ...

How to switch from POST to GET in PHP CURL

I have tried switching from a previous Post request to a Get request. Which assumes its a Get but eventually does a post. I tried the following in PHP : curl_setopt($curl_handle, CURLOPT_POSTFIELDS, null); curl_setopt($curl_handle, CURLOPT_POST, FA...

MySQL compare DATE string with string from DATETIME field

I have a question: Is it possible to select from a MySQL database by comparing one DATE string "2010-04-29" against strings that are stored as DATETIME (2010-04-29 10:00)? I have one date picker that filters data and I would like to query the table ...

how to convert .java file to a .class file

Can anyone tell me how I can convert a .java file into .class file with an executable bytecode?...

How to insert date values into table

How can I insert into table with different input using / ,with date datatype? insert into run(id,name,dob)values(&id,'&name',[what should I write here?]); I'm using oracle 10g....

A keyboard shortcut to comment/uncomment the select text in Android Studio

How do I comment out several lines of text selected in the IDE with a control key combination? I thought that Ctrl + Alt + C was the correct sequence, but that's not working....

Can a JSON value contain a multiline string

I am writing a JSON file which would be read by a Java program. The fragment is as follows... { "testCases" : { "case.1" : { "scenario" : "this the case 1.", "result" : "this is a very long line which is not easily readble. ...

Change navbar color in Twitter Bootstrap

How would I go about modifying the CSS to change the color of the navbar in Twitter Bootstrap?...

How to open a file for both reading and writing?

Is there a way to open a file for both reading and writing? As a workaround, I open the file for writing, close it, then open it again for reading. But is there a way to open a file for both reading and writing?...

jQuery removeClass wildcard

Is there any easy way to remove all classes matching, for example, color-* so if I have an element: <div id="hello" class="color-red color-brown foo bar"></div> after removing, it would be <div id="hello" class="foo bar"><...

xls to csv converter

I am using win32.client in python for converting my .xlsx and .xls file into a .csv. When I execute this code it's giving an error. My code is: def convertXLS2CSV(aFile): '''converts a MS Excel file to csv w/ the same name in the same directory'...

Git reset single file in feature branch to be the same as in master

I'm trying to revert my changes in a single file in my feature branch and I want this file to be the same as in master. I tried: git checkout -- filename git checkout filename git checkout HEAD -- filename It seems that none of these made any ch...

Oracle Insert via Select from multiple tables where one table may not have a row

I have a number of code value tables that contain a code and a description with a Long id. I now want to create an entry for an Account Type that references a number of codes, so I have something like this: insert into account_type_standard (accoun...

SQLDataReader Row Count

I am trying to get the number of rows that were returned by iterating the reader. But I always get 1 when I run this code? Did I screw up something in this? int count = 0; if (reader.HasRows) { while (reader.Read()) { count++; ...

What is the JUnit XML format specification that Hudson supports?

I have Hudson as continuous integration server and I want to use option 'Publish JUnit test result report'. But I don't use xUnit tools for testing, instead of that i have shell scripts which run tests and return results in simple format. I am thinki...

PHP import Excel into database (xls & xlsx)

I tried to search for some plugins to import Excel file into MySQL database, one of them is http://code.google.com/p/php-excel-reader/ The tool is so powerful that it displays the entire excel content into html. However, I think I just need to read...

Remove or adapt border of frame of legend using matplotlib

When plotting a plot using matplotlib: How to remove the box of the legend? How to change the color of the border of the legend box? How to remove only the border of the box of the legend? ...

Undefined symbols for architecture armv7

This problem has been driving me crazy, and I can't work out how to fix it... Undefined symbols for architecture armv7: "_deflateEnd", referenced from: -[ASIDataCompressor closeStream] in ASIDataCompressor.o "_OBJC_CLASS_$_ASIDataDecom...

MySQL WHERE IN ()

My query is: SELECT * FROM table WHERE id IN (1,2,3,4); I use it for usergroups and a user can be in more than one group. but it seems that when a record has multiple id like 1 and 3, mySQL does not return that row. Is there any way to get that r...

Capturing browser logs with Selenium WebDriver using Java

Is there a way to capture browser logs while running automated test cases with Selenium? I found an article on how to capture JavaScript errors in Selenium. But that is just for Firefox and only for errors. I would like to get all the console logs....

Scrollview can host only one direct child

I have multiple LinearLayouts with a combined height that easily exceeds a device's screen height. So in order to make my layout scrollable, I tried adding in a ScrollView, but unfortunately I get the following error: Scrollview can host only one...

Copy files to network computers on windows command line

I am trying to create a script on Windows which when run on an admin PC: Copies a folder from the admin PC into a group of network PCs by specifying the ip address / range For each destination PC, Navigate into the folder and run another script fil...

How to control the line spacing in UILabel

Is it possible to reduce the gap between text, when put in multiple lines in a UILabel? We can set the frame, font size and number of lines. I want to reduce the gap between the two lines in that label....

Sort a single String in Java

Is there a native way to sort a String by its contents in java? E.g. String s = "edcba" -> "abcde" ...

Internet Explorer 11 disable "display intranet sites in compatibility view" via meta tag not working

I have been working on an intranet website for over 6 months were I have been using the below html5 doctype and edge compatibility meta tag to force Internet Explorer to not emulate an older browser version, and this has worked ok. <!DOCTYPE html...

Python loop for inside lambda

In my code I need to simplify as much as possible my line of code. EDIT: I think I'm not clear enough - it needs to be one line of code. I need to put a for loop inside a lambda expression, something like that: x = lambda x: (for i in x : print i) ...

querySelector and querySelectorAll vs getElementsByClassName and getElementById in JavaScript

I would like to know what exactly is the difference between querySelector and querySelectorAll against getElementsByClassName and getElementById? From this link I could gather that with querySelector I can write document.querySelector(".myclass") t...

"string could not resolved" error in Eclipse for C++ (Eclipse can't resolve standard library)

I have the following code in eclipse for c++ and it's underlining string and cout and saying could not be resolved. #include <string> #include <iostream> using namespace std; int main() { string s; s = "hello world"; cout ...

Reset identity seed after deleting records in SQL Server

I have inserted records into a SQL Server database table. The table had a primary key defined and the auto increment identity seed is set to “Yes”. This is done primarily because in SQL Azure, each table has to have a primary key and identity def...

Converting an object to a string

How can I convert a JavaScript object into a string? Example: var o = {a:1, b:2} console.log(o) console.log('Item: ' + o) Output: Object { a=1, b=2} // very nice readable output :) Item: [object Object] // no idea what's inside :( ...

Using sudo with Python script

I'm trying to write a small script to mount a VirtualBox shared folder each time I execute the script. I want to do it with Python, because I'm trying to learn it for scripting. The problem is that I need privileges to launch mount command. I could ...

Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag

I am trying to set up my React.js app so that it only renders if a variable I have set is true. The way my render function is set up looks like: render: function() { var text = this.state.submitted ? 'Thank you! Expect a follow up at '+email...

How to show what a commit did?

A stupid way I know is: git diff commit-number1 commit-number2 any better way? I mean I want to know the commit1 itself, I don't want to add the commit2 before it as parameter....

How do I launch a program from command line without opening a new cmd window?

I'm trying to programmatically execute an external file from cmd using this command: START "filepath" Where "filepath" is the path of my file. It opens fine but it also open a new command prompt window. So, which is the right command for opening ...

Display all items in array using jquery

I have an array that I want to have displayed in html.. I don't want to write multiple lines for posting each item in the array but all should be exactly the same. ie var array = []; //code that fills the array.. $('.element').html('<span>'+ar...

How to force a line break on a Javascript concatenated string?

I'm sending variables to a text box as a concatenated string so I can include multiple variables in on getElementById call. I need to specify a line break so the address is formatted properly. document.getElementById("address_box").value = (title...

How do I read CSV data into a record array in NumPy?

I wonder if there is a direct way to import the contents of a CSV file into a record array, much in the way that R's read.table(), read.delim(), and read.csv() family imports data to R's data frame? Or is the best way to use csv.reader() and then ap...

Ruby: kind_of? vs. instance_of? vs. is_a?

What is the difference? When should I use which? Why are there so many of them?...

Find character position and update file name

What function might I use to find a character position in a string using PowerShell 2.0. i.e I would use CHARINDEX or PATINDEX if using SQL Server. I looked at using the Select-String cmdlet but it doesn't seem to do what I need it to do. Ultim...

IIS7 URL Redirection from root to sub directory

I am using Windows Server 2008 with IIS7. I need to redirect the users who come to www.mysite.com to wwww.mysite.com/menu_1/MainScreen.aspx. Here is the file structure I have for the projects: -Sites -Default Web Site -Menu_1 -MenuService -Vs...

Jackson overcoming underscores in favor of camel-case

I retrieve a JSON string from internet; like most JSON I've seen it includes long keys that are separated by underscores. Essentially, my goal is to deserialize JSON into java-objects, but I don't use underscores in java-code. For instance, I might ...

How to tune Tomcat 5.5 JVM Memory settings without using the configuration program

I need to configure Tomcat memory settings as part of a larger installation, so manually configuring tomcat with the configuration app after the fact is out of the question. I thought I could just throw the JVM memory settings into the JAVA_OPTS envi...

How to remove focus from input field in jQuery?

I am setting the focus on a certain input field when loading a page using the following line: $('#myInputID').focus(); Is there a way that I can undo or remove this focus when hovering over a certain element? (The focus does not have to be reset ...

Check if a folder exist in a directory and create them using C#

How can I check if directory C:/ contains a folder named MP_Upload, and if it does not exist, create the folder automatically? I am using Visual Studio 2005 C#....

How to highlight text using javascript

Can someone help me with a javascript function that can highlight text on a web page. And the requirement is to - highlight only once, not like highlight all occurrences of the text as we do in case of search....

How Can I Convert Postscript Type 1 font to .otf or .ttf?

I have googled until blue in the fingers. I have a Postscript font that I need to use on a website. I need to convert it to .ttf or .otf format. None of the free conversion tools allow .pfm, .afm, or .inf extensions as inputs. I have tried to insta...

When should you use constexpr capability in C++11?

It seems to me that having a "function that always returns 5" is breaking or diluting the meaning of "calling a function". There must be a reason, or a need for this capability or it wouldn't be in C++11. Why is it there? // preprocessor. #define...

Get total number of items on Json object?

Possible Duplicate: Length of Javascript Object (ie. Associative Array) I have an object similar to this one: var jsonArray = { '-1': { '-1': 'b', '2': 'a', '10': 'c' }, '2': { '-1': 'a', '2': 'b', '10': 'a' ...

Getting the last n elements of a vector. Is there a better way than using the length() function?

If, for argument's sake, I want the last five elements of a 10-length vector in Python, I can use the "-" operator in the range index so: >>> x = range(10) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> x[-5:] [5, 6, 7, 8, 9] &g...

Interface/enum listing standard mime-type constants

I am looking among the standard libraries (like apache commons, jax, jboss, javax) for an interface or enum that lists the values of all the standard mime-type (aka content-type). This interface should not be encumbered with too deep with other clas...

How do you reindex an array in PHP but with indexes starting from 1?

I have the following array, which I would like to reindex so the keys are reversed (ideally starting at 1): Current array (edit: the array actually looks like this): Array ( [2] => Object ( [title] => Section [linked] =&g...

Rounded table corners CSS only

I have searched and searched, but haven't been able to find a solution for my requirement. I have a plain ol' HTML table. I want round corners for it, without using images or JS, i.e. pure CSS only. Like this: Rounded corners for corner cells, an...

CURL Command Line URL Parameters

I am trying to send a DELETE request with a url parameter using CURL. I am doing: curl -H application/x-www-form-urlencoded -X DELETE http://localhost:5000/locations` -d 'id=3' However, the server is not seeing the parameter id = 3. I tried using ...

mysql after insert trigger which updates another table's column

i'm trying to write a trigger, I have following tables: BookingRequest: +-----------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+---------+------+-----+-...

Maven fails to find local artifact

Occasionally maven complains that a particular dependency, which is built and packaged locally, cannot be found in the local repository while building another project that has it as a dependency. We get an error like: Failed to execute goal on p...

How to declare a local variable in Razor?

I am developing a web application in asp.net mvc 3. I am very new to it. In a view using razor, I'd like to declare some local variables and use it across the entire page. How can this be done? It seems rather trivial to be able to do the following ...

Why doesn't file_get_contents work?

Why does file_get_contents not work for me? In the test file code below, it seems that everyone's examples that I've searched for all have this function listed, but it never gets executed. Is this a problem with the web hosting service? Can someon...

Replace non-ASCII characters with a single space

I need to replace all non-ASCII (\x00-\x7F) characters with a space. I'm surprised that this is not dead-easy in Python, unless I'm missing something. The following function simply removes all non-ASCII characters: def remove_non_ascii_1(text): ...

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?...

Git merge reports "Already up-to-date" though there is a difference

I have a git repository with 2 branches: master and test. There are differences between master and test branches. Both branches have all changes committed. If I do: git checkout master git diff test A screen full of changes appears showing the...

How to change angular port from 4200 to any other

I want to use 5000 instead of 4200. I have tried to create a file on root name ember-cli and put JSON according to the code below: { "port": 5000 } But my app still runs on 4200 instead of 5000...

How do I do pagination in ASP.NET MVC?

What is the most preferred and easiest way to do pagination in ASP.NET MVC? I.e. what is the easiest way to break up a list into several browsable pages. As an example lets say I get a list of elements from a database/gateway/repository like this: ...

VBA: Conditional - Is Nothing

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

Disable building workspace process in Eclipse

What is Eclipse doing when building workspace process is running? Can i disable it because it is taking a long time to complete and i dont know if it is necessary. Thank you...

Show which git tag you are on?

I'm having trouble finding out which tag is currently checked out. When I do: git checkout tag1 git branch I can't seem to find out which tag I'm on. It only logs: * (no branch) master Is it possible to find out which tags are checked out? I...

How can I parse a String to BigDecimal?

I have this String: 10,692,467,440,017.120 (it's an amount). I want to parse it to a BigDecimal. The problem is that I have tried both DecimalFormat and NumbeFormat in vain....

Uncaught TypeError: $(...).datepicker is not a function(anonymous function)

I found few answers on stack overflow but still cant resolve my problem. I am running on Django but I dont think it is relevant for this error. I try to make work my date picker java script but I am getting the error 1:27 Uncaught TypeError: $(......

HTML Table width in percentage, table rows separated equally

When I create a table in html, a table with a width of 100%, if I want all the cells (tds) to be divided in equal parts, do I have to enter the width % for each cell? Am I "obliged" to do it? E.g.: <table cellpadding="0" cellspacing="0" width="1...

How to wrap text of HTML button with fixed width?

I just noticed that if you give an HTML button a fixed width, the text inside the button is never wrapped. I've tried it with word-wrap, but that cuts of the word even though there are spaces available to wrap on. How can I make the text of an HTML ...

Windows service with timer

I have created a windows service with timer in c#.net. it works fine while i debug/build the project in visual studio but it does not perform its operation after installation. What might be the reason behind this ? code : public partial class S...

How to get a list of all files that changed between two Git commits?

Due to bureaucracy, I need to get a list of all changed files in my repository for a report (I started with existing source code). What should I run to get this list?...

Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces

Looking for quick, simple way in Java to change this string " hello there " to something that looks like this "hello there" where I replace all those multiple spaces with a single space, except I also want the one or more spaces at the b...

What does it mean to "call" a function in Python?

What does "call" mean and do? How would you "call" a function in Python?...

React Hook Warnings for async function in useEffect: useEffect function must return a cleanup function or nothing

I was trying the useEffect example something like below: useEffect(async () => { try { const response = await fetch(`https://www.reddit.com/r/${subreddit}.json`); const json = await response.json(); setPosts(json.data.c...

How can I make the computer beep in C#?

How do I make the computer's internal speaker beep in C# without external speakers?...

Select distinct using linq

I have a class list of class public class LinqTest { public int id { get; set; } public string value { get; set; } } List<LinqTest> myList = new List<LinqTest>(); myList.Add(new LinqTest() { id = 1, value = "a" }); myList.Add(new LinqT...

Debug message "Resource interpreted as other but transferred with MIME type application/javascript"

OK, I understand what the messages means, but I'm really not sure what's causing it. I'm using Safari and the Web Inspector on Mac OS X, by the way. I've got the following in my document head: <script src="http://local.url/a/js/jquery.js" type="...

Android getText from EditText field

I have a problem with getting text from EditText field to insert it in Email composer with intent. I've declared EditText field in layout file (@+id/vnosEmaila): <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http...

Java ArrayList clear() function

Let's say I have a ArrayList<String> data; I'm adding some data into this Array, using data.add() function. Let's say I've added 10 Strings into this array. The size of the array is 10 now. How do i destroy all elements in the array? The data...

matplotlib colorbar for scatter

I'm working with data that has the data has 3 plotting parameters: x,y,c. How do you create a custom color value for a scatter plot? Extending this example I'm trying to do: import matplotlib import matplotlib.pyplot as plt cm = matplotlib.cm.get_...

How to make PopUp window in java

I am currently developing a java application. I want to show a new Window which contains a text area and a button. Do you have any ideas?...

How long do browsers cache HTTP 301s?

I am debugging a problem with a HTTP 301 Permanent Redirect. After a quick test, it seems that Safari clears its cache of 301s when it is restarted, but Firefox does not. When do IE, Chrome, Firefox and Safari clear their cache of 301s? UPDATE: For...

AES Encrypt and Decrypt

I write an application by swift, i need AES Encrypt and Decrypt functionality, i received encrypted data from another .Net solution, but i can't find something to do it. This is my .net Encryption: public static byte[] AES_Encrypt(byte[] bytesToBe...

Programmatically read from STDIN or input file in Perl

What is the slickest way to programatically read from stdin or an input file (if provided) in Perl?...

how to convert Lower case letters to upper case letters & and upper case letters to lower case letters

Alternately display any text that is typed in the textbox // in either Capital or lowercase depending on the original // letter changed. For example: CoMpUtEr will convert to // cOmPuTeR and vice versa. Switch.addActionListener(ne...

javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25

I am getting issue while sending email. javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectExcep...

AngularJS - get element attributes values

How do you get an element attribute value? e.g. HTML element: <button data-id="345" ng-click="doStuff($element.target)">Button</button> JS: function doStuff(item){ angular.element(item)[0].data('id'); // undefined is not a func...

Automatically running a batch file as an administrator

How do I run a batch file from another batch file with administrator rights? I have tried the RUNAS command, but it requires the administrator password. I am searching for an alternative for running a batch file by right clicking on it and running ...

"SyntaxError: Unexpected token < in JSON at position 0"

In a React app component which handles Facebook-like content feeds, I am running into an error: Feed.js:94 undefined "parsererror" "SyntaxError: Unexpected token < in JSON at position 0 I ran into a similar error which turned out to be a ty...

Return Bit Value as 1/0 and NOT True/False in SQL Server

I have a Table in SQL Server 2000 with BitValue Column. But, it is being displayed as True/False in SQL Server Management Studio. When I do a Select * from Tablename it returns the BitValue Column values as True/False. How do I force it to return the...

Choosing bootstrap vs material design

I'm going to start new project using AngularJS (full stack). My project needs to be responsive and I'll be creating templates from scratch. So I need an advice on whether to choose bootstrap 3 (with angular directives) or material design for layout...

Return list of items in list greater than some value

I have the following list j=[4,5,6,7,1,3,7,5] What's the simplest way to return [5,5,6,7,7] being the elements in j greater or equal to 5?...

Convert a Map<String, String> to a POJO

I've been looking at Jackson, but is seems I would have to convert the Map to JSON, and then the resulting JSON to the POJO. Is there a way to convert a Map directly to a POJO?...

ValueError: object too deep for desired array while using convolution

I'm trying to do this: h = [0.2,0.2,0.2,0.2,0.2] Y = np.convolve(Y, h, "same") Y looks like this: While doing this I get this error: ValueError: object too deep for desired array Why is this? My guess is because somehow the convolve functi...

How to include js and CSS in JSP with spring MVC

I want to include js and css files in my jsp, but I'm not able to do so. I'm new to the concept of spring MVC. For a long time, I've been working on this same topic. My index Page is like this <!DOCTYPE html> <html> <head> <link...

Calling a JavaScript function returned from an Ajax response

I have a system where I send an Ajax command, which returns a script block with a function in it. After this data is correctly inserted in the DIV, I want to be able to call this function to perform the required actions. Is this possible?...

Accessing nested JavaScript objects and arrays by string path

I have a data structure like this : var someObject = { 'part1' : { 'name': 'Part 1', 'size': '20', 'qty' : '50' }, 'part2' : { 'name': 'Part 2', 'size': '15', 'qty' : '60' }, 'part3...

@Directive vs @Component in Angular

What is the difference between @Component and @Directive in Angular? Both of them seem to do the same task and have the same attributes. What are the use cases and when to prefer one over another?...

File Permissions and CHMOD: How to set 777 in PHP upon file creation?

A question about file permissions when saving a file that when non existent, is created initially as new file. Now, this all goes well, and the saved file appear to have mode 644. What to I have to change here, in order to make the files save as mode...

IIS Express Windows Authentication

I'm trying to use IIS Express with VS2010 to host a silverlight application. I modified my applicationhost.config file to allow for modification of the proper configuration settings. I have the following in my web.config: <location path=""> ...

Search and replace in bash using regular expressions

I've seen this example: hello=ho02123ware38384you443d34o3434ingtod38384day echo ${hello//[0-9]/} Which follows this syntax: ${variable//pattern/replacement} Unfortunately the pattern field doesn't seem to support full regex syntax (if I use . or ...

Disable HTTP OPTIONS, TRACE, HEAD, COPY and UNLOCK methods in IIS

For security reasons I want to disable those methods through application level so I have this web.config file: <configuration> <location path="index.php"> <system.webServer> <directoryBrowse enab...

Upload files with HTTPWebrequest (multipart/form-data)

Is there any class, library or some piece of code which will help me to upload files with HTTPWebrequest? Edit 2: I do not want to upload to a WebDAV folder or something like that. I want to simulate a browser, so just like you upload your avatar ...

How to unlock android phone through ADB

My screen is dead and I want to unlock my phone so I can access it through Kies to backup my pictures. I locked the phone through Android Device Manager setting an easy password (was hoping for an Unlock option once I locked it) and tried various me...

How to monitor network calls made from iOS Simulator

I am trying to monitor calls from an app to my server just like Firebug does. I could not find a way to see that in iOS Simulator or in xCode. Is there a way to do that without sniffing all the traffic? If no, what tool would you suggest?...

Difference between string and char[] types in C++

I know a little C and now I'm taking a look at C++. I'm used to char arrays for dealing with C strings, but while I look at C++ code I see there are examples using both string type and char arrays: #include <iostream> #include <string> u...

Is there any standard for JSON API response format?

Do standards or best practices exist for structuring JSON responses from an API? Obviously, every application's data is different, so that much I'm not concerned with, but rather the "response boilerplate", if you will. An example of what I mean: ...

How to extract an assembly from the GAC?

There is a package I have to deal with which installs assemblies straight into the GAC (e.g. somewhere deep in %windows%/assembly). How do I exorcise the actual assembly (the DLL) from the GAC into the normal file system? Thanks....

Temporarily switch working copy to a specific Git commit

How to switch to specific Git commit without losing all the commits made after it? I want that local files will be changed, but commits' database will remain intact, only the current position pointer is set to currently selected commit. I want to c...

How to make a phone call in android and come back to my activity when the call is done?

I am launching an activity to make a phone call, but when I pressed the 'end call' button, it does not go back to my activity. Can you please tell me how can I launch a call activity which comes back to me when 'End call' button is pressed? This is ...

What does the explicit keyword mean?

What does the explicit keyword mean in C++?...

How to make the Facebook Like Box responsive?

I am using the Facebook like box code in my side bar by pasting the Facebook code into a text widget. My theme is responsive, and I'd like to get the like box to resize correctly. I found this tutorial but he says the way he is doing it, isn't "fully...

git ignore vim temporary files

What is the correct way to make git ignore temporary files produced by vim in all directories (either globally across the system or locally for a single project)?...

Edit and replay XHR chrome/firefox etc?

I've been looking for a way to alter a XHR request made in my browser and then replay it again. Say I have a complete POST request done in my browser, and the only thing I want to change is a small value and then play it again. This would be a lot ea...

Disable scrolling on `<input type=number>`

Is it possible to disable the scroll wheel changing the number in an input number field? I've messed with webkit-specific CSS to remove the spinner but I'd like to get rid of this behavior altogether. I like using type=number since it brings up a nic...

PHP split alternative?

PHP is telling me that split is deprecated, what's the alternative method I should use?...

How do I SET the GOPATH environment variable on Ubuntu? What file must I edit?

I am trying to do a go get: go get github.com/go-sql-driver/mysql and it fails with the following error: package github.com/go-sql-driver/mysql: cannot download, $GOPATH not set. For more details see: go help gopath when I do a go env , a list ...

How to redirect all HTTP requests to HTTPS

I'm trying to redirect all insecure HTTP requests on my site (e.g. http://www.example.com) to HTTPS (https://www.example.com). I'm using PHP btw. Can I do this in .htaccess?...

iOS8 Beta Ad-Hoc App Download (itms-services)

I have an ipa built using my Wildcard profile. I am hosting the ipa, and my testers are downloading it on our devices. For iOS7+ devices it is working fine. I have installed the iOS8 Beta on one of my devices. If I install my app from the app store...

Where does MAMP keep its php.ini?

I have recently got a mac an am not used to developing on a mac at all. I have MAMP Pro 1.9.6.1. I did a locate on php.ini and got this: $ locate php.ini /Applications/MAMP/conf/php5.2/php.ini /Applications/MAMP/conf/php5.3/php.ini /Library/Applica...

How to negate specific word in regex?

I know that I can negate group of chars as in [^bar] but I need a regular expression where negation applies to the specific word - so in my example how do I negate an actual bar, and not "any chars in bar"?...

Use a content script to access the page context variables and functions

I'm learning how to create Chrome extensions. I just started developing one to catch YouTube events. I want to use it with YouTube flash player (later I will try to make it compatible with HTML5). manifest.json: { "name": "MyExtension", "ve...

Best way to strip punctuation from a string

It seems like there should be a simpler way than: import string s = "string. With. Punctuation?" # Sample string out = s.translate(string.maketrans("",""), string.punctuation) Is there?...

How can I call the 'base implementation' of an overridden virtual method?

Given the following code, is there a way I can call class A's version of method X? class A { virtual void X() { Console.WriteLine("x"); } } class B : A { override void X() { Console.WriteLine("y"); } } class Program { static void Main() { ...

"sed" command in bash

Could someone explain this command for me: cat | sed -e 's,%,$,g' | sudo tee /etc/init.d/dropbox << EOF echo "Hello World" EOF What does the "sed" command do?...

pandas dataframe groupby datetime month

Consider a csv file: string,date,number a string,2/5/11 9:16am,1.0 a string,3/5/11 10:44pm,2.0 a string,4/22/11 12:07pm,3.0 a string,4/22/11 12:10pm,4.0 a string,4/29/11 11:59am,1.0 a string,5/2/11 1:41pm,2.0 a string,5/2/11 2:02pm,3.0 a string,5/2/...

How to get root directory in yii2

yii2 Question My yii2 install in d:\wamp\www\yii2store I want to get above path to save images which will be uploaded by me or users. I have pass all available arguments in Yii::getAlias('@webroot') (below are the lists of argument which I have us...

CSS div 100% height

I'm developing this website and I want the right sidebar to have 100% height. body { height: 100%; min-height: 100%; position: relative; } mydiv { height: 100%; min-height: 100%; position: absolute; top: 0; ri...

SQL - IF EXISTS UPDATE ELSE INSERT INTO

What I'm trying to do is INSERT subscribers in my database, but IF EXISTS it should UPDATE the row, ELSE INSERT INTO a new row. Ofcourse I connect to the database first and GET the $name, $email and $birthday from the url string. $con=mysqli_connec...

Why does the jquery change event not trigger when I set the value of a select using val()?

The logic in the change() event handler is not being run when the value is set by val(), but it does run when user selects a value with their mouse. Why is this? <select id="single"> <option>Single</option> <option>Si...

Console.WriteLine does not show up in Output window

I have put some Console.WriteLine calls in to test, but they aren't appearing in the output box? public static ArrayList myDeliveries = new ArrayList(); public mainForm(){ InitializeComponent(); } private void mainForm_Load(object sender, Even...

Why do you need ./ (dot-slash) before executable or script name to run it in bash?

When running scripts in bash, I have to write ./ in the beginning: $ ./manage.py syncdb If I don't, I get an error message: $ manage.py syncdb -bash: manage.py: command not found What is the reason for this? I thought . is an alias for current ...

Repeat a task with a time delay?

I have a variable in my code say it is "status". I want to display some text in the application depending on this variable value. This has to be done with a specific time delay. It's like, Check status variable value Display some text Wait for 1...

how to count length of the JSON array element

I'm trying to count the length of the JSON array element. I know to count the length of array using json.array.length. That is need to find that how many items in every index. If my array is: { "shareInfo": [{ "id": "...

Find an element in DOM based on an attribute value

Can you please tell me if there is any DOM API which search for an element with given attribute name and attribute value: Something like: doc.findElementByAttribute("myAttribute", "aValue"); ...

Not able to launch IE browser using Selenium2 (Webdriver) with Java

I'm not able to launch IE browser to run my selenium automated tests written in Java. I'm using Windows 7 and IE 9. Below is my code: Please find the attachment. public class GoogleNews { private WebDriver driver; private String baseUrl; ...

How can I run a function from a script in command line?

I have a script that has some functions. Can I run one of the function directly from command line? Something like this? myScript.sh func() ...

Could not open input file: artisan

When trying to create a new laravel project, The following error appears on the CLI: Could not open input file: artisan Script php artisan clear-compiled handling the post-install-cmd event returned with an error I am using the latest version of XA...

How to use gitignore command in git

I'm working first time on git. I have pushed my branch on github and it pushed all the library and documents into the github. Now what can I do and how can I use gitignore command to avoid the same mistake again....

How to find an object in an ArrayList by property

How can I find an object, Carnet, in a ArrayList<Carnet> knowing its property codeIsin. List<Carnet> listCarnet = carnetEJB.findAll(); public class Carnet { private String codeTitre; private String nomTitre; private String ...

PostgreSQL naming conventions

Where can I find a detailed manual about PostgreSQL naming conventions? (table names vs. camel case, sequences, primary keys, constraints, indexes, etc...)...

Convert Unix timestamp into human readable date using MySQL

Is there a MySQL function which can be used to convert a Unix timestamp into a human readable date? I have one field where I save Unix times and now I want to add another field for human readable dates....

Stretch child div height to fill parent that has dynamic height

As it can be seen in the following fiddle, I have two divs, contained in a parent div that have stretched to contain the big div, my goal is to make those child divs equal in height. http://fiddle.jshell.net/y9bM4/ ...

How can I get the UUID of my Android phone in an application?

I'm looking for help to get the UUID of my Android phone. I have searched the net and found one potential solution but it is not working in the emulator. Here is the code: Class<?> c; try { c = Class.forName("android.os.SystemProperties")...

MySQL "NOT IN" query

I wanted to run a simple query to throw up all the rows of Table1 where a principal column value is not present in a column in another table (Table2). I tried using: SELECT * FROM Table1 WHERE Table1.principal NOT IN Table2.principal This is inst...

Route.get() requires callback functions but got a "object Undefined"

I am learning making Todo app. On the website, I am studying is https://coderwall.com/p/4gzjqw/build-a-javascript-todo-app-with-express-jade-and-mongodb I typed as instruction describes, [app.js] var main = require('./routes/main'); var todo = requ...

Can I force a UITableView to hide the separator between empty cells?

When using a plain-style UITableView with a large enough number of cells that the UITableView cannot display them all without scrolling, no separators appear in the empty space below the cells. If I have only a few cells the empty space below them in...

Parser Error when deploy ASP.NET application

I've finished simple asp.net web application project, compiled it, and try to test on local IIS. I've create virtual directory, map it with physical directory, then put all necessary files there, including bin folder with all .dll's In the project se...

How to get memory available or used in C#

How can I get the available RAM or memory used by the application? ...

add controls vertically instead of horizontally using flow layout

I am adding checkboxes on JPanel in FlowLayout the checkboxes are being added horizontally. I want to add checkboxes vertically on the Panel. What is the possible solution?...

Insert node at a certain position in a linked list C++

I'm trying to insert a node at a certain position. In my code, the numbers with position 1 is only being inserted (basically at the beginning of the linked list) and it is not inserting any data with position 2. Is there something wrong with temp2? W...

val() doesn't trigger change() in jQuery

I'm trying to trigger the change event on a text box when I change its value with a button, but it doesn't work. Check this fiddle. If you type something in the text boxes and click somewhere else, change is triggered. However, if you click the butt...

HTML&CSS + Twitter Bootstrap: full page layout or height 100% - Npx

I'm trying to make following layout: +-------------------------------------------------+ | Header + search (Twitter navbar) | +------------+------------------------------------+ | | ...

How to select rows where column value IS NOT NULL using CodeIgniter's ActiveRecord?

I'm using CodeIgniter's Active Record class to query the MySQL database. I need to select the rows in a table where a field is not set to NULL: $this->db->where('archived !=', 'NULL'); $q = $this->db->get('projects'); That only returns...

htaccess remove index.php from url

I have a problem whereby google has indexed some pages with the wrong url. The url they are indexing is: http://www.example.com/index.php/section1/section2 I need it to redirect to: http://www.example.com/section1/section2 .htaccess isn't my f...

What's the difference between django OneToOneField and ForeignKey?

What's the difference between Django OneToOneField and ForeignKey?...

Deleting a folder from svn repository

I sometimes make mistakes with svn and have folders stuck in my repository. I want to remove these folders but I cannot figure out a way to do this. Keep in mind I am very new with SVN. I am running this command from apple terminal: sudo svn dele...

Which is the best IDE for Python For Windows

I am new to python and I am using simple gedit application on linux machine to write python code, however its very difficult to manage the indentations of my code. I am looking for any Python IDEs that provides some functionality and should not slow ...

Deployment error:Starting of Tomcat failed, the server port 8080 is already in use

When I run my Java project using Netbeans I get the following error: Deployment error: Starting of Tomcat failed, the server port 8080 is already in use. See the server log for details. at org.netbeans.modules.j2ee.deployment.devmodules.api....

command/usr/bin/codesign failed with exit code 1- code sign error

I'm currently in the process of submitting my first app to the Apple store. I've completed the following processes Obtained a developer account Logged into the Member Center to Create an App ID Used keychain access to request and receive a distribu...

JavaScript Regular Expression Email Validation

This code is always alerting out "null", which means that the string does not match the expression. var pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$"; function isEmailAddress(str) { str = "[email protected]"; alert(str.match(patte...

operator << must take exactly one argument

a.h #include "logic.h" ... class A { friend ostream& operator<<(ostream&, A&); ... }; logic.cpp #include "a.h" ... ostream& logic::operator<<(ostream& os, A& a) { ... } ... When i compile, it says: std::...

Difference between getAttribute() and getParameter()

What is the difference between getAttribute() and getParameter() methods within HttpServletRequest class?...

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...

See :hover state in Chrome Developer Tools

I want to see the :hover style for an anchor I'm hovering on in Chrome. In Firebug, there's a style dropdown that allows me to select different states for an element. I can't seem to find anything similar in Chrome. Am I missing something? ...

What should be the sizeof(int) on a 64-bit machine?

Possible Duplicate: size of int, long, etc Does the size of an int depend on the compiler and/or processor? What decides the sizeof an integer? I'm using a 64-bit machine. $ uname -m x86_64 $ file /usr/bin/file /usr/bin/file: ELF 64-b...

What is the proper #include for the function 'sleep()'?

I am using the Big Nerd Ranch book Objective-C Programming, and it starts out by having us write in C in the first few chapters. In one of my programs it has me create, I use the sleep function. In the book it told me to put #include <stdlib.h>...

How to insert an item into a key/value pair object?

Ok...here's a softball question... I just need to be able to insert a key/value pair into an object at a specific position. I'm currently working with a Hashtable which, of course, doesn't allow for this functionality. What would be the best approac...

How to check if a file exists in the Documents directory in Swift?

How to check if a file exists in the Documents directory in Swift? I am using [ .writeFilePath ] method to save an image into the Documents directory and I want to load it every time the app is launched. But I have a default image if there is no sav...

Add a new element to an array without specifying the index in Bash

Is there a way to do something like PHPs $array[] = 'foo'; in bash vs doing: array[0]='foo' array[1]='bar' ...

How can I check if a string is a number?

I'd like to know on C# how to check if a string is a number (and just a number). Example : 141241 Yes 232a23 No 12412a No and so on... Is there a specific function?...

Append String in Swift

I am new to iOS. I am currently studying iOS using Objective-C and Swift. To append a string in Objective-C I am using following code: NSString *string1 = @"This is"; NSString *string2 = @"Swift Language"; NSString *appendString=[NSString string...

Concat strings in a shell script

How can I concat strings in shell? Is it just... var = 'my'; var .= 'string'; ?...

Could not locate Gemfile

I'm certainly no Ruby developer but I have an application on my server using Ruby, Gems, and Bundler. I am trying to install another Ruby on under a different user account but on the same VPS. When I go to run bundle install I get the following e...

How Connect to remote host from Aptana Studio 3

I am using CODA from a long time .. now i use aptana studio 3 my Question How Connect to remote host from Aptana Studio 3? thanks...

Download File to server from URL

Well, this one seems quite simple, and it is. All you have to do to download a file to your server is: file_put_contents("Tmpfile.zip", file_get_contents("http://someurl/file.zip")); Only there is one problem. What if you have a large file, like 1...

Calculating average of an array list?

I'm trying to use the below code to calculate the average of a set of values that a user enters and display it in a jTextArea but it does not work properly. Say, a user enters 7, 4, and 5, the program displays 1 as the average when it should display ...

Convert data file to blob

How to get a blob? HTML: <input type="file" onchange="previewFile()"> JavaScript: function previewFile() { var file = document.querySelector('input[type=file]').files[0]; var reader = new FileReader(); // Get blob? console.log...

Format decimal for percentage values?

What I want is something like this: String.Format("Value: {0:%%}.", 0.8526) Where %% is that format provider or whatever I am looking for. Should result: Value: %85.26.. I basically need it for wpf binding, but first let's solve the general forma...

Return multiple values in JavaScript?

I am trying to return two values in JavaScript. Is this possible? var newCodes = function() { var dCodes = fg.codecsCodes.rs; var dCodes2 = fg.codecsCodes2.rs; return dCodes, dCodes2; }; ...

Java: get greatest common divisor

I have seen that such a function exists for BigInteger, i.e. BigInteger#gcd. Are there other functions in Java which also work for other types (int, long or Integer)? It seems this would make sense as java.lang.Math.gcd (with all kinds of overloads) ...

Trim string in JavaScript?

How do I trim a string in JavaScript? That is, how do I remove all whitespace from the beginning and the end of the string in JavaScript?...

How to Set Opacity (Alpha) for View in Android

I have a button as in the following: <Button android:text="Submit" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content"> </Button> In my onCreate() event, I am calli...

What is the basic difference between the Factory and Abstract Factory Design Patterns?

What is the basic difference between the Factory and Abstract Factory Patterns?...

DataTables: Cannot read property 'length' of undefined

I understand this a popular issue, and I have read all the similar questions here on Stack Overflow and other sites (including the datatables website). To clarify, I am using PHP Codeigniter Materliazecss I have also made sure that I received th...

Python Script to convert Image into Byte array

I am writing a Python script where I want to do bulk photo upload. I want to read an Image and convert it into a byte array. Any suggestions would be greatly appreciated. #!/usr/bin/python import xmlrpclib import SOAPpy, getpass, datetime import url...

Is there a CSS selector by class prefix?

I want to apply a CSS rule to any element whose one of the classes matches specified prefix. E.g. I want a rule that will apply to div that has class that starts with status- (A and C, but not B in following snippet): <div id='A' class='foo-clas...

Enter key in textarea

I have a textarea, On every Enter key pressed in textarea I want new line to be started with a bullet say (*). How to go about it ? No jQuery please. I can observe for the Enter key , after that !? Should I have to get the whole value of textarea ...

How to solve error: "Clock skew detected"?

I am uploading my OpenCL and Cuda code to hgpu.org because I don't have a graphics card on my laptop. When I upload my code I get the following error: make: Warning: File `main.cu' has modification time 381 s in the future make: warning: Clock skew...

Converting string to number in javascript/jQuery

Been trying to convert the following to number: <button class="btn btn-large btn-info" data-votevalue="1"> <strong>1</strong> </button> var votevalue = parseInt($(this).data('votevalue')); I've also tried Number() but...

RecyclerView - How to smooth scroll to top of item on a certain position?

On a RecyclerView, I am able to suddenly scroll to the top of a selected item by using: ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(position, 0); However, this abruptly moves the item to the top position. I w...

SyntaxError: missing ; before statement

I am getting this error : SyntaxError: missing ; before statement Why would I get that from this code? How can I get around this ? var $this = $("input"); foob_name = $this.attr('name').replace(/\[(\d+)\]/, function($0, $1) { return '[' + (+$1...

How to set cursor to input box in Javascript?

document.getElementById(frmObj.id).value=""; document.getElementById(frmObj.id).autofocus; document.getElementById("errorMsg").innerHTML = "Only numeric value is allowed"; In the above code the value of the form object is perfectly setting to "" bu...

What Vim command(s) can be used to quote/unquote words?

How can I quickly quote/unquote words and change quoting (e.g. from ' to ") in Vim? I know about the surround.vim plugin, but I would like to use just Vim. ...

Maximum packet size for a TCP connection

What is the maximum packet size for a TCP connection or how can I get the maximum packet size?...

Cannot find mysql.sock

I just had to re-install mysql and I am having a problem starting it up. It cannot find the socket (mysql.sock). The problem is that neither can I. In my Mac OS X 10.4 terminal, I type: locate mysql.sock, and I get back /private/tmp/mysql.sock. I...

How to create major and minor gridlines with different linestyles in Python

I am currently using matplotlib.pyplot to create graphs and would like to have the major gridlines solid and black and the minor ones either greyed or dashed. In the grid properties, which=both/major/mine, and then color and linestyle are defined si...

Select multiple elements from a list

I have a list in R some 10,000 elements long. Say I want to select only elements, 5, 7, and 9. I'm not sure how I would do that without a for loop. I want to do something like mylist[[c(5,7,9]] but that doesn't work. I've also tried the lapply funct...

How to get file URL using Storage facade in laravel 5?

I've been experimenting using the new Flysystem integration with Laravel 5. I am storing 'localised' paths to the DB, and getting the Storage facade to complete the path. For example I store screenshots/1.jpg and using Storage::disk('local')->g...

Import python package from local directory into interpreter

I'm developing/testing a package in my local directory. I want to import it in the interpreter (v2.5), but sys.path does not include the current directory. Right now I type in sys.path.insert(0,'.'). Is there a better way? Also, from . import myp...

How to add style from code behind?

I want to add a style A:Hover to a HyperLink control from code behind. I can do like this : HyperLink hlRow = new HyperLink(); hlRow.Style.Add("color", "#000000"); hlRow.Style.Add("text-decoration", "none"); But how can I add styles for A:Hover f...

'Best' practice for restful POST response

So nothing new here I am just trying to get some clarification and cannot seem to find any in other posts. I am creating a new resource restulfully, say: /books (POST) with a body: { title: 'The Lion, the Witch and the Wardrobe', author: 'C....

c# datatable insert column at position 0

does anyone know the best way to insert a column in a datatable at position 0?...

Difference between single and double quotes in Bash

In Bash, what are the differences between single quotes ('') and double quotes ("")?...

Add tooltip to font awesome icon

Has anyone here added tooltips to font-awesome icons? I have the following jsfiddle, but cannot seem to find a guide to add tooltips to the icons. <header> <!-- icons for settings, change pwd and list of active sessions --> <div ...

nodemon not found in npm

I have a problem: nodemon does not run off the npm script (e.g. npm start), but if nodemon is called on the command line outside the npm script, nodemon runs as normal. $ nodemon server.js 14 Feb 22:59:51 - [nodemon] v1.3.7 14 Feb 22:59:51 - [nodemo...

How are Anonymous inner classes used in Java?

What is the use of anonymous classes in Java? Can we say that usage of anonymous class is one of the advantages of Java?...

Do Git tags only apply to the current branch?

I'm currently working with a repository that has multiple branches. When I create a tag, does that tag refer to the then-current branch? In other words: Whenever I create a tag, do I need to switch to the desired branch and tag inside that branch s...

How to change date format using jQuery?

I have a date in a format like this fecha2.value = '2014-01-06', but I want to change the format to this '01-06-14' using jQuery. How can I do this? Thanks in advance....

How to remove class from all elements jquery

I am changing the class of an element with the following $("#"+data.id).addClass("highlight") Given the list below. <div id="menuItems"> <ul id="contentLeft" class="edgetoedge"> <li class="sep" ">Shakes and Floats</l...

Easy way to build Android UI?

Is there a tool or a website that could help me create a UI for an Android application using drag-and-drop? I found this site but want to know if there is a more stable tool or website for this?...

Change tab bar tint color on iOS 7

Is there a way to change the tint of a tab bar on iOS 7 from the default white with blue icons to another color tint with different color buttons?...

Border Height on CSS

I have a table TD and on the right of it I want to add a 1 pixel border, so I've done this: table td { border-right:1px solid #000; } It works fine but the problem is that the border's height takes the total TD's height. Is there a way to set...

Oracle SQL: Use sequence in insert with Select Statement

Basically I want to run the following query: INSERT INTO historical_car_stats (historical_car_stats_id, year, month, make, model, region, avg_msrp, count) SELECT my_seq.nextval, '2010', '12', 'ALL', 'ALL', region, sum(a...

shorthand c++ if else statement

So I'm just curious if there is a short hand statement to this: if(number < 0 ) bigInt.sign = 0; else bigInt.sign = 1; I see all these short hand statements for if a < b and such. I'm not sure on how to do it properly and would like som...

How do I create test and train samples from one dataframe with pandas?

I have a fairly large dataset in the form of a dataframe and I was wondering how I would be able to split the dataframe into two random samples (80% and 20%) for training and testing. Thanks!...

How do I schedule a task to run at periodic intervals?

I was trying some codes to implement a scheduled task and came up with these codes . import java.util.*; class Task extends TimerTask { int count = 1; // run is a abstract method that defines task performed at scheduled time. public ...

How to echo print statements while executing a sql script

We have a simple sql script which needs to be executed against a MySQL database and we would like print log statements on the progress of the script (e.g. Inserted 10 records into foo or Deleted 5 records from bar). How do we do this? I would like ...

How to trim a string in SQL Server before 2017?

In SQL Server 2017, you can use this syntax, but not in earlier versions: SELECT Name = TRIM(Name) FROM dbo.Customer; ...

Webpack - webpack-dev-server: command not found

I am working on a React webapp using webpack, loosely alongside this tutorial. Accidentally, I added the node_modules folder to my git. I then removed it again using git rm -f node_modules/*. Now, when I try starting the webpack server, I get the f...

Web Reference vs. Service Reference

I just hit a huge brick wall with Paypal. I had created a regular C# project to create some wrapper classes using their WSDL. If you create a non-web project, the only option you get to add a wsdl is a Web Service Reference. And this builds kinda ...

element with the max height from a set of elements

I have a set of div elements. In jQuery, I would like to be able to find out the div with the maximum height and also the height of that div. For instance: <div> <div class="panel"> Line 1 Line 2 </div> <div class...

Printing pointers in C

I was trying to understand something with pointers, so I wrote this code: #include <stdio.h> int main(void) { char s[] = "asd"; char **p = &s; printf("The value of s is: %p\n", s); printf("The direction of s is: %p\n", &a...

How to run Tensorflow on CPU

I have installed the GPU version of tensorflow on an Ubuntu 14.04. I am on a GPU server where tensorflow can access the available GPUs. I want to run tensorflow on the CPUs. Normally I can use env CUDA_VISIBLE_DEVICES=0 to run on GPU no. 0. How c...

select into in mysql

I am a MSSQL user and now I am converting my database to MySQL. I am writing the following query in MySQL: select * into new_tbl from tbl And I get the following error Error : Undeclared variable new_tbl How such a query should be properly writ...

Align DIV to bottom of the page

I have a DIV that needs to be aligned to the bottom of a search result page, problem is whenever there is no search result or less rows of search result displayed on the page, the DIV goes up from the bottom of the page. but it should be placed li...

Node.js Generate html

I have created a JavaScript program which generates a list of data. Example output below: output one output two output three ... I would like to be able to generate a HTML file which can be saved to disk and opened with a browser. Below is a sa...

How to disable Home and other system buttons in Android?

I need to disable Home and other system buttons in my Android application. Example: MX Player (see at Google Play) - you can press "lock" icon at player screen and it locks all hardware and software system buttons. It works fine WITHOUT ROOTING. ...

org.postgresql.util.PSQLException: FATAL: sorry, too many clients already

I am trying to connect to a Postgresql database, I am getting the following Error: Error:org.postgresql.util.PSQLException: FATAL: sorry, too many clients already What does the error mean and how do I fix it? My server.properties file is follo...

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

I am using struts and hibernate. I have a parent and child relation using set in hbm. In the action I am using session.saveOrUpdate() method to save but while saving it is showing the below error. Can anyone help regardng this with explanation where ...

How do I check for a network connection?

What is the best way to determine if there is a network connection available?...

How to iterate through a list of dictionaries in Jinja template?

I tried: list1 = [{"username": "abhi", "pass": 2087}] return render_template("file_output.html", list1=list1) In the template: <table border=2> <tr> <td> Key </td> <td> Value </td>...

How to create multiple output paths in Webpack config

Does anyone know how to create multiple output paths in a webpack.config.js file? I'm using bootstrap-sass which comes with a few different font files, etc. For webpack to process these i've included file-loader which is working correctly, however th...

Initializing a static std::map<int, int> in C++

What is the right way of initializing a static map? Do we need a static function that will initialize it? ...

How to run Gulp tasks sequentially one after the other

in the snippet like this: gulp.task "coffee", -> gulp.src("src/server/**/*.coffee") .pipe(coffee {bare: true}).on("error",gutil.log) .pipe(gulp.dest "bin") gulp.task "clean",-> gulp.src("bin", {read:false}) .p...

How can I clear the terminal in Visual Studio Code?

I need to clean the contents of the terminal in Visual Studio Code. Every time I use Maven, the output of the terminal is attached to the previous build, which is confusing me. How do I clear the terminal window with some command or keyboard shortc...

How can I do string interpolation in JavaScript?

Consider this code: var age = 3; console.log("I'm " + age + " years old!"); Are there any other ways to insert the value of a variable in to a string, apart from string concatenation?...

How to return value from Action()?

In regards to the answer for this question Passing DataContext into Action(), how do I return a value from action(db)? SimpleUsing.DoUsing(db => { // do whatever with db }); Should be more like: MyType myType = SimpleUsing.DoUsing<MyType...

HTML5 Pre-resize images before uploading

Here's a noodle scratcher. Bearing in mind we have HTML5 local storage and xhr v2 and what not. I was wondering if anyone could find a working example or even just give me a yes or no for this question: Is it possible to Pre-size an image using the...

What are .NumberFormat Options In Excel VBA?

Can you please let me know what are the .NumberFormat format options in Excel VBA? As you are fully aware Excel 2010 supports the following types: I know that we can set for example Text type as: .NumberFormat ="@" or for number: .NumberF...

The view 'Index' or its master was not found.

The view 'Index' or its master was not found. The following locations were searched: ~/Views/ControllerName/Index.aspx ~/Views/ControllerName/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx I got this error when using ASP.Net mvc are...

What are best practices for REST nested resources?

As far as I can tell each individual resource should have only one canonical path. So in the following example what would good URL patterns be? Take for an example a rest representation of Companies. In this hypothetical example, each company owns ...

Parsing JSON using Json.net

I'm trying to parse some JSON using the JSon.Net library. The documentation seems a little sparse and I'm confused as to how to accomplish what I need. Here is the format for the JSON I need to parse through. { "displayFieldName" : "OBJECT_NAM...

Where to put default parameter value in C++?

What's the place for the default parameter value? Just in function definition, or declaration, or both places?...

How to generate serial version UID in Intellij

When I used Eclipse it had a nice feature to generate serial version UID. But what to do in IntelliJ? How to choose or generate identical serial version UID in IntelliJ? And what to do when you modify old class? If you haven't specify the id, it...

Make copy of an array

I have an array a which is constantly being updated. Let's say a = [1,2,3,4,5]. I need to make an exact duplicate copy of a and call it b. If a were to change to [6,7,8,9,10], b should still be [1,2,3,4,5]. What is the best way to do this? I tried a ...

How do I programmatically get the GUID of an application in .NET 2.0

I need to access the assembly of my project in C# .NET 2.0. I can see the GUID in the 'Assembly Information' dialog in under project properties, and at the moment I have just copied it to a const in the code. The GUID will never change, so this is no...

How to stretch div height to fill parent div - CSS

I have a page with divs like below <div id="container"> <div id="A"></div> <div id="B"> <div id="B1"></div> <div id="B2">B2</div>...

JavaScript how to get tomorrows date in format dd-mm-yy

I am trying to get JavaScript to display tomorrows date in format (dd-mm-yyyy) I have got this script which displays todays date in format (dd-mm-yyyy) var currentDate = new Date() var day = currentDate.getDate() var month = currentDate.getMonth() ...

How can I open Windows Explorer to a certain directory from within a WPF app?

In a WPF application, when a user clicks on a button I want to open the Windows explorer to a certain directory, how do I do that? I would expect something like this: Windows.OpenExplorer("c:\test"); ...

Why is volatile needed in C?

Why is volatile needed in C? What is it used for? What will it do?...

How to set a variable to be "Today's" date in Python/Pandas

I am trying to set a variable to equal today's date. I looked this up and found a related article: Set today date as default value in the model However, this didn't particularly answer my question. I used the suggested: dt.date.today But after...

What does T&& (double ampersand) mean in C++11?

I've been looking into some of the new features of C++11 and one I've noticed is the double ampersand in declaring variables, like T&& var. For a start, what is this beast called? I wish Google would allow us to search for punctuation like t...

Reading from memory stream to string

I am trying to write an object to an Xml string and take that string and save it to a DB. But first I need to get the string... private static readonly Encoding LocalEncoding = Encoding.UTF8; public static string SaveToString<T> (T se...

Split a large pandas dataframe

I have a large dataframe with 423244 lines. I want to split this in to 4. I tried the following code which gave an error? ValueError: array split does not result in an equal division for item in np.split(df, 4): print item How to split this da...

setting content between div tags using javascript

I'm trying to set some content in between some div tags on a JSP page using javascript. currently the div tag on the JSP page looks like this: <div id="successAndErrorMessages"></div> I want to fill the content in those div tags using...

What is a vertical tab?

What was the original historical use of the vertical tab character (\v in the C language, ASCII 11)? Did it ever have a key on a keyboard? How did someone generate it? Is there any language or system still in use today where the vertical tab charac...

Facebook Access Token for Pages

I have a Facebook Page that I want to get some things from it. First thing are feeds and from what I read they are public (no need for access_token). But I want to also get the events... and they aren't public and need the access_token. I don't want...

Python sockets error TypeError: a bytes-like object is required, not 'str' with send function

I am trying to create a program that will open a port on the local machine and let others connect into it via netcat. My current code is. s = socket.socket() host = '127.0.0.1' port = 12345 s.bind((host, port)) s.listen(5) while True: c, addr =...

Find distance between two points on map using Google Map API V2

I am using google map api v2 in my android application, I am able to show the map and put markers on it, but now I am stuck with the problem in which I need to find out the distance between two markers or points placed on map, I have already gone th...

What port is a given program using?

I want to be able to figure out what port a particular program is using. Are there any programs available online or that come with windows that will tell me which processes are using which ports on my computer? PS - before you downmod this for not ...

Practical uses of different data structures

There's a lot of talk about data structures, but I can't find a simple list of data structures and their practical use out there. I'm trying to study for an interview and I think this would help me out, along with many others. I'm looking for somet...

How to resolve Error listenerStart when deploying web-app in Tomcat 5.5?

I've deployed an Apache Wicket web-application that uses Spring and Hibernate to my Tomcat 5.5 instance. When I navigate to the Tomcat Manager interface I see that the web-application I deployed is not running. When I press 'Start' I get the followin...

TypeError: $.ajax(...) is not a function?

I'm trying to create a simple AJAX request which returns some data from a MySQL database. Here's my function below: function AJAXrequest(url, postedData, callback) { $.ajax() ({ type: 'POST', url: url, data: postedData, ...

How to get anchor text/href on click using jQuery?

Consider I have an anchor which looks like this <div class="res"> <a href="~/Resumes/Resumes1271354404687.docx"> ~/Resumes/Resumes1271354404687.docx </a> </div> NOTE: There won't be any id or class for ...

How do I remove a property from a JavaScript object?

Say I create an object as follows: let myObject = { "ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*" }; What is the best way to remove the property regex to end up wit...

Pip install Matplotlib error with virtualenv

I am trying to install matplotlib in a new virtualenv. When I do: pip install matplotlib or pip install http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz I get this error: building 'matplot...

Using Pip to install packages to Anaconda Environment

conda 4.2.13 MacOSX 10.12.1 I am trying to install packages from pip to a fresh environment (virtual) created using anaconda. In the Anaconda docs it says this is perfectly fine. It is done the same way as for virtualenv. Activate the enviro...

AttributeError: 'module' object has no attribute 'urlopen'

I'm trying to use Python to download the HTML source code of a website but I'm receiving this error. Traceback (most recent call last): File "C:\Users\Sergio.Tapia\Documents\NetBeansProjects\DICParser\src\WebDownload.py", line 3, in <modul...

How to create a temporary directory?

I use to create a tempfile, delete it and recreate it as a directory: temp=`tempfile` rm -f $temp # <breakpoint> mkdir $temp The problem is, when it runs to the <breakpoint>, there happens to be another program wants to do the same thi...

C++ array initialization

is this form of intializing an array to all 0s char myarray[ARRAY_SIZE] = {0} supported by all compilers? , if so, is there similar syntax to other types? for example bool myBoolArray[ARRAY_SIZE] = {false} ...

Change status bar text color to light in iOS 9 with Objective-C

In iOS 9, how do I change the color of the status bar text to white?...

JSONP call showing "Uncaught SyntaxError: Unexpected token : "

Here is my code $.ajax({ url: 'https://api.flightstats.com/flex/schedules/rest/v1/json/flight/AA/100/departing/2013/10/4?appId=19d57e69&appKey=e0ea60854c1205af43fd7b1203005d59&callback=?', dataType: 'JSONP', jsonpCall...

What is Turing Complete?

What does the expression "Turing Complete" mean? Can you give a simple explanation, without going into too many theoretical details?...

Combine two tables for one output

Say I have two tables: KnownHours: ChargeNum CategoryID Month Hours 111111 1 2/1/09 10 111111 1 3/1/09 30 111111 1 4/1/09 50 222222 1 3/1/09 40 111111 2...

Can you call Directory.GetFiles() with multiple filters?

I am trying to use the Directory.GetFiles() method to retrieve a list of files of multiple types, such as mp3's and jpg's. I have tried both of the following with no luck: Directory.GetFiles("C:\\path", "*.mp3|*.jpg", SearchOption.AllDirectories); ...

How to set menu to Toolbar in Android

I want use ToolBar instead of ActionBar, but don't show me menu in toolbar!!! i want set menu such as Refresh or Setting buttons in ActionBar. Toolbar.xml code : <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar ...

How to fill OpenCV image with one solid color?

How to fill OpenCV image with one solid color?...

Difference between "as $key => $value" and "as $value" in PHP foreach

I have a database call and I'm trying to figure out what the $key => $value does in a foreach loop. The reason I ask is because both these codes output the same thing, so I'm trying to understand why it's written this way. Here's the code: 1)In...

AJAX jQuery refresh div every 5 seconds

I got this code from a website which I have modified to my needs: <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> </head> <div id="links"> </div&g...

Difference between Git and GitHub

I have recently added a new project to Git using Eclipse, but do not see the project appear in my GitHub account. Why do they have the same account information and different repositories? Isn't Git and GitHub the same thing?...

Angular.js ng-repeat filter by property having one of multiple values (OR of values)

Is it possible to filter an array of objects, such that the value of property can be either of a few values (OR condition) without writing a custom filter This is similar to this problem - Angular.js ng-repeat :filter by single field But instead of...

BEGIN - END block atomic transactions in PL/SQL

This information should be easy to find, but I haven't had any luck. When I have a BEGIN - END block in a PL/SQL, does it behave as an atomic transaction, that will try to commit on hitting the END block and if anything goes wrong rolls back the cha...

Excel vba - convert string to number

So, I used the left function to take the first 4 characters of a string and I need to run a vlookup with it, but it won't find the match because it's looking through numbers. I want to do this in a macro, so I'm not sure about the syntax. Can someo...

"The stylesheet was not loaded because its MIME type, "text/html" is not "text/css"

I have a javascript application and when I run it on firefox I am getting the following erro on the console: "The stylesheet was not loaded because its MIME type, "text/html" is not "text/css". DumbStuck!! EDIT: Note that it tells that "Th...

Minimum and maximum value of z-index?

I have a div in my HTML page. I am showing this div based on some condition, but the div is displaying behind the HTML element where I pointed the mouse cursor. I have tried all values for z-index from 0 - 999999. Can anyone tell me why this is happ...

Code snippet or shortcut to create a constructor in Visual Studio

What is the code snippet or shortcut for creating a constructor in Visual Studio? Visual Studio 2010 and C#....

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

I keep getting the following errors with mysql connection through XAMPP and I don't know what to do: That's the code in the config.inc.php <?php /* * This is needed for cookie based authentication to encrypt password in * cookie */ $cfg['bl...

Sort an ArrayList based on an object field

Possible Duplicate: Sorting an ArrayList of Contacts I am storing DataNode objects in an ArrayList. The DataNode class has an integer field called degree. I want to retrieve DataNode objects from nodeList in the increasing order of degree....

ModalPopupExtender OK Button click event not firing?

I have a Button inside an UpdatePanel. The button is being used as the OK button for a ModalPopupExtender. For some reason, the button click event is not firing. Any ideas? Am I missing something? <asp:updatepanel id="UpdatePanel1" runat="ser...

The best node module for XML parsing

As far as XML parsing is concerned, which is the best node module, that I can use for XML parsing?...

How to add a single item to a Pandas Series

How Do I add a single item to a serialized panda series. I know it's not the most efficient way memory wise, but i still need to do that. Something along: >> x = Series() >> N = 4 >> for i in xrange(N): >> x.some_appendi...

Edit a specific Line of a Text File in C#

I have two text files, Source.txt and Target.txt. The source will never be modified and contain N lines of text. So, I want to delete a specific line of text in Target.txt, and replace by an specific line of text from Source.txt, I know what number o...

How to inspect FormData?

I've tried console.log and looping through it using for in. Here it the MDN Reference on FormData. Both attempts are in this fiddle. var fd = new FormData(), key; // poulate with dummy data fd.append("key1", "alskdjflasj"); fd.append("key2...

Using union and order by clause in mysql

I want to use order by with union in mysql query. I am fetching different types of record based on different criteria from a table based on distance for a search on my site. The first select query returns data related to the exact place search . The ...

Best practice: PHP Magic Methods __set and __get

Possible Duplicate: Are Magic Methods Best practice in PHP? These are simple examples, but imagine you have more properties than two in your class. What would be best practice? a) Using __get and __set class MyClass { private $first...

Differences between time complexity and space complexity?

I have seen that in most cases the time complexity is related to the space complexity and vice versa. For example in an array traversal: for i=1 to length(v) print (v[i]) endfor Here it is easy to see that the algorithm complexity in terms of ...

Selenium Webdriver move mouse to Point

I am currently trying to move the cursor to a point (org.openqa.selenium.Point) that has been set by checking for an occurrence of a marker on a live chart from which I can get no details but can find the X and Y coordinates of. How can I move to the...

How to pass argument to Makefile from command line?

How to pass argument to Makefile from command line? I understand I can do $ make action VAR="value" $ value with Makefile VAR = "default" action: @echo $(VAR) How do I get the following behavior? $ make action value value ? How about ...

How to Load an Assembly to AppDomain with all references recursively?

I want to load to a new AppDomain some assembly which has a complex references tree (MyDll.dll -> Microsoft.Office.Interop.Excel.dll -> Microsoft.Vbe.Interop.dll -> Office.dll -> stdole.dll) As far as I understood, when an assembly is being loaded t...

How can I list all cookies for the current page with Javascript?

Is there any way to, with help of Javascript, list all cookies associated with the current page? That is, if I don't know the names of the cookies but want to retrieve all the information they contain....

max(length(field)) in mysql

If I say: select max(length(Name)) from my_table I get the result as 18, but I want the concerned data also. So if I say: select max(length(Name)), Name from my_table ...it does not work. There should be a self join I guess which...

Right align and left align text in same HTML table cell

I have a cell in an HTML <table>. I would like part of the cell contents to be left justified and part to be right justified. Is this possible?...

Print "\n" or newline characters as part of the output on terminal

I'm running Python on terminal Given a string string = "abcd\n" I'd like to print it somehow so that the newline characters '\n' in abcd\n would be visible rather than go to the next line Can I do this without having to modify the string and addin...

Is there a conditional ternary operator in VB.NET?

In Perl (and other languages) a conditional ternary operator can be expressed like this: my $foo = $bar == $buz ? $cat : $dog; Is there a similar operator in VB.NET?...

How to run Rake tasks from within Rake tasks?

I have a Rakefile that compiles the project in two ways, according to the global variable $build_type, which can be :debug or :release (the results go in separate directories): task :build => [:some_other_tasks] do end I wish to create a task t...

SSH to Vagrant box in Windows?

I'm using Vagrant to start a VirtualBox VM in windows. In other platforms, I can just $ vagrant ssh to connect to the VM. How do i connect to this Vagrant box in windows? The way suggested in Vagrant documentation to use PuTTy also did not work:...

How to add/subtract time (hours, minutes, etc.) from a Pandas DataFrame.Index whos objects are of type datetime.time?

I've got a DataFrame who's index is just datetime.time and there's no method in DataFrame.Index and datetime.time to shift the time. datetime.time has replace but that'll only work on individual items of the Series? Here's an example of the index ...

SQL Sum Multiple rows into one

I need some help with the SUM feature. I am trying to SUM the bill amounts for the same account into one grand total, but the results I am getting show my SUM column just multiples my first column by 3. Here is what I want as results for my mock da...

How to block until an event is fired in c#

After asking this question, I am wondering if it is possible to wait for an event to be fired, and then get the event data and return part of it. Sort of like this: private event MyEventHandler event; public string ReadLine(){ return event.waitForVa...

How to send a simple email from a Windows batch file?

I'm running Windows 2003 Service Pack 2. I have a batch file that runs on demand. I want to have an email sent every time the batch file runs. The email is simple, just a sentence indicating that the batch file ran; it is the same every time. I've t...

How do I rename a file using VBScript?

I am trying to rename a file and was using the below code but it does not seem to work. Can someone please tell me why? What is the correct way to rename a file from VBScript? FSO.GetFile("MyFile.txt).Name = "Hello.txt" I am using this thread for ...

Force browser to refresh css, javascript, etc

I'm developing a website based on Wordpress source code through XAMPP. Sometimes I change the CSS code, scrips or something else and I notice my browser takes time to apply the modifications. This leads me to use multiple browsers to refresh one and ...

understanding private setters

I don't understand the need of having private setters which started with C# 2. Having a setter method for me is letting the user to set some variables in that class. In doing so, we will not expose the variables directly to the users. Instead we le...

SQL Joins Vs SQL Subqueries (Performance)?

I wish to know if I have a join query something like this - Select E.Id,E.Name from Employee E join Dept D on E.DeptId=D.Id and a subquery something like this - Select E.Id,E.Name from Employee Where DeptId in (Select Id from Dept) When I cons...

What does string::npos mean in this code?

What does the phrase std::string::npos mean in the following snippet of code? found = str.find(str2); if (found != std::string::npos) std::cout << "first 'needle' found at: " << int(found) << std::endl; ...

What is the easiest way to push an element to the beginning of the array?

I can't think of a one line way to do this. Is there a way?...

Disable all gcc warnings

I'm working on a project that will read compiler error messages of a particular variety and do useful things with them. The sample codebase I'm testing this on (a random open-source application), and hence rebuilding frequently, contains a few bits t...

printf and long double

I am using the latest gcc with Netbeans on Windows. Why doesn't long double work? Is the printf specifier %lf wrong? Code: #include <stdio.h> int main(void) { float aboat = 32000.0; double abet = 5.32e-5; long double dip = 5.32e-...

Advantages of SQL Server 2008 over SQL Server 2005?

What are the key differences between Microsoft's SQL Server 2005 and SQL Server 2008? Are there any compelling reasons for upgrading (any edition, as I have a customer with multiple editions)? Or is there a website with either a chart or bullet po...

Checkboxes in web pages – how to make them bigger?

The standard checkboxes rendered in most browsers are quite small and don’t increase in size even when a larger font is used. What is the best, browser-independent way to display larger checkboxes?...

C++ float array initialization

Possible Duplicate: C and C++ : Partial initialization of automatic structure While reading Code Complete, I came across an C++ array initialization example: float studentGrades[ MAX_STUDENTS ] = { 0.0 }; I did not know C++ could init...

Java: parse int value from a char

I just want to know if there's a better solution to parse a number from a character in a string (assuming that we know that the character at index n is a number). String element = "el5"; String s; s = ""+element.charAt(2); int x = Integer.parseInt(s...

how do I query sql for a latest record date for each user

I have a table that is a collection entries as to when a user was logged on. username, date, value -------------------------- brad, 1/2/2010, 1.1 fred, 1/3/2010, 1.0 bob, 8/4/2009, 1.5 brad, 2/2/2010, 1.2 fred, 12/2/200...

Why dividing two integers doesn't get a float?

Can anyone explain why b gets rounded off here when I divide it by an integer although it's a float? #include <stdio.h> void main() { int a; float b, c, d; a = 750; b = a / 350; c = 750; d = c / 350; printf("%.2f %...

Button text toggle in jquery

When i click ".pushme" button, it turns its text to "Don't push me". I want to turn the text again to "push me" when button is clicked again. How can i do that? <html> <head> <script src="http://code.jquery.com/jquery-latest.js"&...

How to set cell spacing and UICollectionView - UICollectionViewFlowLayout size ratio?

I'm trying to add UICollectionView to ViewController, and I need to have 3 cells 'per row' without blank space between cells (it should look like a grid). Cell width should be one third of screen size, so I thought that the layout.item width should b...

Know relationships between all the tables of database in SQL Server

I wish to all know how the tables in my database are related to each other (i.e PK/FK/UK) and hence i created a database diagram of all my tables in SQL Server. The diagram that was created was not easily readable and had to scroll (horizontally and ...

HTML5 - mp4 video does not play in IE9

I have an mp4 video that I want to play in IE9 using HTML5 <video> tag. I added the MIME type to IIS 7 so if I browse http://localhost/video.mp4 it plays in both Chrome and IE9 but not in HTML5, Chrome plays the video in HTML though. Here's th...

Executing multiple commands from a Windows cmd script

I'm trying to write a Windows cmd script to perform several tasks in series. However, it always stops after the first command in the script. The command it stops after is a maven build (not sure if that's relevant). How do I make it carry on and ru...

How to find the files that are created in the last hour in unix

How to find the files that are created in the last hour in unix...

implement time delay in c

I don't know exactly how to word a search for this.. so I haven't had any luck finding anything.. :S I need to implement a time delay in C. for example I want to do some stuff, then wait say 1 minute, then continue on doing stuff. Did that make se...

Android button with different background colors

i want to change the background-color of a button using a selector-xml-file. My approach is basically the one from the example at the bottom this page: http://developer.android.com/guide/topics/resources/color-list-resource.html i have a res/color/b...

Android: where are downloaded files saved?

I am trying to develop a "document manager" I have the necessity of accessing the files downloaded from the internet, from Gmail, for other mail clients, from other internet sources... I would like to understand where these files are stored exactly...

Entity Framework Core add unique constraint code-first

I can't find way to add a unique constraint to my field with using attribute: public class User { [Required] public int Id { get; set; } [Required] // [Index("IX_FirstAndSecond", 2, IsUnique = true)] not supported by core public...

isPrime Function for Python Language

So I was able to solve this problem with a little bit of help from the internet and this is what I got: def isPrime(n): for i in range(2,int(n**0.5)+1): if n%i==0: return False return True But my question really ...

Select all where [first letter starts with B]

This is a follow up question to my previous one. I want to write a MYSQL statement that echoes every entry that starts with letter B. Function.php function getCategory() { $query = mysql_query("SELECT author FROM lyrics WHERE author [starts with l...

How do I use dataReceived event of the SerialPort Port Object in C#?

I am attempting to create a small application to collect data received from an external sensor attached to COM10. I have successfully created a small C# console object and application that opens the port and streams data to a file for a fixed period...

Error when trying vagrant up

I'm using Vagrant for my environment and I've got a little issue: $vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Box 'base' could not be found. Attempting to find and install... default: Box Provider: vi...

Python and JSON - TypeError list indices must be integers not str

I am learning to use Python and APIs (specifically, this World Cup API, http://www.kimonolabs.com/worldcup/explorer) The JSON data looks like this: [ { "firstName": "Nicolas Alexis Julio", "lastName": "N'Koulou N'Doubena", "nickname":...

Java synchronized block vs. Collections.synchronizedMap

Is the following code set up to correctly synchronize the calls on synchronizedMap? public class MyClass { private static Map<String, List<String>> synchronizedMap = Collections.synchronizedMap(new HashMap<String, List<String>...

Set folder browser dialog start location

Is there any way to set the initial directory of a folder browser dialog to a non-special folder? This is what I'm currently usingfdbLocation.RootFolder = Environment.SpecialFolder.Desktop; but I want to use a path I have stored in a string somethin...

Difference between `constexpr` and `const`

What's the difference between constexpr and const? When can I use only one of them? When can I use both and how should I choose one? ...

"Actual or formal argument lists differs in length"

When I try to put something in the () brackets of Friends f = new Friends(friendsName, friendsAge); it comes up with the error: Constructor Friends in class Friends cannot by applied to given types. Required: no arguments. Found: String, int. ...

How to call another components function in angular2

I have two components as follows and I want to call a function from another component. Both components are included in the third parent component using directive. Component 1: @component( selector:'com1' ) export class com1{ function1(){....

How do I parse command line arguments in Java?

What is a good way of parsing command line arguments in Java?...

how to convert numeric to nvarchar in sql command

I need to convert a numeric value to nvarchar in sql command. Can anyone please help me....

Send HTTP GET request with header

From my Android app I want to request a URL with GET parameters and read the response. In the request I must add a x-zip header. The URL is something like http://example.com/getmethod.aspx?id=111&method=Test Can some one provide me code for ...

How to check if a file exists in a shell script

I'd like to write a shell script which checks if a certain file, archived_sensor_data.json, exists, and if so, deletes it. Following http://www.cyberciti.biz/tips/find-out-if-file-exists-with-conditional-expressions.html, I've tried the following: [...

Java Code for calculating Leap Year

I am following "The Art and Science of Java" book and it shows how to calculate a leap year. The book uses ACM Java Task Force's library. Here is the code the books uses: import acm.program.*; public class LeapYear extends ConsoleProgram { pub...

What are the rules about using an underscore in a C++ identifier?

It's common in C++ to name member variables with some kind of prefix to denote the fact that they're member variables, rather than local variables or parameters. If you've come from an MFC background, you'll probably use m_foo. I've also seen myFoo o...

Android: How to set password property in an edit text?

I need to create a login form with 'username' 'password' fields and two buttons 'login' and 'cancel' in my android application. I am using an alert dialog with edittext inside that. This is the code I used to create password edittext.. fina...

Writing unit tests in Python: How do I start?

I completed my first proper project in Python and now my task is to write tests for it. Since this is the first time I did a project, this is the first time I would be writing tests for it. The question is, how do I start? I have absolutely no idea...

Can you append strings to variables in PHP?

Why does the following code output 0? It works with numbers instead of strings just fine. I have similar code in JavaScript that also works. Does PHP not like += with strings? <?php $selectBox = '<select name="number">'; for ($i=1;...

Adjusting the Xcode iPhone simulator scale and size

Is there anyway to make the iOS simulator for iPhone 5 in Xcode, be the actual size of the iPhone 5. I'm getting a huge display and things seemed to be scaled....

Permutation of array

For example I have this array: int a[] = new int[]{3,4,6,2,1}; I need list of all permutations such that if one is like this, {3,2,1,4,6}, others must not be the same. I know that if the length of the array is n then there are n! possible combina...

removing bold styling from part of a header

Is there a way to remove bold styling from part of a header? <h1>**This text should be bold**, but this text should not</h1> Is there a way to accomplish this?...

Subprocess changing directory

I want to execute a script inside a subdirectory/superdirectory (I need to be inside this sub/super-directory first). I can't get subprocess to enter my subdirectory: tducin@localhost:~/Projekty/tests/ve$ python Python 2.7.4 (default, Sep 26 2013, 0...

How do I determine k when using k-means clustering?

I've been studying about k-means clustering, and one thing that's not clear is how you choose the value of k. Is it just a matter of trial and error, or is there more to it?...

IOError: [Errno 13] Permission denied

I have this piece of code to create a .json file to store python data. When i run it in my server i get this error: IOError: [Errno 13] Permission denied: 'juliodantas2015.json' at line with open(output_file, 'wb') as fp: Python code: fich_input=...

How can I rollback a git repository to a specific commit?

My repo has 100 commits in it right now. I need to rollback the repository to commit 80, and remove all the subsequent ones. Why? This repo is supposed to be for merging from miscellaneous users. A bunch of merges went in as commits from me, due to e...

ASP.NET Core 1.0 on IIS error 502.5

I just updated my server (Windows 2012R2) to .Net Core 1.0 RTM Windows Hosting pack from the previous .Net Core 1.0 RC2. My app works on my PC without any issues but the server keeps showing: HTTP Error 502.5 - Process Failure Common causes of thi...

Horizontal scroll on overflow of table

I have a basic table in a container. The table will have about 25 columns. I am trying to add a horizontal scroll bar on overflow of the table and am having a really tough time. What is happening now, is the table cells are accommodating the cells ...

Get keys of a Typescript interface as array of strings

I've a lot of tables in Lovefield and their respective Interfaces for what columns they have. Example: export interface IMyTable { id: number; title: string; createdAt: Date; isDeleted: boolean; } I'd like to have the property names of this ...

Force Internet Explorer to use a specific Java Runtime Environment install?

When viewing someone else's webpage containing an applet, how can I force Internet Explorer 6.0 to use a a particular JRE when I have several installed?...

How to break out of jQuery each Loop

How do I break out of a jQuery each loop? I have tried: return false; In the loop but this did not work. Any ideas? Update 9/5/2020 I put the return false; in the wrong place. When I put it inside the loop everything worked....

Use tnsnames.ora in Oracle SQL Developer

I am evaluating Oracle SQL Developer. My tnsnames.ora is populated, and a tnsping to a connection defined in tnsnames.ora works fine. Still, SQL Developer does not display any connections. Oracle SQL Developer Soars mentions, that if you have ...

Count the number occurrences of a character in a string

What's the simplest way to count the number of occurrences of a character in a string? e.g. count the number of times 'a' appears in 'Mary had a little lamb'...

Can you use @Autowired with static fields?

Is there some way to use @Autowired with static fields. If not, are there some other ways to do this?...

Convert a dataframe to a vector (by rows)

I have a dataframe with numeric entries like this one test <- data.frame(x = c(26, 21, 20), y = c(34, 29, 28)) How can I get the following vector? > 26, 34, 21, 29, 20, 28 I was able to get it using the following, but I guess there should...

Java Singleton and Synchronization

Please clarify my queries regarding Singleton and Multithreading: What is the best way to implement Singleton in Java, in a multithreaded environment? What happens when multiple threads try to access getInstance() method at the same time? Can we ma...

Add newly created specific folder to .gitignore in Git

I had a clean working directory and brought in a clone from a Git repo last night. But now my local server created and contains a stats folder which I want to ignore. I can't seem to get Git to ignore this folder when I run a git status. On branc...

SQL: capitalize first letter only

I need an SQL statement to capitalize the first letter of each word. The other characters have to be lower case. The words can be like this: wezembeek-oppem roeselare BRUGGE louvain-la-neuve Which would have to be: Wezembeek-Oppem Roeselare Brug...

C++ template typedef

I have a class template<size_t N, size_t M> class Matrix { // .... }; I want to make a typedef which creates a Vector (column vector) which is equivalent to a Matrix with sizes N and 1. Something like that: typedef Matrix<N,1> Vec...

Subset data to contain only columns whose names match a condition

Is there a way for me to subset data based on column names starting with a particular string? I have some columns which are like ABC_1 ABC_2 ABC_3 and some like XYZ_1, XYZ_2,XYZ_3 let's say. How can I subset my df based only on columns containing th...

C++ "was not declared in this scope" compile error

New to C++. In the following program I'm writing I get this error: g++ -o Blob blob.cc blob.cc: In function 'int nonrecursivecountcells(color (*)[7], int, int)': blob.cc:41: error: 'grid' was not declared in this scope Here is the code: #include ...

Python's equivalent of && (logical-and) in an if-statement

Here's my code: def front_back(a, b): # +++your code here+++ if len(a) % 2 == 0 && len(b) % 2 == 0: return a[:(len(a)/2)] + b[:(len(b)/2)] + a[(len(a)/2):] + b[(len(b)/2):] else: #todo! Not yet done. :P return I'm getting ...

Converting Pandas dataframe into Spark dataframe error

I'm trying to convert Pandas DF into Spark one. DF head: 10000001,1,0,1,12:35,OK,10002,1,0,9,f,NA,24,24,0,3,9,0,0,1,1,0,0,4,543 10000001,2,0,1,12:36,OK,10002,1,0,9,f,NA,24,24,0,3,9,2,1,1,3,1,3,2,611 10000002,1,0,4,12:19,PA,10003,1,1,7,f,NA,74,74,0,2...

PHP: HTML: send HTML select option attribute in POST

I want to send the selected item value along with some attribute (stud_name) value. Is there any functionality in PHP to do so? Here is the example one. <form name="add"> Age: <select name="age"> <...

How do I activate a specific workbook and a specific sheet?

How do I activate my Other workbook from the Current workbook? I have a current workbook with dumb.xls and The other workbook name as Tire.xls.I have opened the Tire.xls from the dumb.xls using worksbooks.open filename:= "name of the file".Its gettin...

console.log(result) returns [object Object]. How do I get result.name?

My script is returning [object Object] as a result of console.log(result). Can someone please explain how to have console.log return the id and name from result? $.ajaxSetup({ traditional: true }); var uri = ""; $("#enginesOuputWaiter").show(); ...