Examples On Programing Languages

How can I exclude one word with grep?

I need something like: grep ^"unwanted_word"XXXXXXXX ...

How to "properly" print a list?

So I have a list: ['x', 3, 'b'] And I want the output to be: [x, 3, b] How can I do this in python? If I do str(['x', 3, 'b']), I get one with quotes, but I don't want quotes....

Java keytool easy way to add server cert from url/port

I have a server with a self signed certificate, but also requires client side cert authentication. I am having a rough time trying to get the raw CA server cert so I can import it into a keystore. Anyone have some suggestions on how to easily do that...

How to split a single column values to multiple column values?

I have a problem splitting single column values to multiple column values. For Example: Name ------------ abcd efgh ijk lmn opq asd j. asdjja asb (asdfas) asd asd and I need the output something like this: first_name last_name ------...

How to find when a web page was last updated

Is there a way to find out how much time has passed since a web page was changed? For example, I have a page hosted at: www.mywebsitenotupdated.com Is there a way to find out when this HTML page was uploaded to the server? I have no access to se...

Single Page Application: advantages and disadvantages

I've read about SPA and it advantages. I find most of them unconvincing. There are 3 advantages that arouse my doubts. Question: Can you act as advocate of SPA and prove that I am wrong about first three statements? ==...

AlertDialog.Builder with custom layout and EditText; cannot access view

I am trying to create an alert dialog with an EditText object. I need to set the initial text of the EditText programmatically. Here's what I have. AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); // ...Irrelevant code for customiz...

How do I hide javascript code in a webpage?

Is it possible to hide the Javascript code from the html of a webpage, when the source code is viewed through the browsers View Source feature? I know it is possible to obfuscate the code, but I would prefer it being hidden from the view source fea...

100% Min Height CSS layout

What's the best way to make an element of 100% minimum height across a wide range of browsers ? In particular if you have a layout with a header and footer of fixed height, how do you make the middle content part fill 100% of the space in bet...

How do I choose grid and block dimensions for CUDA kernels?

This is a question about how to determine the CUDA grid, block and thread sizes. This is an additional question to the one posted here. Following this link, the answer from talonmies contains a code snippet (see below). I don't understand the commen...

How to window.scrollTo() with a smooth effect

I can scroll to 200px using the following btn.addEventListener("click", function(){ window.scrollTo(0,200); }) But I want a smooth scroll effect. How do I do this?...

Copying files using rsync from remote server to local machine

Once I've ssh'd into my remote server, what would the command be to copy all files from a directory to a local directory on my machine?...

How to include another XHTML in XHTML using JSF 2.0 Facelets?

What is the most correct way to include another XHTML page in an XHTML page? I have been trying different ways, none of them are working....

How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator

I have the following simple code written in Swift 3: let str = "Hello, playground" let index = str.index(of: ",")! let newStr = str.substring(to: index) From Xcode 9 beta 5, I get the following warning: 'substring(to:)' is deprecated: Please u...

How to get a ListBox ItemTemplate to stretch horizontally the full width of the ListBox?

I want to have the ListItems to extend with their orange background the full width of the Listbox. Currently they are only as wide as the FirstName + LastName. I've set every element I can to: HorizontalAlignment="Stretch". I want the background o...

Python functions call by reference

In some languages you can pass a parameter by reference or value by using a special reserved word like ref or val. When you pass a parameter to a Python function it never alters the value of the parameter on leaving the function.The only way to do th...

AngularJS is rendering <br> as text not as a newline

I am sure this has been asked before but I cannot find the answer. I have an AngularJS script that is pulling from a DB and then rendering to content. Everything is working correctly except a couple of places that I am trying to concatenate some wo...

Creating a file name as a timestamp in a batch job

We have a batch job that runs every day and copies a file to a pickup folder. I want to also take a copy of that file and drop it into an archive folder with the filename yyyy-MM-dd.log What's the easiest way to do this in a Windows batch job? I...

In Laravel, the best way to pass different types of flash messages in the session

I'm making my first app in Laravel and am trying to get my head around the session flash messages. As far as I'm aware in my controller action I can set a flash message either by going Redirect::to('users/login')->with('message', 'Thanks for regi...

How to host a Node.Js application in shared hosting

How to host a Node.Js application in a shared hosting I want to host a node.js application in shared hosting. Does anyone have any reference or documentation to refer to?...

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

Setting an int to Infinity in C++

I have an int a that needs to be equal to "infinity". This means that if int b = anyValue; a>b is always true. Is there any feature of C++ that could make this possible?...

Is Eclipse the best IDE for Java?

Is Eclipse the best IDE for Java? If not, is there something better? I want to know and possibly try it out. Thanks....

ASP.NET set hiddenfield a value in Javascript

I don't know how to set the value of a hiddenField in Javascript. Can somebody show me how to do this? Javascript: document.getElementById('hdntxtbxTaksit').value = ""; HTML: <asp:HiddenField ID="hdntxtbxTaksit" runat="server" Value="" Visib...

How to test an Oracle Stored Procedure with RefCursor return type?

I'm looking for a good explanation on how to test an Oracle stored procedure in SQL Developer or Embarcardero Rapid XE2. Thank you....

How to make html <select> element look like "disabled", but pass values?

When I'm disabling a <select name="sel" disabled> <option>123</option> </select> element, it doesnt pass its variable. What to do to look it like disabled, but be in "normal" state? This is because I have a list of "...

iterating through Enumeration of hastable keys throws NoSuchElementException error

I am trying to iterate through a list of keys from a hash table using enumeration however I keep getting a NoSuchElementException at the last key in list? Hashtable<String, String> vars = new Hashtable<String, String>(); vars.put("POST...

C# how to convert File.ReadLines into string array?

The question that I have is regarding converting the process of reading lines from a text file into an array instead of just reading it. The error in my codes appear at string[] lines = File.ReadLines("c:\\file.txt"); with cannot implicity convert.....

Django - "no module named django.core.management"

I get the following error when trying to run Django from the command line. File manage.py, line 8, in <module>      from django.core.management import execute_from_command_line ImportError: No module named django.core.management Any idea...

J2ME/Android/BlackBerry - driving directions, route between two locations

On Android 1.0 there was a com.google.googlenav namespace for driving directions: Route - Improved Google Driving Directions But in newer SDK it was removed by some reason... Android: DrivingDirections removed since API 1.0 - how to do it in 1.5/1.6?...

How to read until EOF from cin in C++

I am coding a program that reads data directly from user input and was wondering how could I (without loops) read all data until EOF from standard input. I was considering using cin.get( input, '\0' ) but '\0' is not really the EOF character, that ju...

How to use class from other files in C# with visual studio?

I am a newbie of C# and MS visual studio, and I want to use the C# class which defined in another file, but can't get it work. Here is the program.cs(and why can't I rename that file ?) using System; namespace TestCSharp2 { class Program {...

"pip install unroll": "python setup.py egg_info" failed with error code 1

I'm new to Python and have been trying to install some packages with pip. But pip install unroll gives me Command "python setup.py egg_info" failed with error code 1 in C:\Users\MARKAN~1\AppData\Local\Temp\pip-build-wa7uco0k\unroll\ How can...

Check if a string is a valid date using DateTime.TryParse

I am using DateTime.TryParse() function to check if a particular string is a valid datetime not depending on any cultures. To my surprise , the function returns true for even strings like "1-1", "1/1" .etc. How can I solve this problem? Update: D...

How to make zsh run as a login shell on Mac OS X (in iTerm)?

When zsh is set as a login shell on Mac OS X, when it is started by iTerm, zsh doesn't consider that it's being run as a login shell, although it's started as ‘-zsh’ (‘-’ is put as the first character of arg[0]) which is supposed to mean that...

How to close Android application?

I want to close my application, so that it no longer runs in the background. How to do that? Is this good practice on Android platform? If I rely on the "back" button, it closes the app, but it stays in background. There is even application called ...

How to get the Touch position in android?

I need to get the touch begin position (X, Y) , touch move position and touch end position of the screen in android....

Best practices for catching and re-throwing .NET exceptions

What are the best practices to consider when catching exceptions and re-throwing them? I want to make sure that the Exception object's InnerException and stack trace are preserved. Is there a difference between the following code blocks in the way th...

Set output of a command as a variable (with pipes)

Can you redirect the output of a command to a variable with pipes? I haven't tried much as I haven't been able to think of anything to try, but I have tried one method (with two variations)... For example: echo Hello|set text= Didn't work, neith...

How do I generate a constructor from class fields using Visual Studio (and/or ReSharper)?

I've gotten accustomed to many of the Java IDEs (Eclipse, NetBeans, and IntelliJ IDEA) providing you with a command to generate a default constructor for a class based on the fields in the class. For example: public class Example { public decim...

Installing Tomcat 7 as Service on Windows Server 2008

I want to install my tomcat v7.0.12 as a service on my Windows 2008 Server. On the tomcat page I found this tutorial. But there isn't a service.bat file in my installation dir. In the service overview of WS2008 it isn't possible easily create a new ...

How do I store the select column in a variable?

How do I store the select column in a variable? I tried this, but it throws me an error "Incorrect syntax": declare @EmpId int SELECT dbo.Employee.Id as @EmpId FROM dbo.Employee ...

Can't pickle <type 'instancemethod'> when using multiprocessing Pool.map()

I'm trying to use multiprocessing's Pool.map() function to divide out work simultaneously. When I use the following code, it works fine: import multiprocessing def f(x): return x*x def go(): pool = multiprocessing.Pool(processes=4) ...

Equivalent of Oracle's RowID in SQL Server

What's the equivalent of Oracle's RowID in SQL Server?...

C multi-line macro: do/while(0) vs scope block

Possible Duplicates: What’s the use of do while(0) when we define a macro? Why are there sometimes meaningless do/while and if/else statements in C/C++ macros? do { … } while (0) what is it good for? I've seen some multi-l...

What is phtml, and when should I use a .phtml extension rather than .php?

I'm wondering what the difference between .phtml and .php files is, and when to use one over the other....

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

Using CMake to generate Visual Studio C++ project files

I am working on an open source C++ project, for code that compiles on Linux and Windows. I use CMake to build the code on Linux. For ease of development setup and political reasons, I must stick to Visual Studio project files/editor on Windows (I can...

jQuery get the image src

I hope when I click the button, I can get the specific img src and show the img src in the div class img-block block. HTML <button class="button">Click</button> <div class="img1"> <img src="img.jpg" alt=""> </div> ...

Why does Math.Round(2.5) return 2 instead of 3?

In C#, the result of Math.Round(2.5) is 2. It is supposed to be 3, isn't it? Why is it 2 instead in C#?...

Official way to ask jQuery wait for all images to load before executing something

In jQuery when you do this: $(function() { alert("DOM is loaded, but images not necessarily all loaded"); }); It waits for the DOM to load and executes your code. If all the images are not loaded then it still executes the code. This is obvious...

bootstrap 3 wrap text content within div for horizontal alignment

My post title here could be misleading. first have a look at HTML i have currently: As you can see, each column's text content overflows to next column. Secondly, each of them is not horizontal aligned. (eg the link for view details does not align ...

SVN: Folder already under version control but not comitting?

mark@mark-ubuntu:~/myproject$ svn stat ? runserver.sh ? media/images/icons ? apps/autocomplete mark@mark-ubuntu:~/myproject$ svn add apps/autocomplete svn: warning: 'apps/autocomplete' is already under version control svn stat say...

Java ArrayList - Check if list is empty

How can I check if a list is empty? If so, the system has to give a message saying List is empty. If not, the system has to give a message saying List is not empty. Users can enter numbers, -1 to stop the program. This is the code I now have, but thi...

How to add an image to the "drawable" folder in Android Studio?

I need to add an image to the res/drawable folder... When I choose new > Image Asset, it comes out a dialog to choose Asset Type... How can I add an image to res/drawable folder?...

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 are the differences and similarities between ffmpeg, libav, and avconv?

When I run ffmpeg on Ubuntu, it shows: $ ffmpeg ffmpeg version v0.8, Copyright (c) 2000-2011 the Libav developers built on Feb 28 2012 13:27:36 with gcc 4.6.1 This program is not developed anymore and is only provided for compatibility. Use avcon...

No serializer found for class org.hibernate.proxy.pojo.javassist.Javassist?

I am working on SpringMVC, Hibernate & JSON but I am getting this error. HTTP Status 500 - Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create Be...

How can I remove item from querystring in asp.net using c#?

I want remove "Language" querystring from my url. How can I do this? (using Asp.net 3.5 , c#) Default.aspx?Agent=10&Language=2 I want to remove "Language=2", but language would be the first,middle or last. So I will have this...

What are the most common font-sizes for H1-H6 tags

I've always been unsure of where to start as a general best practice baseline. Yes, I know it depends on your design, but what's most common? Here's what I currently have as a starter: h1 { font-size: 24px;} h2 { font-size: 22px;} h3 { font-size: 18p...

Why does CreateProcess give error 193 (%1 is not a valid Win32 app)

The code below fails to start documents. I get error 193 (%1 is not a valid Win32 app). Starting executables work fine. The files are properly associated, they start the corresponding app when double clicked. I have searched SO and elsewhere for the ...

Change drive in git bash for windows

I was trying to navigate to my drive location E:/Study/Codes in git bash in windows. In command prompt in order to change drive I use E: It returns an error in git bash. bash: E:: command not found. How do I change my current directory locatio...

Branch from a previous commit using Git

If I have n commits, how can I branch from the n-3 commit? I can see the hash of every commit. ...

How to efficiently check if variable is Array or Object (in NodeJS & V8)?

Is there any way to efficiently check if the variable is Object or Array, in NodeJS & V8? I'm writing a Model for MongoDB and NodeJS, and to traverse the object tree I need to know if the object is simple (Number, String, ...) or composite (Has...

Jackson and generic type reference

I want to use jackson json library for a generic method as follows: public MyRequest<T> tester() { TypeReference<MyWrapper<T>> typeRef = new TypeReference<MyWrapper<T>>(); MyWrapper<T> requestWrapper = (...

In practice, what are the main uses for the new "yield from" syntax in Python 3.3?

I'm having a hard time wrapping my brain around PEP 380. What are the situations where "yield from" is useful? What is the classic use case? Why is it compared to micro-threads? [ update ] Now I understand the cause of my difficulties. I've use...

UITableView Cell selected Color?

I have created a custom UITableViewCell. The table view is showing data fine. What I am stuck in is when user touches cell of tableview, then I want to show the background color of the cell other than the default [blue color] values for highlighting ...

Bash or KornShell (ksh)?

I am not new to *nix, however lately I have been spending a lot of time at the prompt. My question is what are the advantages of using KornShell (ksh) or Bash Shell? Where are the pitfalls of using one over the other? Looking to understand from the...

Performing a Stress Test on Web Application?

In the past, I used Microsoft Web Application Stress Tool and Pylot to stress test web applications. I'd written a simple home page, login script, and site walkthrough (in an ecommerce site adding a few items to a cart and checkout). Just hitting th...

Swift 3 URLSession.shared() Ambiguous reference to member 'dataTask(with:completionHandler:) error (bug)

Hello I have working json parsing code for swift2.2 but when i use it for Swift 3.0 gives me that error ViewController.swift:132:31: Ambiguous reference to member 'dataTask(with:completionHandler:)' My codes here let listUrlString = "http:...

C++ Dynamic Shared Library on Linux

This is a follow-up to Dynamic Shared Library compilation with g++. I'm trying to create a shared class library in C++ on Linux. I'm able to get the library to compile, and I can call some of the (non-class) functions using the tutorials that I fou...

Unique constraint violation during insert: why? (Oracle)

I'm trying to create a new row in a table. There are two constraints on the table -- one is on the key field (DB_ID), the other constrains a value to be one of several the the field ENV. When I do an insert, I do not include the key field as one of...

How add items(Text & Value) to ComboBox & read them in SelectedIndexChanged (SelectedValue = null)

I want to add some items to a combobox like this : public class ComboboxItem { public string Text { get; set; } public object Value { get; set; } public override string ToString() { return Text; } } ComboboxItem item...

How to create a DataFrame from a text file in Spark

I have a text file on HDFS and I want to convert it to a Data Frame in Spark. I am using the Spark Context to load the file and then try to generate individual columns from that file. val myFile = sc.textFile("file.txt") val myFile1 = myFile.map(x...

What's the difference between eval, exec, and compile?

I've been looking at dynamic evaluation of Python code, and come across the eval() and compile() functions, and the exec statement. Can someone please explain the difference between eval and exec, and how the different modes of compile() fit in?...

What's the difference between django OneToOneField and ForeignKey?

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

Wrap text in <td> tag

I want to wrap some text that is added to a <td> element. I have tried with style="word-wrap: break-word;" width="15%". But it is not wrapping the text. Is it mandatory to give it 100% width? I have other controls to display so only 15% width i...

jQuery checkbox checked state changed event

I want an event to fire client side when a checkbox is checked / unchecked: $('.checkbox').click(function() { if ($(this).is(':checked')) { // Do stuff } }); Basically I want it to happen for every checkbox on the page. Is this method of f...

Using Axios GET with Authorization Header in React-Native App

I'm trying to use axios for a GET request with an API which requires an Authorization header. My current code: const AuthStr = 'Bearer ' + USER_TOKEN; where USER_TOKEN is the access token needed. This string concatenation may be the issue as if I...

What are abstract classes and abstract methods?

Possible Duplicate: Abstract class in Java I got several explanations but so far I'm not able to understand that what are the abstract classes and methods in Java. Some said it has to do something with the security of the program, other s...

What is a raw type and why shouldn't we use it?

Questions: What are raw types in Java, and why do I often hear that they shouldn't be used in new code? What is the alternative if we can't use raw types, and how is it better? ...

The container 'Maven Dependencies' references non existing library - STS

I'm using win8 previously I had been running Eclipse Juno on my pc but from now on I wanted to start using STS, I am getting the below error as soon as I create a new project. I deleted my .m2 folder and everything related to Eclipse in order to star...

websocket.send() parameter

Usually, we only put the data we want to send as websocket.send() method's parameter, but I want to know whether there are other parameters like IP that we can put inside the brackets. Can we use it this way: websocket.send(ip, data); // send data ...

Could not find or load main class with a Jar File

I'm trying to load a jar using @echo off java -jar Test.jar pause With the manifest of Manifest-Version: 1.0 Main-Class: classes.TestClass In the Jar directory, I can clearly see a classes\TestClass file when I extract it. Edit: classes.TestC...

Using 'starts with' selector on individual class names

If I have the following: <div class="apple-monkey"></div> <div class="apple-horse"></div> <div class="cow-apple-brick"></div> I can use the following selector to find the first two DIVs: $("div[class^='apple-']...

Unable to import a module that is definitely installed

After installing mechanize, I don't seem to be able to import it. I have tried installing from pip, easy_install, and via python setup.py install from this repo: https://github.com/abielr/mechanize. All of this to no avail, as each time I enter my P...

How to search through all Git and Mercurial commits in the repository for a certain string?

I have a Git repository with few branches and dangling commits. I would like to search all such commits in repository for a specific string. I know how to get a log of all commits in history, but these don't include branches or dangling blobs, just ...

SVN: Is there a way to mark a file as "do not commit"?

With TortoiseSVN, I can move a file into the ignore-on-commit changelist, so that when I commit a whole tree, changes to that file do not get committed. Is there a way to do something like that using the svn command-line tool? EDIT: Thanks for the ...

How to set cookie value with AJAX request?

I want to set a cookie value on an AJAX request but the code below doesn't work. $.ajax({ type: "GET", url: "http://example.com", cache: false, setCookies: "lkfh89asdhjahska7al446dfg5kgfbfgdhfdbfgcvbcbc dfskljvdfhpl", crossD...

grep without showing path/file:line

How do you grep and only return the matching line? i.e. The path/filename is omitted from the results. In this case I want to look in all .bar files in the current directory, searching for the term FOO find . -name '*.bar' -exec grep -Hn FOO {} \; ...

VBA vlookup reference in different sheet

In Excel 2007, I am looping through the values of column 4 in Sheet 2. Still in Sheet 2, I want to output the result of my vlookup formula into column 5. The vlookup formula needs to refer to Sheet 1 where the reference columns are. In order to do so...

jquery $('.class').each() how many items?

When looping over a group of items using jquery selectors is there a way to find out how many items there are on the collection?...

Imply bit with constant 1 or 0 in SQL Server

Is it possible to express 1 or 0 as a bit when used as a field value in a select statement? e.g. In this case statement (which is part of a select statement) ICourseBased is of type int. case when FC.CourseId is not null then 1 else 0 end as IsCo...

How can I check what version/edition of Visual Studio is installed programmatically?

I could read registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0. However, it doesn't give me any information about the edition of it - Professional/Ultimate or whatever. How can I get the information with programmatically (preferably ...

Assign command output to variable in batch file

I'm trying to assign the output of a command to a variable - as in, I'm trying to set the current flash version to a variable. I know this is wrong, but this is what I've tried: set var=reg query hklm\SOFTWARE\Macromedia\FlashPlayer\CurrentVersion&g...

Is it possible to opt-out of dark mode on iOS 13?

A large part of my app consists of web views to provide functionality not yet available through native implementations. The web team has no plans to implement a dark theme for the website. As such, my app will look a bit half/half with Dark Mode supp...

How to Parse a JSON Object In Android

I am having some problems pulling values from a JSON object. Here is my code try { JSONObject json = new JSONObject(result); JSONObject json2 = json.getJSONObject("results"); test = json2.getString("name"); } catch (JSONException e)...

Find and kill a process in one line using bash and regex

I often need to kill a process during programming. The way I do it now is: [~]$ ps aux | grep 'python csp_build.py' user 5124 1.0 0.3 214588 13852 pts/4 Sl+ 11:19 0:00 python csp_build.py user 5373 0.0 0.0 8096 960 pts/6 S+ ...

How to Define Callbacks in Android?

During the most recent Google IO, there was a presentation about implementing restful client applications. Unfortunately, it was only a high level discussion with no source code of the implementation. In this diagram, on the return path there are va...

how to check if a datareader is null or empty

I have a datareader that return a lsit of records from a sql server database. I have a field in the database called "Additional". This field is 50% of the time empty or null. I am trying to write code that checks if this field isnull. The l...

How to round the double value to 2 decimal points?

Possible Duplicate: round double to two decimal places in java I want to round up the double value upto 2 decimal points. for example: I have double d=2; and the result should be result =2.00...

Comparing two NumPy arrays for equality, element-wise

What is the simplest way to compare two NumPy arrays for equality (where equality is defined as: A = B iff for all indices i: A[i] == B[i])? Simply using == gives me a boolean array: >>> numpy.array([1,1,1]) == numpy.array([1,1,1]) arra...

Exit single-user mode

Currently, my database is in Single User mode. When I try to expand me database, I get an error: The database 'my_db' is not accessible.(ObjectExplorer) Also, when I try to delete the database, I get the error: Changes to the state or optio...

scrollTop animation without jquery

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

How to call a vue.js function on page load

I have a function that helps filter data. I am using v-on:change when a user changes the selection but I also need the function to be called even before the user selects the data. I have done the same with AngularJS previously using ng-init but I und...

How to do a SUM() inside a case statement in SQL server

I want to add some calculation inside my case statement to dynamically create the contents of a new column but I get the error: Column 'Test1.qrank' is invalid in the select list because it is not contained in either an aggregate function or the...

D3.js: How to get the computed width and height for an arbitrary element?

I need to know exactly the width and height for an arbitrary g element in my SVG because I need to draw a selection marker around it once the user has clicked it. What I've seen in the internet is something like: d3.select("myG").style("width"). The...

How should I multiple insert multiple records?

I have a class named Entry declared like this: class Entry{ string Id {get;set;} string Name {get;set;} } and then a method that will accept multiple such Entry objects for insertion into the database using ADO.NET: static void Inse...

How can I divide one column of a data frame through another?

I wanted to divide one column by another to get the per person time how can I do this?I couldn't find anything on how you can divide. Here is some data that I want to use min count2.freq 263807.0 1582 196190.5 1016 586689.0 3479 ...

Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties

Did anybody have similar problem with this, I import android project and I get errors like [2011-10-03 17:20:09 - Screen] Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Propert...

How to make rpm auto install dependencies

I have built two RPM packages proj1-1.0-1.x86_64.rpm libtest1-1.0-1.x86_64.rpm proj1 depends on the file libtest1.so being present and it is reflected correctly in the RPM packages as seen here: user@my-pc:~$ rpm -qp --requires proj1-1.0-1.x86_6...

getaddrinfo: nodename nor servname provided, or not known

I have a Ruby on Rails application that I am deploying on a computer running Mac OS X 10.6. The code where the problem arises is run by a delayed_job. The problem only occurs when it is run through delayed_job. If I run it within a console (rails con...

Read XML file into XmlDocument

I am very new to C#. I have XML file (text.xml). I want to read that in XmlDocument and store the stream in string variable....

Send json post using php

I have this json data: { userID: 'a7664093-502e-4d2b-bf30-25a2b26d6021', itemKind: 0, value: 1, description: 'Saude', itemID: '03e76d0a-8bab-11e0-8250-000c29b481aa' } and I need to post into json url: http://domain/OnLeagueRes...

How to make a script wait for a pressed key?

I want my script to wait until the user presses any key. How do I do that?...

How to select <td> of the <table> with javascript?

I know this is very easy question, but I couldn't find the answer anywhere. Only answers are the ones using jQuery, not pure JS. I've tried the code below and it doesn't work. I don't know why. var t = document.getElementById("table"), d = t.ge...

What to put in a python module docstring?

Ok, so I've read both PEP 8 and PEP 257, and I've written lots of docstrings for functions and classes, but I'm a little unsure about what should go in a module docstring. I figured, at a minimum, it should document the functions and classes that th...

Can a foreign key be NULL and/or duplicate?

Please clarify two things for me: Can a Foreign key be NULL? Can a Foreign key be duplicate? As fair as I know, NULL shouldn't be used in foreign keys, but in some application of mine I'm able to input NULL in both Oracle and SQL Server, and I do...

Best Practices: working with long, multiline strings in PHP?

Note: I'm sorry if this is an extremely simple question but I'm somewhat obsessive compulsive over the formatting of my code. I have a class that has a function that returns a string that will make up the body text of an email. I want this text form...

How to create a directory using Ansible

How do you create a directory www at /srv on a Debian-based system using an Ansible playbook?...

module.exports vs exports in Node.js

I've found the following contract in a Node.js module: module.exports = exports = nano = function database_module(cfg) {...} I wonder whats the different between module.exports and exports and why both are used here....

How to merge a list of lists with same type of items to a single list of items?

The question is confusing, but it is much more clear as described in the following codes: List<List<T>> listOfList; // add three lists of List<T> to listOfList, for example /* listOfList = new { { 1, 2, 3}, // list...

Error when testing on iOS simulator: Couldn't register with the bootstrap server

I was testing my app on the simulator when it crashed on clicking a button of a UIAlertView. I stopped debugging there, made some changes to the code and built the app again. Now when I run the application, I get this error in the console Couldn'...

WPF MVVM ComboBox SelectedItem or SelectedValue not working

Update After a bit of investigating. What seems to be the issue is that the SelectedValue/SelectedItem is occurring before the Item source is finished loading. If I sit in a break point and wait a few seconds it works as expected. Don't know how ...

What's the reason I can't create generic array types in Java?

What's the reason why Java doesn't allow us to do private T[] elements = new T[initialCapacity]; I could understand .NET didn't allow us to do that, as in .NET you have value types that at run-time can have different sizes, but in Java all kinds o...

C++ error: undefined reference to 'clock_gettime' and 'clock_settime'

I am pretty new to Ubuntu, but I can't seem to get this to work. It works fine on my school computers and I don't know what I am not doing. I have checked usr/include and time.h is there just fine. Here is the code: #include <iostream> #inc...

How to POST a FORM from HTML to ASPX page

How do I post a form from an HTML page to and ASPX page (2.0) and be able to read the values? I currently have an ASP.NET site using the Membership provider and everything is working fine. Users can log in from the Login.aspx page. We now want to ...

Submitting a form on 'Enter' with jQuery?

I have a bog-standard login form - an email text field, a password field and a submit button on an AIR project that's using HTML/jQuery. When I hit Enter on the form, the entire form's contents vanish, but the form isn't submitted. Does anyone know...

Printing 2D array in matrix format

I have a 2D array as follows: long[,] arr = new long[4, 4] {{ 0, 0, 0, 0 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 1, 1, 1, 1 }}; I want to print the values of th...

Android get Current UTC time

What is the function to get the current UTC time. I have tried with System.getCurrentTime but i get the current date and time of the device. Thanks...

How to kill a nodejs process in Linux?

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9631/node How do I kill this process in linux(ubuntu)?...

How do I pull from a Git repository through an HTTP proxy?

Note: while the use-case described is about using submodules within a project, the same applies to a normal git clone of a repository over HTTP. I have a project under Git control. I'd like to add a submodule: git submodule add http://github.com/j...

How to read a file in reverse order?

How to read a file in reverse order using python? I want to read a file from last line to first line....

nodejs - first argument must be a string or Buffer - when using response.write with http.request

I'm simply trying to create a node server that outputs the HTTP status of a given URL. When I try to flush the response with res.write, I get the error: throw new TypeError('first argument must be a string or Buffer'); But if I replace them with co...

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(){....

reactjs giving error Uncaught TypeError: Super expression must either be null or a function, not undefined

I am using reactjs. When I run the code below the browser says: Uncaught TypeError: Super expression must either be null or a function, not undefined Any hints at all as to what is wrong would be appreciated. First the line used to compile the co...

Git - How to fix "corrupted" interactive rebase?

I managed to create a little mess in my local git repository. I was trying to fix a broken commit by using the following instructions. Before running the "git commit --amend" (and after the git rebase --interactive) I decided that my changes were inc...

Using Custom Domains With IIS Express

Traditionally I use custom domains with my localhost development server. Something along the lines of: dev.example.com dev.api.example.com This has provided me a ton of flexibility when working with external API's such as Facebook. This has worked...

How to select and change value of table cell with jQuery?

How do I change the content of the cell containing the 'c' letter in the HTML sample using jQuery? <table id="table_header"> <tr> <td>a</td> <td>b</td> <td>c</td> </tr> </table> ...

How to combine date from one field with time from another field - MS SQL Server

In an extract I am dealing with, I have 2 datetime columns. One column stores the dates and another the times as shown. How can I query the table to combine these two fields into 1 column of type datetime? Dates 2009-03-12 00:00:00.000 2009-03-26 ...

Access mysql remote database from command line

I have a server with Rackspace. I want to access the database from my local machine command line. I tried like: mysql -u username -h my.application.com -ppassword But it gives an error: ERROR 2003 (HY000): Can't connect to MySQL server on 'my.appli...

A button to start php script, how?

I want to make a button that starts my php script after I click it. So do I just make 2 separate files and have action post to the php file and then let it start? or is there a better way to do this? Possibly in one document? Update: Well, I basica...

Correct Way to Load Assembly, Find Class and Call Run() Method

Sample console program. class Program { static void Main(string[] args) { // ... code to build dll ... not written yet ... Assembly assembly = Assembly.LoadFile(@"C:\dyn.dll"); // don't know what or how to cast here ...

Refreshing page on click of a button

I would like to refresh the current page when a button is clicked. Using JavaScript, I have the following: <button type="button" onClick="refreshPage()">Close</button> <script> function refreshPage() { // What do I pu...

CodeIgniter: How to get Controller, Action, URL information

I have these URLs: http://backend.domain.com/system/setting/edit/12 http://backend.domain.com/product/edit/1 How to get controller name, action name from these URLs. I'm CodeIgniter newbie. Are there any helper function to get this info Ex: $p...

Why are C# 4 optional parameters defined on interface not enforced on implementing class?

I noticed that with the optional parameters in C# 4 if you specify an optional parameter on an interface you don,t have to make that parameter optional on any implementing class: public interface MyInterface { void TestMethod(bool flag = false)...

Search all tables, all columns for a specific value SQL Server

I have a specific value, let's say string 'comments'. I need to find all instances of this in the database as I need to do an update on the format to change it to (*) Comments. How can I do this? The database is in SQL Server 2000 format....

Using R to list all files with a specified extension

I'm very new to R and am working on updating an R script to iterate through a series of .dbf tables created using ArcGIS and produce a series of graphs. I have a directory, C:\Scratch, that will contain all of my .dbf files. However, when ArcGIS cre...

How to wrap text in textview in Android

Does any one know how to wrap text in TextView in Android platform. i.e if the text in textview exceed the screen length it should be displayed in the second line. I have searched and tried the following: android:scrollHorizontally="false", android...

How to convert upper case letters to lower case

I have a script which reads the input and than lists it, however i want it to convert upper case letters to lower case, how can i do that? this is what i got for words in text.readlines(): sentence = [w.strip(',.') for w in line.split() if w.s...

batch file to check 64bit or 32bit OS

Can I check to see if current machine is running 64bit OS or 32bit OS inside a batch file? EDIT: Found this online and it is good enough to me now:...

How to use double or single brackets, parentheses, curly braces

I am confused by the usage of brackets, parentheses, curly braces in Bash, as well as the difference between their double or single forms. Is there a clear explanation?...

node.js shell command execution

I am still trying to grasp the finer points of how I can run a linux or windows shell command and capture output within node.js; ultimately, I want to do something like this... //pseudocode output = run_command(cmd, args) The important piece is th...

How do I merge changes to a single file, rather than merging commits?

I have two branches (A and B) and I want to merge a single file from branch A with a corresponding single file from Branch B....

How to "crop" a rectangular image into a square with CSS?

I know that it is impossible to actually modify an image with CSS, which is why I put crop in quotes. What I'd like to do is take rectangular images and use CSS to make them appear square without distorting the image at all. I'd basically like to ...

How to clear memory to prevent "out of memory error" in excel vba?

I am running VBA code on a large spreadsheet. How do I clear the memory between procedures/calls to prevent an "out of memory" issue occurring? Thanks...

How to use hex color values

I am trying to use hex color values in Swift, instead of the few standard ones that UIColor allows you to use, but I have no idea how to do it. Example: how would I use #ffffff as a color?...

"call to undefined function" error when calling class method

this is the error Fatal error: Call to undefined function assign( this is the code, as you can see i obviously have defined the function so why is it not working class shades { function create($name, $shades, $slug, $shortDesc, $longDesc, $posit...

Dynamically Dimensioning A VBA Array?

Why am I unable to set the size of an array based on a variable? What's the best way around this? Dim NumberOfZombies as integer NumberOfZombies = 20000 Dim Zombies(NumberOfZombies) as New Zombie ...

Which is a better way to check if an array has more than one element?

I just need to check if an array has more than one element. I am trying to do it this way : if (isset($arr['1'])) the other traditional way is if (sizeof($arr)>1) Which of the two is better? In such situaions, how should I judge between tw...

INFO: No Spring WebApplicationInitializer types detected on classpath

I have a spring project that runs fine on my tomcat7 server when I deploy from eclipse: Run As >> Run on server. In the eclipse tab "Servers" I see: Servers Tomcat v7.0 Server at localhost [Started, Synchronized] my_project [Synchronized] s...

Open URL in Java to get the content

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

How to detect if URL has changed after hash in JavaScript

How can I check if a URL has changed in JavaScript? For example, websites like GitHub, which use AJAX, will append page information after a # symbol to create a unique URL without reloading the page. What is the best way to detect if this URL changes...

Checking if a file is a directory or just a file

I'm writing a program to check if something is a file or is a directory. Is there a better way to do it than this? #include <stdio.h> #include <sys/types.h> #include <dirent.h> #include <errno.h> int isFile(const char* name...

'const string' vs. 'static readonly string' in C#

In C#, what's the difference between static readonly string MyStr; and const string MyStr; ?...

Using Oracle to_date function for date string with milliseconds

I have to perform some inserts into an Oracle DB. I have some dates in the following format '23.12.2011 13:01:001' Following the documentation I wrote inserts to_date as follows: to_date('23.12.2011 13:01:01', 'DD.MM.YYYY HH24:MI:SS') which wo...

How to export database schema in Oracle to a dump file

I have a database schema on Oracle server installed on a Linux machine. I need to export the schema related information in a dump file. How to do this ?...

How to include NA in ifelse?

I am trying to create a column ID based on logical statements for values of other columns. For example, in the following dataframe test <- structure(list(time = c(10L, 20L, NA, 30L), type = structure(c(1L, 2L, 3L, NA), .Label = c("A", "B", "C"),...

How to copy std::string into std::vector<char>?

Possible Duplicate: Converting std::string to std::vector<char> I tried: std::string str = "hello"; std::vector<char> data; std::copy(str.c_str(), str.c_str()+str.length(), data); but it does not work=( So I wonder How to co...

Does :before not work on img elements?

I'm trying to use the :before selector to place an image over another image, but I'm finding that it simply doesn't work to place an image before an img element, only some other element. Specifically, my styles are: .container { position: relati...

Failed to build gem native extension (installing Compass)

When I attempt to install the latest version of compass (https://rubygems.org/gems/compass/versions/1.0.0.alpha.17), I get the following error. ERROR: Error installing compass: ERROR: Failed to build gem native extension. ERROR: Error installing...

Including JavaScript class definition from another file in Node.js

I'm writing a simple server for Node.js and I'm using my own class called User which looks like: function User(socket) { this.socket = socket; this.nickname = null; /* ... just the typical source code like functions, variables and bugs ...

Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. Manifest definition does not match the assembly reference

Things I've tried after searching: in Web.Config put a binding on the old version: <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersi...

XML Document to String

What's the simplest way to get the String representation of a XML Document (org.w3c.dom.Document)? That is all nodes will be on a single line. As an example, from <root> <a>trge</a> <b>156</b> </root> (this...

mysqli::query(): Couldn't fetch mysqli

Warning: mysqli::query(): Couldn't fetch mysqli in C:\Program Files (x86)\EasyPHP-DevServer-13.1VC9\data\localweb\my portable files\class_EventCalendar.php on line 43 The following is my connection file: <?php if(!isset($_SESSION)) { s...

syntax error, unexpected T_VARIABLE

I can't seem to find where my code has went wrong. Here is my full error: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\GigaLoad.com\register.php on line 102 But I've been looking a that line for hours. I will give you t...

Cross-browser custom styling for file upload button

I'm trying to style a file upload button to my personal preferences, but I couldn't find any really solid ways to do this without JS. I did find two other questions about this subject, but the answers there either involved JavaScript, or suggested Qu...

Python not working in the command line of git bash

Python will not run in git bash (Windows). When I type python in the command line, it takes me to a blank line without saying that it has entered python 2.7.10 like its does in Powershell. It doesn't give me an error message, but python just doesn't ...

What does an exclamation mark mean in the Swift language?

The Swift Programming Language guide has the following example: class Person { let name: String init(name: String) { self.name = name } var apartment: Apartment? deinit { println("\(name) is being deinitialized") } } class Apartmen...

Verify a method call using Moq

I am fairly new to unit testing in C# and learning to use Moq. Below is the class that I am trying to test. class MyClass { SomeClass someClass; public MyClass(SomeClass someClass) { this.someClass = someClass; } pu...

Reading a cell value in Excel vba and write in another Cell

I have an Excel file and I want to read a value of a cell i.e a cell contains (S:1 P:0 K:1 Q:1) I want to read each value and save each value to another column. For example if S:1, then should be another cell 1, how can I read the data from a cell a...

How do I disable right click on my web page?

Can I disable right click on my web page without using JavaScript? I ask this because most browsers allow user to disable JavaScript. If not, how do I use JavaScript to disable right click?...

Android Paint: .measureText() vs .getTextBounds()

I'm measuring text using Paint.getTextBounds(), since I'm interested in getting both the height and width of the text to be rendered. However, the actual text rendered is always a bit wider than the .width() of the Rect information filled by getTextB...

Script not served by static file handler on IIS7.5

I've just tried to deploy my first web application to IIS on my Windows 7 Home Premium notebook. After creating the application, I had to change to the Classic App Pool, then set that pool for framework 4.0. Now I get the following error: HTTP ...

What is simplest way to read a file into String?

I am trying to read a simple text file into a String. Of course there is the usual way of getting the input stream and iterating with readLine() and reading contents into String. Having done this hundreds of times in past, I just wondered how can I...

undefined reference to 'std::cout'

Shall this be the example: #include <iostream> using namespace std; int main() { cout << "Hola, moondo.\n"; } It throws the error: gcc -c main.cpp gcc -o edit main.o main.o: In function `main': main.cpp:(.text+0xa): undefined ref...

Extract number from string with Oracle function

I need to create an Oracle DB function that takes a string as parameter. The string contains letters and numbers. I need to extract all the numbers from this string. For example, if I have a string like RO1234, I need to be able to use a function, sa...

jQuery .attr("disabled", "disabled") not working in Chrome

Not sure why this isn't working. When people click the 'edit' button of my application, the disabled textfields become editable: $("#bewerken").click(function(e) { $("input[disabled='disabled']").removeAttr('disabled'); }); I then want to ...

Histogram using gnuplot?

I know how to create a histogram (just use "with boxes") in gnuplot if my .dat file already has properly binned data. Is there a way to take a list of numbers and have gnuplot provide a histogram based on ranges and bin sizes the user provides?...

How do I redirect users after submit button click?

How do I redirect users after submit button click? My javascript isn't working: Javascript <script type="text/javascript" language="javascript"> function redirect() { window.location.href="login.php"; } </script> Form Page <fo...

Export query result to .csv file in SQL Server 2008

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

Are static class variables possible in Python?

Is it possible to have static class variables or methods in Python? What syntax is required to do this?...

Unix ls command: show full path when using options

I often use this list command in Unix (AIX / KSH): ls -Artl It displays the files as this: -rw-r--r-- 1 myuser mygroup 0 Apr 2 11:59 test1.txt -rw-r--r-- 1 myuser mygroup 0 Apr 2 11:59 test2.txt I would like to modify the command such a way...

Multi-line strings in PHP

Consider: $xml = "l"; $xml = "vv"; echo $xml; This will echo vv. Why and how can I do multi-line strings for things like SimpleXML, etc.?...

Display Animated GIF

I want to display animated GIF images in my aplication. As I found out the hard way Android doesn't support animated GIF natively. However it can display animations using AnimationDrawable: Develop > Guides > Images & Graphics > Drawables Overv...

ImportError: No module named win32com.client

I am currently using python 2.7 and trying to open an Excel sheet. When using the code below: import os from win32com.client import Dispatch xlApp = win32com.client.Dispatch("Excel.Application") xlApp.Visible = True # Open the file we want in Excel...

Text on image mouseover?

I am trying to get a small box to appear on the bottom-left side of an image when a mouse moves over it. Inside the box there will be a link to a different page. Here is somewhat similar to what I want, but the box to be smaller and not connected to...

Subversion ignoring "--password" and "--username" options

When I try to do any svn command and supply the --username and/or --password options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified by --username. Neither --no-auth-cache nor --non-...

Creating a list of pairs in java

Which class would work best for a non-ordered list of pairs? I'll be taking a bunch of (float,short) pairs and will need to be able to perform simple math (like multiplying the pair together to return a single float, etc). List only takes one argumen...

Rebuild Docker container on file changes

For running an ASP.NET Core application, I generated a dockerfile which build the application and copys the source code in the container, which is fetched by Git using Jenkins. So in my workspace, I do the following in the dockerfile: WORKDIR /app ...

How do I save JSON to local text file

Say I have a javascript object that looks like this : var data = { name: "cliff", age: "34", name: "ted", age: "42", name: "bob", age: "12" } var jsonData = JSON.stringify(data); I stringify it to convert...

Chosen Jquery Plugin - getting selected values

How can i get the selected values from the chosen Multi-select Box?...

Paste Excel range in Outlook

I want to paste a range of cells in Outlook. Here is my code: Sub Mail_Selection_Range_Outlook_Body() Dim rng As Range Dim OutApp As Object Dim OutMail As Object Set rng = Nothing On Error Resume Next ' Only send the visible cells in the selecti...

No mapping found for HTTP request with URI.... in DispatcherServlet with name

I checked out nearly every relevant article on stackoverflow already, but I just cant fix my problem. Here is the code: web.xml: <display-name>Spring3MVC</display-name> <welcome-file-list> <welcome-file>index....

Compare DATETIME and DATE ignoring time portion

I have two tables where column [date] is type of DATETIME2(0). I have to compare two records only by theirs Date parts (day+month+year), discarding Time parts (hours+minutes+seconds). How can I do that?...

Java Generate Random Number Between Two Given Values

I would like to know how to generate a random number between two given values. I am able to generate a random number with the following: Random r = new Random(); for(int i = 0; i < a.length; i++){ for(int j = 0; j < a[i].length; j++){ ...

Is it correct to use alt tag for an anchor link?

Is it correct to use alt tag for an anchor link, something like <a href="#" class="test" alt="Something" src="sfasfs" ></a> ...

VBA Count cells in column containing specified value

I need to write a macro that searches a specified column and counts all the cells that contain a specified string, such as "19/12/11" or "Green" then associate this number with a variable, Does anyone have any ideas?...

CSS3 Spin Animation

I have reviewed quite a few demos and have no idea why I can't get the CSS3 spin to function. I am using the latest stable release of Chrome. The fiddle: http://jsfiddle.net/9Ryvs/1/ _x000D_ _x000D_ div {_x000D_ margin: 20px;_x000D_ width: 100p...

How can I convert an HTML table to CSV?

How do I convert the contents of an HTML table (<table>) to CSV format? Is there a library or linux program that does this? This is similar to copy tables in Internet Explorer, and pasting them into Excel....

SQL Server Pivot Table with multiple column aggregates

I've got a table: create table mytransactions(country varchar(30), totalcount int, numericmonth int, chardate char(20), totalamount money) The table has these records: insert into mytransactions(country, totalcount, numericmonth, chardate, total...

Does the Java &= operator apply & or &&?

Assuming boolean a = false; I was wondering if doing: a &= b; is equivalent to a = a && b; //logical AND, a is false hence b is not evaluated. or on the other hand it means a = a & b; //Bitwise AND. Both a and b are evaluat...

React.js: How to append a component on click?

I'm new to React and I'm puzzled on something kind of basic. I need to append a component to the DOM after the DOM is rendered, on a click event. My initial attempt is as follows, and it doesn't work. But it's the best thing I've thought to try. (A...

1114 (HY000): The table is full

I'm trying to add a row to an InnoDB table with a simply query: INSERT INTO zip_codes (zip_code, city) VALUES ('90210', 'Beverly Hills'); But when I attempt this query, I get the following: ERROR 1114 (HY000): The table zip_codes is full Doi...

Can I pass column name as input parameter in SQL stored Procedure

create procedure sp_First @columnname varchar AS begin select @columnname from Table_1 end exec sp_First 'sname' My requirement is to pass column names as input parameters. I tried like that but it gave wrong output. So Help me...

Android Lint contentDescription warning

I am getting warning as "[Accessibility] Missing contentDescription attribute on image" for imageview. while using android lint What does that mean?...

How to check if a process is running via a batch script

How can I check if an application is running from a batch (well cmd) file? I need to not launch another instance if a program is already running. (I can't change the app to make it single instance only.) Also the application could be running as any...

Is there a REAL performance difference between INT and VARCHAR primary keys?

Is there a measurable performance difference between using INT vs. VARCHAR as a primary key in MySQL? I'd like to use VARCHAR as the primary key for reference lists (think US States, Country Codes) and a coworker won't budge on the INT AUTO_INCREMENT...

creating a table in ionic

I am in need of creating a table in Ionic. I thought of using Ionic grid but could not achieve what I wanted. How can I do this? Here is an image of something similar to what i want: I can use this but how can I divide the rows like in the picture...

Split bash string by newline characters

I found this. And I am trying this: x='some thing' y=(${x//\n/}) And I had no luck, I thought it could work with double backslash: y=(${x//\\n/}) But it did not. To test I am not getting what I want I am doing: echo ${y[1]} Getting: s...

Simple way to create matrix of random numbers

I am trying to create a matrix of random numbers, but my solution is too long and looks ugly random_matrix = [[random.random() for e in range(2)] for e in range(3)] this looks ok, but in my implementation it is weights_h = [[random.random() for e...

Wildcards in a Windows hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost. The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local, site2.local etc, and have them all resolve to...

Trying Gradle build - "Task 'build' not found in root project"

I just started to read "Pro Spring MVC with web flow" and it comes with a code sample that I want to follow. What I want - I want to build the applications as it's done in the book, using Gradle What is the problem - I have never used Gradle befor...

how to open .mat file without using MATLAB?

I have done a project in Matlab and now I have uninstalled Matlab. Now, I need some reference of my project. I'm left with all the .mat files. I'm trying to open them in notepad and I'm getting unicode characters over there. My question is simple. Ho...

Python, Pandas : write content of DataFrame into text File

I have pandas DataFrame like this X Y Z Value 0 18 55 1 70 1 18 55 2 67 2 18 57 2 75 3 18 58 1 35 4 19 54 2 70 I want to write this data to a text file ...

Is ini_set('max_execution_time', 0) a bad idea?

Is there a good reason not to set the PHP configuration variable max_execution_time to 0? A coworker recently checked in a change to a file that added: ini_set('max_execution_time', 0); The default value had been too low for a page that did some ...

Select arrow style change

I'm trying to replace the arrow of a select with a picture of my own. I'm including the select in a div with the same size, I set the background of the select as transparent and I'm including a picture(with the same size as the arrow) in the right to...

Create a directly-executable cross-platform GUI app using Python

Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux. The problem being I have no idea where to start or how to write ...

Package name does not correspond to the file path - IntelliJ

I'm trying to import a project from VCS (well, I'm doing it for the first time actually) and this is my (imported) project's structure: BTW. this screen is made after many tries of changing these directories' properties (in their context menus). ...

jquery find element by specific class when element has multiple classes

So I am working on something that wasn't well thought out in the build from the backend team. That leaves me with a document full of divs. What I am doing is rolling back from the element I need to click on, get the parent container then find an el...

Apache won't run in xampp

I have just installed XAMPP and everything works fine except that I can't get apache to run. It seems that port 80 is the problem, I have disabled Skype to use port 80 but it doesn't seem to fix it. I read somewhere that the SSL port can be the pro...

What's the difference between .bashrc, .bash_profile, and .environment?

I've used a number of different *nix-based systems of the years, and it seems like every flavor of Bash I use has a different algorithm for deciding which startup scripts to run. For the purposes of tasks like setting up environment variables and al...

Rounding integer division (instead of truncating)

I was curious to know how I can round a number to the nearest whole number. For instance, if I had: int a = 59 / 4; which would be 14.75 if calculated in floating point; how can I store the result as 15 in "a"?...

How to change the sender's name or e-mail address in mutt?

How can I change the sender's name or e-mail address (From: header) used by mutt?...

How to check if AlarmManager already has an alarm set?

When my app starts, I want it to check if a particular alarm (registered via AlarmManager) is already set and running. Results from google seem to indicate that there is no way to do this. Is this still correct? I need to do this check in order to ad...

R define dimensions of empty data frame

I am trying to collect some data from multiple subsets of a data set and need to create a data frame to collect the results. My problem is don't know how to create an empty data frame with defined number of columns without actually having data to pu...

PDO Prepared Inserts multiple rows in single query

I am currently using this type of SQL on MySQL to insert multiple rows of values in one single query: INSERT INTO `tbl` (`key1`,`key2`) VALUES ('r1v1','r1v2'),('r2v1','r2v2'),... On the readings on PDO, the use prepared statements should give me a...

How to set Apache Spark Executor memory

How can I increase the memory available for Apache spark executor nodes? I have a 2 GB file that is suitable to loading in to Apache Spark. I am running apache spark for the moment on 1 machine, so the driver and executor are on the same machine. Th...

Get refresh token google api

I can't get my refresh token with my code. I can only get my access token, token type etc., I have followed some tutorials like putting access_type=offline on my login URL: echo "<a href='https://accounts.google.com/o/oauth2/auth?" . "access...

Oracle select most recent date record

I am trying to find the most recent record based on a date field. When I set latest = 1 in the where clause, I get an error. Please help if possible. DATE is a the field I'm sorting by. I have tried both latest = 1 and latest = '1' SELECT STAFF_I...

Using async/await with a forEach loop

Are there any issues with using async/await in a forEach loop? I'm trying to loop through an array of files and await on the contents of each file. import fs from 'fs-promise' async function printFiles () { const files = await getFilePaths() // ...

Difference between the Apache HTTP Server and Apache Tomcat?

What is the difference in terms of functionality between the Apache HTTP Server and Apache Tomcat? I know that Tomcat is written in Java and the HTTP Server is in C, but other than that I do not really know how they are distinguished. Do they have d...

How do I get the name of a Ruby class?

How can I get the class name from an ActiveRecord object? I have: result = User.find(1) I tried: result.class # => User(id: integer, name: string ...) result.to_s # => #<User:0x3d07cdc>" I need only the class name, in a string (Use...

Window.open and pass parameters by post method

With window.open method I open new site with parameters, which I have to pass by post method.I've found solution, but unfortunately it doesn't work. This is my code: <script type="text/javascript"> function openWindowWithPost(url,name,k...

Solving SharePoint Server 2010 - 503. The service is unavailable, After installation

Installed: SharePoint Server 2010 for Internet Enterprise Beta (x64) On: Windows Server 2008 Standard (x64) on 64 bit hardware Attempts to access the Central Administration console led to IIS returning 503. The service is unavailable And this error...

How can I align all elements to the left in JPanel?

I would like to have all elements in my JPanel to be aligned to the left. I try to do it in the following way: JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setAlignmentX(Component.LEFT_ALIGNMENT); As ...

Java system properties and environment variables

What's the difference between system properties System.getProperties() and environment variables System.getenv() in a JVM?...

Insecure content in iframe on secure page

I'm in the in the process of developing an application for a client, which will have an SSL certificate and be served under https. However, to integrate with their existing site they want to provide their navigation inside an iframe. I can see this ...

git - Your branch is ahead of 'origin/master' by 1 commit

I am newbie in git and I am working on git. I added some files in git : git add <file1> git add <file2> then I wanted to push that for review, but mistakenly I did git commit so the files which I have changed don't go for revie...

Solve Cross Origin Resource Sharing with Flask

For the following ajax post request for Flask (how can I use data posted from ajax in flask?): $.ajax({ url: "http://127.0.0.1:5000/foo", type: "POST", contentType: "application/json", data: JSON.stringify({'inputVar': 1}), succ...

String contains another two strings

Is it possible to have the contain function find if the string contains 2 words or more? This is what I'm trying to do: string d = "You hit someone for 50 damage"; string a = "damage"; string b = "someone"; string c = "you"; if(d.Contains(b + a)) {...

Location Services not working in iOS 8

My app that worked fine on iOS 7 doesn't work with the iOS 8 SDK. CLLocationManager doesn't return a location, and I don't see my app under Settings -> Location Services either. I did a Google search on the issue, but nothing came up. What...

force Maven to copy dependencies into target/lib

How do I get my project's runtime dependencies copied into the target/lib folder? As it is right now, after mvn clean install the target folder contains only my project's jar, but none of the runtime dependencies....

JavaScript variable assignments from tuples

In other languages like Python 2 and Python 3, you can define and assign values to a tuple variable, and retrieve their values like this: tuple = ("Bob", 24) name, age = tuple print(name) #name evaluates to Bob print(age) #age e...

Why is Android Studio reporting "URI is not registered"?

So I've given Android Studio a try, because I really like Resharper and noticed that the IDE had some of their functionality built into it. Having now created a default new project, I added a new layout file and wanted to change the existing default ...

Returning a promise in an async function in TypeScript

It's my understanding that these two functions will have the same behavior in JavaScript: const whatever1 = (): Promise<number> => { return new Promise((resolve) => { resolve(4); }); }; const whatever2 = async (): Promis...

How to control border height?

I have two div, one on the left and the other is on the right. Now I want to divide this two div with a border between them. But the border with full height looks bad. I want to control the height of the border. How could I do this?...

update columns values with column of another table based on condition

I have two tables... table1 ( id, item, price ) values: id | item | price ------------- 10 | book | 20 20 | copy | 30 30 | pen | 10 ....table2 ( id, item, price) values: id | item | price ------------- 10 | book | 20 20 | book | 30 Now I...

How do I get a substring of a string in Python?

Is there a way to substring a string in Python, to get a new string from the third character to the end of the string? Maybe like myString[2:end]? If leaving the second part means 'till the end', and if you leave the first part, does it start from ...

Can "git pull --all" update all my local branches?

I often have at least 3 remote branches: master, staging and production. I have 3 local branches that track those remote branches. Updating all my local branches is tedious: git fetch --all git rebase origin/master git checkout staging git rebase o...

How does origin/HEAD get set?

I have a branch set up to track a ref in origin. git checkout <branchname> switches to that branch, and a git status will show me how far ahead or behind my branch is from origin, but I'm surprised that origin/HEAD still points at origin/maste...

How to set button click effect in Android?

In Android, when I set background image to Button, I can not see any effect on button. I need some effect on button so user can recognize that button is clicked. Button should be dark while a few second when it clicked, so what should I do for thi...

Reversing a string in C

I have developed a reverse-string program. I am wondering if there is a better way to do this, and if my code has any potential problems. I am looking to practice some advanced features of C. char* reverse_string(char *str) { char temp; siz...

ReferenceError: describe is not defined NodeJs

I am trying to define some endpoints and do a test using nodejs. In server.js I have: var express = require('express'); var func1 = require('./func1.js'); var port = 8080; var server = express(); server.configure(function(){ server.use(express.bo...

change image opacity using javascript

how can I change image opacity using javascript? I'm going to create a fading effect using javascript, is there any sample? is there anything like image.opacity that can be changed through JS code? how is it set? thanks...

Oracle date to string conversion

I have a string column COL1 when I am doing this SELECT TO_CHAR(TO_DATE(COL1,'dd-mon-yy'), 'mm/dd/yyyy') FROM TABLE1 The data in COL1 is in dd-mon-yy, eg: 27-11-89 and 89 is 1989 but the select returns it as 11/27/2089. I have to do an inner TO_D...

How do I use 3DES encryption/decryption in Java?

Every method I write to encode a string in Java using 3DES can't be decrypted back to the original string. Does anyone have a simple code snippet that can just encode and then decode the string back to the original string? I know I'm making a very ...

DateTime fields from SQL Server display incorrectly in Excel

Countless times during the day I am copying and pasting records from SQL Server Management Studio to Excel. My problem is that a DateTime value such as 8/23/2013 4:51:02 PM does not display correctly as shown in the image below even though it show...

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

Modifying CSS class property values on the fly with JavaScript / jQuery

I've run into a unique situation that I have so far been unable to find a solution for: dynamically assigning a value to a CSS style. I know how to use jQuery to assign width, height, etc. to an element, but what I'm trying to do is actually change ...

Querying a linked sql server

I added a linked server, which is showing in the linked server list, but when I query it, it throws an error with the db server name. EXEC sp_helpserver EXEC sp_addlinkedserver 'aa-db-dev01' Select * from openquery('aa-db-dev01','Select * from Test...

Create table (structure) from existing table

How to create new table which structure should be same as another table I tried CREATE TABLE dom AS SELECT * FROM dom1 WHERE 1=2 but its not working error occurred ...

How to remove an HTML element using Javascript?

I am a total newbie. Can somebody tell me how to remove an HTML element using the original Javascript not jQuery. index.html <html> <head> <script type="text/javascript" src="myscripts.js" > </script> <style> #dummy...

Include CSS,javascript file in Yii Framework

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

How does Python return multiple values from a function?

I have written the following code: class FigureOut: def setName(self, name): fullname = name.split() self.first_name = fullname[0] self.last_name = fullname[1] def getName(self): return self.first_name, self.last_name ...

Remove the legend on a matplotlib figure

To add a legend to a matplotlib plot, one simply runs legend(). How to remove a legend from a plot? (The closest I came to this is to run legend([]) in order to empty the legend from data. But that leaves an ugly white rectangle in the upper right ...

Combining two sorted lists in Python

I have two lists of objects. Each list is already sorted by a property of the object that is of the datetime type. I would like to combine the two lists into one sorted list. Is the best way just to do a sort or is there a smarter way to do this in P...

Simultaneously merge multiple data.frames in a list

I have a list of many data.frames that I want to merge. The issue here is that each data.frame differs in terms of the number of rows and columns, but they all share the key variables (which I've called "var1" and "var2" in the code below). If the da...

Favorite Visual Studio keyboard shortcuts

What is your favorite Visual Studio keyboard shortcut? I'm always up for leaving my hands on the keyboard and away from the mouse! One per answer please....

What does `return` keyword mean inside `forEach` function?

_x000D_ _x000D_ $('button').click(function () {_x000D_ [1, 2, 3, 4, 5].forEach(function (n) {_x000D_ if (n == 3) {_x000D_ // it should break out here and doesn't alert anything after_x000D_ return false_x000D_ }_x000D...

How to fix missing dependency warning when using useEffect React Hook?

With React 16.8.6 (it was good on previous version 16.8.3), I get this error when I attempt to prevent an infinite loop on a fetch request ./src/components/BusinessesList.js Line 51: React Hook useEffect has a missing dependency: 'fetchBusinesses'. ...

Gunicorn worker timeout error

I have setup gunicorn with 3 workers 30 worker connections and using eventlet worker class. It is setup behind Nginx. After every few requests, I see this in the logs. [ERROR] gunicorn.error: WORKER TIMEOUT (pid:23475) None [INFO] gunicorn.error: Bo...

In what cases do I use malloc and/or new?

I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the new operator you should pair with delete and it is a mistake to mix the two (e.g. Calling free() on so...

Where is my .vimrc file?

I have been using Vim, and I would really like to save my settings. The problem I am having is that I cannot find my .vimrc file, and it is not in the standard /home/user/.vimrc location. How might I find this file?...

Convert a row of a data frame to vector

I want to create a vector out of a row of a data frame. But I don't want to have to row and column names. I tried several things... but had no luck. This is my data frame: > df <- data.frame(a=c(1,2,4,2),b=c(2,6,2,1),c=c(2.6,8.2,7.5,3)) > ...

C# HttpWebRequest of type "application/x-www-form-urlencoded" - how to send '&' character in content body?

I'm writing a small API-connected application in C#. I connect to a API which has a method that takes a long string, the contents of a calendar(ics) file. I'm doing it like this: HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);...

Laravel 5 Class 'form' not found

I have added "illuminate/html": "5.*" to composer.json and ran "composer update". - Installing illuminate/html (v5.0.0) Loading from cache I ran this command in the root of the website. I modified the composer.json file in /root/.composer......

Sites not accepting wget user agent header

When I run this command: wget --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" http://yahoo.com ...I get this result (with nothing else in the file): <!-- hw147.fp.gq1.yahoo.com uncompressed/chu...

Define global constants

In Angular 1.x you can define constants like this: angular.module('mainApp.config', []) .constant('API_ENDPOINT', 'http://127.0.0.1:6666/api/') What would be the equivalent in Angular (with TypeScript)? I just don't want to repeat the API bas...

Is there a way to pass optional parameters to a function?

Is there a way in Python to pass optional parameters to a function while calling it and in the function definition have some code based on "only if the optional parameter is passed"...

Just what is an IntPtr exactly?

Through using IntelliSense and looking at other people's code, I have come across this IntPtr type; every time it has needed to be used I have simply put null or IntPtr.Zero and found most functions to work. What exactly is it and when/why is it used...

log4j: Log output of a specific class to a specific appender

I use log4j and would like to route the output of certain Loggers to specific files. I already have multiple appenders in place. Now, to make debugging easier, I want to tell log4j that the output generated by a specific class (e.g. foo.bar.Baz) sh...

How to write an XPath query to match two attributes?

Following Question: <div id="id-74385" class="guest clearfix" style="z-index: 999;"> Given above, If I want a XPath expression with checks both id and class, can we do it w/ 'and' condition LIKE: //div[@id='id-74385'] and div[@class='guest...

UILabel is not auto-shrinking text to fit label size

I have this strange issue, and im dealing with it for more than 8 hours now.. Depending on situation i have to calculate UILabels size dynamically, e.g my UIViewController receives an event and i change UILabels size. from bigger to smaller. The si...

Can we update primary key values of a table?

Can we update primary key values of a table?...

iloc giving 'IndexError: single positional indexer is out-of-bounds'

I am trying to encode some information to read into a Machine Learning model using the following import numpy as np import pandas as pd import matplotlib.pyplot as py Dataset = pd.read_csv('filename.csv', sep = ',') X = Dataset.iloc[:,:-1].values...

How to remove leading and trailing spaces from a string

I have the following input: string txt = " i am a string " I want to remove space from start of starting and end from a string. The result should be: "i am a string" How can I do this in c#?...

How to convert empty spaces into null values, using SQL Server?

I have a table and the columns on this table contains empty spaces for some records. Now I need to move the data to another table and replace the empty spaces with a NULL value. I tried to use: REPLACE(ltrim(rtrim(col1)),' ',NULL) but it doesn'...

Calling Scalar-valued Functions in SQL

I have migrated a database from oracle, and now have a few Scalar-valued Functions. However, when I call them, I get an error saying: Cannot find either column "dbo" or the user-defined function or aggregate "dbo.chk_mgr", or the name is ambiguo...

How to pause javascript code execution for 2 seconds

I want to stop execution for 2 seconds. So is this, but now follows a code block: <html> <head> <title> HW 10.12 </title> <script type="text/javascript"> for (var i = 1; i <= 5; i++) { ...

How to make String.Contains case insensitive?

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

merge two object arrays with Angular 2 and TypeScript?

I have gone across the JavaScript questions on this topic, this question is specifically about Angular2 with TypeScript. What I am trying to do is to concatenate the json objects to an array. My code looks something like this, public results: []; ...

Simple Deadlock Examples

I would like to explain threading deadlocks to newbies. I have seen many examples for deadlocks in the past, some using code and some using illustrations (like the famous 4 cars). There are also classic easily-deadlocked problems like The Dining Phil...

What are functional interfaces used for in Java 8?

I came across a new term in Java 8: "functional interface". I could only find one use of it while working with lambda expressions. Java 8 provides some built-in functional interfaces and if we want to define any functional interface then we...

get index of DataTable column with name

I have some code which sets the value of cells in a DataRow by column name i.e. row["ColumnName"] = someValue; I want to also set the value for this row in the column immediately to the right of the one found above. Clearly if I was getting the c...

How to make return key on iPhone make keyboard disappear?

I have two UITextFields (e.g. username and password) but I cannot get rid of the keyboard when pressing the return key on the keyboard. How can I do this? ...

How to define a default value for "input type=text" without using attribute 'value'?

I need to give a default value for input type=text field as follows: <input type="text" size="32" value="" name="fee" /> There is one way to give this default value as I know: <input type="text" size="32" value="1000" name="fee" /> ...

List all kafka topics

I'm using kafka 0.10 without zookeeper. I want to get kafka topics list. This command is not working since we're not using zookeeper: bin/kafka-topics.sh --list --zookeeper localhost:2181. How can I get the same output without zookeeper?...

multiple figure in latex with captions

How can I insert multiple figures each of them has a caption and label, without using minipage. I wrote this code, but just there is one caption :( \begin{figure}[htp] \centering \label{figur}\caption{equation...} \begin{tabular}{cc} ...

Reading an image file in C/C++

I need to read an image file in C/C++. It would be very great, if some one can post the code for me. I work on gray scale images and the images are JPEG. I would like to read the images into a 2D array which will make my work easy. ...

Why is git push gerrit HEAD:refs/for/master used instead of git push origin master

I've just started using gerrit and I want to know why we need to do git push gerrit HEAD:refs/for/master instead of doing git push origin master If I do git push origin master I get the error saying ! [remote rejected] master -> master (prohibite...

How do I find duplicates across multiple columns?

So I want to do something like this sql code below: select s.id, s.name,s.city from stuff s group by s.name having count(where city and name are identical) > 1 To produce the following, (but ignore where only name or only city match, it has to...

matplotlib error - no module named tkinter

I tried to use the matplotlib package via Pycharm IDE on windows 10. when I run this code: from matplotlib import pyplot I get the following error: ImportError: No module named 'tkinter' I know that in python 2.x it was called Tkinter, but that...

MySQL Insert with While Loop

I'm trying to create a bunch of records in my MySQL database. This is a one time creation so I am not trying to create a stored procedure. Here is my code: BEGIN SET i = 2376921001; WHILE (i <= 237692200) DO INSERT INTO `mytable` (code, act...

Gcc error: gcc: error trying to exec 'cc1': execvp: No such file or directory

I have been successfully using gcc on Linux Mint 12. Now I am getting an error. I have recently been doing some .so builds and installed Clang not to long ago, but have successfully compiled since both of those events, so not sure what has changed. I...

npm install private github repositories by dependency in package.json

I'm trying to install github private repository by npm that includes other private github repositories as dependency. Have tried a lot of ways and posts but none is working. Here is what i'm doing : npm install git+https://github.com/myusername/myg...

How different is Objective-C from C++?

What are the main differences between Objective-C and C++ in terms of the syntax, features, paradigms, frameworks and libraries? *Important: My goal is not to start a performance war between the two languages. I only want real hard facts. In fact, m...

system("pause"); - Why is it wrong?

Here's a question that I don't quite understand: The command, system("pause"); is taught to new programmers as a way to pause a program and wait for a keyboard input to continue. However, it seems to be frowned on by many veteran programmers as some...

Creating a new column based on if-elif-else condition

I have a DataFrame df: A B a 2 2 b 3 1 c 1 3 I want to create a new column based on the following criteria: if row A == B: 0 if rowA > B: 1 if row A < B: -1 so given the above table, it should be: A B C...

Smooth scroll to specific div on click

What I'm trying to do is make it so that if you click on a button, it scrolls down (smoothly) to a specific div on the page. What I need is if you click on the button, it smooth scrolls to the div 'second'. _x000D_ _x000D_ .first {_x000D_ width...

log4net vs. Nlog

Anyone have experience for both? How do they stack up against each other? We are planning on using one of them for logging in an enterprise application. References: log4net nlog EDIT: We have no existing dependencies to either nlog or log4net....

When to use <span> instead <p>?

As the question indicates, if I have some text that I want to add in the HTML then when should I use <p> and when should I use <span>?...

Creating a node class in Java

So I'm fairly new to Java and programming and I was wondering how to create a node class? So far I have: public class ItemInfoNode{ private ItemInfoNode next; private ItemInfoNode prev; private ItemInfo info; public ItemInfoNode(I...

Clear variable in python

Is there a way to clear the value of a variable in python? For example if I was implementing a binary tree: class Node: self.left = somenode1 self.right = somenode2 If I wanted to remove some node from the tree, I would need to set self.left...

Where does the @Transactional annotation belong?

Should you place the @Transactional in the DAO classes and/or their methods or is it better to annotate the Service classes which are calling using the DAO objects? Or does it make sense to annotate both "layers"?...

Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields?

I have a Person model that has a foreign key relationship to Book, which has a number of fields, but I'm most concerned about author (a standard CharField). With that being said, in my PersonAdmin model, I'd like to display book.author using list_di...

Finding absolute value of a number without using Math.abs()

Is there any way to find the absolute value of a number without using the Math.abs() method in java....

Getting "Skipping JaCoCo execution due to missing execution data file" upon executing JaCoCo

I'm using Maven 3.0.3, JUnit 4.8.1, and Jacoco 0.6.3.201306030806, and I am trying to create test coverage reports. I have a project with unit tests only, but I can't get reports to run, I'm repeatedly getting the error: Skipping JaCoCo execution du...

How to call Base Class's __init__ method from the child class?

If I have a python class as: class BaseClass(object): #code and the init function of the base class And then I define a child class such as: class ChildClass(BaseClass): #here I want to call the init function of the base class If the init funct...

Why doesn't os.path.join() work in this case?

The below code will not join, when debugged the command does not store the whole path but just the last entry. os.path.join('/home/build/test/sandboxes/', todaystr, '/new_sandbox/') When I test this it only stores the /new_sandbox/ part of the cod...

how to download file using AngularJS and calling MVC API?

I am using AngularJS, and I have a MVC 4 API that returns a HttpResponseMessage with an attachment. var result = new MemoryStream(pdfStream, 0, pdfStream.Length) { Position = 0 }; var response = new HttpResponseMessage { StatusCode = HttpS...

Radio Buttons ng-checked with ng-model

In my HTML page, I have two sets of Boolean based radio buttons: Labeled: "Yes" and "No" / Values: True and False respectively. I'm populating a full form from a PostgreSQL database table to allow the authenticated user to view the form with populate...

Displaying standard DataTables in MVC

Perhaps this is just completely wrong, but back in the days of Webforms you would return a Dataset which you would then bind to a grid. But now in MVC you're not supposed to pass a datatable because you cannot serialize it and it's technically passi...

Loop through a date range with JavaScript

Given two Date() objects, where one is less than the other, how do I loop every day between the dates? for(loopDate = startDate; loopDate < endDate; loopDate += 1) { } Would this sort of loop work? But how can I add one day to the loop counte...

How can I get a resource "Folder" from inside my jar File?

I have a resources folder/package in the root of my project, I "don't" want to load a certain File. If I wanted to load a certain File, I would use class.getResourceAsStream and I would be fine!! What I actually want to do is to load a "Folder" withi...

Detect if the app was launched/opened from a push notification

Is it possible to know if the app was launched/opened from a push notification? I guess the launching event can be caught here: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if (...

C# difference between == and Equals()

I have a condition in a silverlight application that compares 2 strings, for some reason when I use == it returns false while .Equals() returns true. Here is the code: if (((ListBoxItem)lstBaseMenu.SelectedItem).Content.Equals("Energy Attack")) { ...

Direct method from SQL command text to DataSet

What is the most direct route to get a DataSet if I have a sql command? string sqlCommand = "SELECT * FROM TABLE"; string connectionString = "blahblah"; DataSet = GetDataSet(sqlCommand,connectionString); GetDataSet() { //...? } I started with...

How to extract extension from filename string in Javascript?

how would i get the File extension of the file in a variable? like if I have a file as 1.txt I need the txt part of it....

NSDate get year/month/day

How can I get the year/month/day of a NSDate object, given no other information? I realize that I could probably do this with something similar to this: NSCalendar *cal = [[NSCalendar alloc] init]; NSDateComponents *components = [cal components:0 fr...

Predicate Delegates in C#

Can you explain to me: What is a Predicate Delegate? Where should we use predicates? Any best practices when using predicates? Descriptive source code will be appreciated....

How to center a label text in WPF?

How to center a label text in WPF? Label HorizontalAlignment="Center" Content="What?" FontSize="25" FontWeight="Bold" Canvas.Top="5" ...

Select by partial string from a pandas DataFrame

I have a DataFrame with 4 columns of which 2 contain string values. I was wondering if there was a way to select rows based on a partial string match against a particular column? In other words, a function or lambda function that would do something ...

what is the use of xsi:schemaLocation?

I see that we have multiple url's as value of this attribute like in spring: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xs...

CGContextDrawImage draws image upside down when passed UIImage.CGImage

Does anyone know why CGContextDrawImage would be drawing my image upside down? I am loading an image in from my application: UIImage *image = [UIImage imageNamed:@"testImage.png"]; And then simply asking core graphics to draw it to my context: CG...

count number of rows in a data frame in R based on group

I have a data frame in R like this: ID MONTH-YEAR VALUE 110 JAN. 2012 1000 111 JAN. 2012 2000 . . . . 121 FEB. 2012 3000 131 FEB. 2012 4000 . . . ...

Selecting element by data attribute with jQuery

Is there an easy and straight-forward method to select elements based on their data attribute? For example, select all anchors that has data attribute named customerID which has value of 22. I am kind of hesitant to use rel or other attributes to...

How to manage startActivityForResult on Android?

In my activity, I'm calling a second activity from the main activity by startActivityForResult. In my second activity, there are some methods that finish this activity (maybe without a result), however, just one of them returns a result. For example...

How to filter an array of objects based on values in an inner array with jq?

Given this input: [ { "Id": "cb94e7a42732b598ad18a8f27454a886c1aa8bbba6167646d8f064cd86191e2b", "Names": [ "condescending_jones", "loving_hoover" ] }, { "Id": "186db739b7509eb0114a09e14bcd16bf637019860d23c4fc20e98cb...

'System.Net.Http.HttpContent' does not contain a definition for 'ReadAsAsync' and no extension method

I made a console app to consume a Web API I just made. The console app code does not compile. It gives me the compilation error: 'System.Net.Http.HttpContent' does not contain a definition for 'ReadAsAsync' and no extension method 'ReadAsAsync' acc...

How to get public directory?

I am a beginner here so pardon me for this question am using return File::put($path , $data); to create a file in public folder on Laravel. I used this piece of code from controller I need to know the value of $path how should it be....

How to Change Margin of TextView

I have TextView added Programmatically in to LinearLayout and on some external events I want to decrease bottom margin of that TextView to -10, for that I tried following. LinearLayout.LayoutParams lastTxtParams = new LinearLayout.LayoutParams(Line...

How do I read an image file using Python?

How do I read an image file and decode it using Python?...

How to get english language word database?

I need a database of every single valid word in English. I checked the /usr/share/dict/words file, it contains less than 100k words. Wikipedia says English has 475k words. Where do I get the complete list (American spelling)? Also, is there a singl...

WHILE LOOP with IF STATEMENT MYSQL

I would like to create a stored routine for MySQL that figures out the number of business or working days for a month (Working Days are Monday thru Friday). It's a syntax error however I don't know what the syntax error is. All it tells me is: ...

Import JavaScript file and call functions using webpack, ES6, ReactJS

Trying to do something I would think would be very simple. I would like to import an existing JavaScript library and then call it's functions. So for example I would like to import blah.js and then call blah(). import React from 'react'; import {b...

How to create a new instance from a class object in Python

I need to dynamically create an instance of a class in Python. Basically I am using the load_module and inspect module to import and load the class into a class object, but I can't figure out how to create an instance of this class object. Please he...

Flutter command not found

bash: flutter: command not found Apparently, none of the flutter commands are working on the terminal of an android studio which I believe I am trying to run it at the root of my project....

How to dynamically add a class to manual class names?

I need to add a dynamic class to a list of regular classes, but have no idea how (I'm using babel), something like this: <div className="wrapper searchDiv {this.state.something}"> ... </div> Any ideas?...

How do I show the value of a #define at compile-time?

I am trying to figure out what version of Boost my code thinks it's using. I want to do something like this: #error BOOST_VERSION but the preprocessor does not expand BOOST_VERSION. I know I could print it out at run-time from the program, and I k...

Navigation bar with UIImage for title

I want to customize my app's look by using a logo image as the navigation bar's title, instead of plain text. When I use this code let logo = UIImage(named: "logo.png") self.navigationItem.titleView = logo; I get the error "UIImage is not converti...

Android - set TextView TextStyle programmatically?

Is there a way to set the textStyle attribute of a TextView programmatically? There doesn't appear to be a setTextStyle() method. To be clear, I am not talking about View / Widget styles! I am talking about the following: <TextView android:id=...

How to control the width of select tag?

I have a list of countries, some with a very long name: <select name=countries> <option value=af>Afghanistan</option> <option value=ax>Åland Islands</option> ... <option value=gs>South Georgia and the South S...

What does += mean in Python?

I see code like this for example in Python: if cnt > 0 and len(aStr) > 1: while cnt > 0: aStr = aStr[1:]+aStr[0] cnt += 1 What does the += mean?...

Set the value of a variable with the result of a command in a Windows batch file

When working in a Bash environment, to set the value of a variable as the result of a command, I usually do: var=$(command -args) where var is the variable set by the command command -args. I can then access that variable as $var. A more conventi...

Tomcat won't stop or restart

I tried stopping tomcat. It failed with this message: Tomcat did not stop in time. PID file was not removed. I then tried again and got this: PID file (/opt/tomcat/work/catalina.pid) found but no matching process was found. Stop aborted. I t...

ipad safari: disable scrolling, and bounce effect?

I'm working on a browser based app, currently I'm developing and styling for the ipad safari browser. I'm looking for two things on the ipad: How can I disable vertical scrolling for pages that don't require it? & how can I disable the elastic b...

Find size of object instance in bytes in c#

For any arbitrary instance (collections of different objects, compositions, single objects, etc) How can I determine its size in bytes? (I've currently got a collection of various objects and i'm trying to determine the aggregated size of it) EDIT...

Compiler error: "class, interface, or enum expected"

I have been troubleshooting this program for hours, trying several configurations, and have had no luck. It has been written in java, and has 33 errors (lowered from 50 before) Source Code: /*This program is named derivativeQuiz.java, stored on a n...

How to break out of nested loops?

If I use a break statement, it will only break inner loop and I need to use some flag to break the outer loop. But if there are many nested loops, the code will not look good. Is there any other way to break all of the loops? (Please don't use goto ...

Can I use a :before or :after pseudo-element on an input field?

I am trying to use the :after CSS pseudo-element on an input field, but it does not work. If I use it with a span, it works OK. <style type="text/css"> .mystyle:after {content:url(smiley.gif);} .mystyle {color:red;} </style> This work...

Get the Application Context In Fragment In Android?

I have stored some data to a Global Class By using the Application Context In One Activity. Later I have to Retrieve those values in A Fragment. I have done something like this to store in Global Class. AndroidGlobalClass AGC = ((AndroidGlobalClass...

If Radio Button is selected, perform validation on Checkboxes

I'm trying to work this form so when the first radio button is selected, run a certain validation. When the second radio button is selected, run a different validation, etc. Currently using Alerts to check the functionality, but whichever radio butto...

Lodash remove duplicates from array

This is my data: [ { url: 'www.example.com/hello', id: "22" }, { url: 'www.example.com/hello', id: "22" }, { url: 'www.example.com/hello-how-are-you', id: "23" }, ...

python-dev installation error: ImportError: No module named apt_pkg

I am Debian user, and I want to install python-dev, but when I run the code in the shell as a root: # aptitude install python-dev I get the following error: Traceback (most recent call last): File "/usr/bin/apt-listchanges", line 28, in ...

Error Code 1292 - Truncated incorrect DOUBLE value - Mysql

I am not sure what is this error! #1292 - Truncated incorrect DOUBLE value: I don't have double value field or data! I have wasted a whole hour trying to figure this out! here is my query INSERT INTO call_managment_system.contact_numbers ...

Eventviewer eventid for lock and unlock

What is the event id in Event Viewer for lock, unlock for a computer in Windows XP, Windows 7, Windows Vista and Windows Server 2008?...

How to change font in ipython notebook

I am fairly new to python and have no html experience. The question has been asked and either not answered at all or not answered in enough detail for me to set the default font within iPython (not change to browser). Specifically, what has to be put...

How can I backup a remote SQL Server database to a local drive?

I need to copy a database from a remote server to a local one. I tried to use SQL Server Management Studio, but it only backs up to a drive on the remote server. Some points: I do not have access to the remote server in a way that I could copy fil...

How do I fill arrays in Java?

I know how to do it normally, but I could swear that you could fill out out like a[0] = {0,0,0,0}; How do you do it that way? I did try Google, but I didn't get anything helpful....

How to read data from a zip file without having to unzip the entire file

Is there anyway in .Net (C#) to extract data from a zip file without decompressing the complete file? Simply I possibly want to extract data (file) from the start of a zip file, obviously this depends if the compression algorithm compress the file i...

Splitting string with pipe character ("|")

I'm not able to split values from this string: "Food 1 | Service 3 | Atmosphere 3 | Value for money 1 " Here's my current code: String rat_values = "Food 1 | Service 3 | Atmosphere 3 | Value for money 1 "; String[] value_split = rat_values.split(...

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

Equal sized table cells to fill the entire width of the containing table

Is there a way using HTML/CSS (with relative sizing) to make a row of cells stretch the entire width of the table within which it is contained? The cells should be equal widths and the outer table size is also dynamic with <table width="100%">...

how to bypass Access-Control-Allow-Origin?

I'm doing a ajax call to my own server on a platform which they set prevent these ajax calls (but I need it to fetch the data from my server to display retrieved data from my server's database). My ajax script is working , it can send the data over t...

Eclipse add Tomcat 7 blank server name

I was trying to add Tomcat 7 in my Eclipse in Ubuntu. When I click "Add new server" in Eclipse and select "Tomcat v7.0 Server", the field "Server Name" is blank and I cannot type in anything in that textbox as shown below: What I did before is I d...

How can I run multiple npm scripts in parallel?

In my package.json I have these two scripts: "scripts": { "start-watch": "nodemon run-babel index.js", "wp-server": "webpack-dev-server", } I have to run these 2 scripts in parallel everytime I start developing in Node.js. The first th...

Insert an element at a specific index in a list and return the updated list

I have this: >>> a = [1, 2, 4] >>> print a [1, 2, 4] >>> print a.insert(2, 3) None >>> print a [1, 2, 3, 4] >>> b = a.insert(3, 6) >>> print b None >>> print a [1, 2, 3, 6, 4] Is the...

In-memory size of a Python structure

Is there a reference for the memory size of Python data stucture on 32- and 64-bit platforms? If not, this would be nice to have it on SO. The more exhaustive the better! So how many bytes are used by the following Python structures (depending on th...

How to change Oracle default data pump directory to import dumpfile?

I'm using impdp to import a backup. But I want change default directory dumpfile. $ impdp system/password@$ORACLE_SID schemas=USER_SCHEMA dumpfile=mydumpfile.dmp logfile=impdpmydumpfile.log Import: Release 11.2.0.3.0 - Production on Mon Mar 16 09:3...

In jQuery, how do I get the value of a radio button when they all have the same name?

Here is my code: <table> <tr> <td>Sales Promotion</td> <td><input type="radio" name="q12_3" value="1">1</td> <td><input type="radio" name="q12_3" value="2">2</td> ...

List tables in a PostgreSQL schema

When I do a \dt in psql I only get a listing of tables in the current schema (public by default). How can I get a list of all tables in all schemas or a particular schema?...

Eclipse: The resource is not on the build path of a Java project

I have been given a Source Folder (src) of a Java Project. I have created a .project file, kept it inside that folder and imported that Project into Eclipse 3.6 through the Import Existing Projects into Workspace Option and added required jars to it....

JAVA Unsupported major.minor version 51.0

I'm not a programmer but I couldn't find any answer on this website. I'm trying to run a game on linux ubuntu with Java Open JDK but nothing happen. I tried to run it with the prompt command and it said this: leops95@leops95-SATELLITE-C660:~$ '/home...

XML Schema (XSD) validation tool?

At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an .XSD file. Are there tool or libraries that we can use for automated testing to check that the generate...

What is __main__.py?

What is the __main__.py file for, what sort of code should I put into it, and when should I have one?...

How do I attach events to dynamic HTML elements with jQuery?

Suppose I have some jQuery code that attaches an event handler to all elements with class .myclass. For example: $(function(){ $(".myclass").click( function() { // do something }); }); And my HTML might be as follows: <a clas...

Creating a zero-filled pandas data frame

What is the best way to create a zero-filled pandas data frame of a given size? I have used: zero_data = np.zeros(shape=(len(data),len(feature_list))) d = pd.DataFrame(zero_data, columns=feature_list) Is there a better way to do it?...

Remove all elements contained in another array

I am looking for an efficient way to remove all elements from a javascript array if they are present in another array. // If I have this array: var myArray = ['a', 'b', 'c', 'd', 'e', 'f', 'g']; // and this one: var toRemove = ['b', 'c', 'g']; I ...

Xampp MySQL not starting - "Attempting to start MySQL service..."

I've just installed XAMPP for Windows - should be the newest version (XAMPP Control Panel v3.2.1). Apache is running just fine on port 80 and 443, but MySQL is not starting. When I press the start button, I get this message: Attempting to start...

Getting Data from Android Play Store

I have seen some Apps and Websites who use Data from the Android Play store. E.g. Apps or Sites with a top Apps ranking etc. But how can you get the Data? From where I can parse it? ...

How to set a value for a selectize.js input?

I have a form from which I would like to copy some default values into the inputs. The form inputs are using the selectize.js plugin. I would like to set some of the form values programatically. The standard way of doing this: $("#my_input").val(...

Check a collection size with JSTL

How can I check the size of a collection with JSTL? Something like: <c:if test="${companies.size() > 0}"> </c:if> ...

RegEx - Match Numbers of Variable Length

I'm trying to parse a document that has reference numbers littered throughout it. Text text text {4:2} more incredible text {4:3} much later on {222:115} and yet some more text. The references will always be wrapped in brackets, and there wil...

unique() for more than one variable

I have the following data frame in R: > str(df) 'data.frame': 545227 obs. of 15 variables: $ ykod : int 93 93 93 93 93 93 93 93 93 93 ... $ yad : Factor w/ 42 levels "BAKUGAN","BARBIE",..: 30 30 30 30 30 30 30 30 30 30 ... $ per : Factor...

Multiple file upload in php

I want to upload multiple files and store them in a folder and get the path and store it in the database... Any good example you looked for doing multiple file upload... Note: Files can be of any type......

Android Camera : data intent returns null

I have an android application which contains multiple activities. In one of them I'm using a button which will call the device camera : public void onClick(View view) { Intent photoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); star...

Git push won't do anything (everything up-to-date)

I'm trying to update a Git repository on GitHub. I made a bunch of changes, added them, committed then attempted to do a git push. The response tells me that everything is up to date, but clearly it's not. git remote show origin responds with the ...

MySQL stored procedure vs function, which would I use when?

I'm looking at MySQL stored procedures and function. What is the real difference? They seem to be similar, but a function has more limitations. I'm likely wrong, but it seems a stored procedure can do everything and more a stored function can. Why...

Validate IPv4 address in Java

I want to validate an IPv4 address using Java. It should be written using the dot-decimal notation, so it should have 3 dots ("."), no characters, numbers in between the dots, and numbers should be in a valid range. How should it be done?...

Implementation difference between Aggregation and Composition in Java

I'm aware of the conceptual differences between Aggregation and Composition. Can someone tell me the implementation difference in Java between them with examples? ...

window.location.href not working

My website is http://www.collegeanswerz.com/. I'm using rails. The code is for searching for colleges. I want the user to be able to type in the colleges name, click enter, and be taken to the url, rather than seeing the search results (if the use...

Matplotlib 2 Subplots, 1 Colorbar

I've spent entirely too long researching how to get two subplots to share the same y-axis with a single colorbar shared between the two in Matplotlib. What was happening was that when I called the colorbar() function in either subplot1 or subplot2,...

How can I render Partial views in asp.net mvc 3?

I have some data in ViewData.Model, and in my views I want to write a partial view and to pass their current model I have in my page. How I can pass their current ViewData.Model and render them through the location of partials?...

Retrieving and Saving media metadata using FFmpeg

I want to read the metadata in media files and then save that metadata in a text/xml file, so that I can later insert that data in my database. I would prefer to use ffmpeg. Also is the same thing possible with MediaInfo?? I know I can get the metad...

Differences between Lodash and Underscore.js

Why would someone prefer either the Lodash or Underscore.js utility library over the other? Lodash seems to be a drop-in replacement for underscore, the latter having been around longer. I think both are brilliant, but I do not know enough about how ...

Why doesn't Java support unsigned ints?

Why doesn't Java include support for unsigned integers? It seems to me to be an odd omission, given that they allow one to write code that is less likely to produce overflows on unexpectedly large input. Furthermore, using unsigned integers can...

Define an <img>'s src attribute in CSS

I need to define an <img>'s src attribute in CSS. Is there a way to specify this attribute?...

Optimum way to compare strings in JavaScript?

I am trying to optimize a function which does binary search of strings in JavaScript. Binary search requires you to know whether the key is == the pivot or < the pivot. But this requires two string comparisons in JavaScript, unlike in C like lan...

Convert string to nullable type (int, double, etc...)

I am attempting to do some data conversion. Unfortunately, much of the data is in strings, where it should be int's or double, etc... So what I've got is something like: double? amount = Convert.ToDouble(strAmount); The problem with this approac...

Modify request parameter with servlet filter

An existing web application is running on Tomcat 4.1. There is an XSS issue with a page, but I can't modify the source. I've decided to write a servlet filter to sanitize the parameter before it is seen by the page. I would like to write a Filter ...

What are the differences between a pointer variable and a reference variable in C++?

I know references are syntactic sugar, so code is easier to read and write. But what are the differences?...

Maven 3 warnings about build.plugins.plugin.version

Since I updated to Maven 3 I get the following warning messages at each build : How can I get rid of these warnings? [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for proj:id:...

How to resize the jQuery DatePicker control

I'm using the jQuery DatePicker control for the first time. I've got it working on my form, but it's about twice as big as I would like, and about 1.5 times as big as the demo on the jQuery UI page. Is there some simple setting I'm missing to control...

HTML not loading CSS file

I am completely stumped as to why this doesn't work. It seems the HTML file can't load the CSS for some reason, even though both are in the same directory. Any idea what might be the problem? index.html <!DOCTYPE html> <html> <head&g...

Cannot set content-type to 'application/json' in jQuery.ajax

When I have this code $.ajax({ type: 'POST', //contentType: "application/json", url: 'http://localhost:16329/Hello', data: { name: 'norm' }, dataType: 'json' }); in Fiddler I can see following raw request POST http://localhost...

Creating a procedure in mySql with parameters

I am trying to make a stored procedure using mySQL. This procedure will validate a username and a password. I'm currently running mySQL 5.0.32 so it should be possible to create procedures. Heres the code I've used. All I get is an SQL syntax error...

What is the difference between Dim, Global, Public, and Private as Modular Field Access Modifiers?

In VB6/VBA, you can declare module-level variables outside of a specific Sub or Function method. I've used Private and Public before inside modules and understand them like so: Public - visible to all code inside the module and all code outside th...

how to hide keyboard after typing in EditText in android?

I have a EditText and button aligned to parent's bottom. When I enter text in it and press the button to save data, the virtual keyboard does not disappear. Can any one guide me how to hide the keyboard?...

Adding css class through aspx code behind

I am using aspx. If I have HTML as follows: <div id="classMe"></div> I am hoping to dynamically add a css class through the code behind file, ie on Page_Load. Is it possible?...

How can I use onItemSelected in Android?

package org.example.mbtiapplication; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android....

Can jQuery check whether input content has changed?

Is it possible to bind javascript (jQuery is best) event to "change" form input value somehow? I know about .change() method, but it does not trigger until you (the cursor) leave(s) the input field. I have also considered using .keyup() method but ...

How to run a script at a certain time on Linux?

I have a text file containing a specific date and time. I want to be able to run a script at the time specified in that file. How would you achieve that? Create another script that runs in background (sort of a deamon) and checks every second if the...

The executable gets signed with invalid entitlements in Xcode

I got this error with Xcode 5 when I try to run the app on my device. The executable was signed with invalid entitlement It worked fine with Xcode 4.x. Anyone knows how to get rid of the error? ...

How to change context root of a dynamic web project in Eclipse?

I developed a dynamic web project in Eclipse. I can access the app through my browser using the following URL: http://localhost:8080/MyDynamicWebApp I want to change the access URL to: http://localhost:8080/app To do so, I changed the context...

connecting MySQL server to NetBeans

I am trying to connect MySQL database in Netbeans and stuck at the very first step- connecting the database. My Database is working fine on the console - tried command mysqladmin -u root -p ping and it says mysql id is alive. I have even created data...

MySQL query to get column names?

I'd like to get all of a mysql table's col names into an array in php? Is there a query for this? ...

Compiled vs. Interpreted Languages

I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dyn...

making a paragraph in html contain a text from a file

I have an html paragraph (inside a div) in which I want to display a simple fixed text. The text is a bit long so I'd rather the text will be in a seperate txt file. something like <div><p txt=file.txt></p></div> Can I do ...

matplotlib savefig() plots different from show()

When I use show() to plot the graphs in X, the graphs looks very good. However when I start to use savefig() to generate large amount of graphs, the savefig() generated graphs ' font, lines, polygons all look smaller than the show() generated graph. ...

How to hide/show div tags using JavaScript?

Basically, I'm trying to make a link that, when pressed, will hide the current body div tag and show another one in its place, unfortunately, when I click the link, the first body div tag still appears. Here is the HTML code: <div id="body"> ...

Getting the class of the element that fired an event using JQuery

is there anyway to get the class when click event is fired. My code as below, it only work for id but not class. _x000D_ _x000D_ $(document).ready(function() {_x000D_ $("a").click(function(event) {_x000D_ alert(event.target.id + " and " + even...

Using boolean values in C

C doesn't have any built-in boolean types. What's the best way to use them in C?...

Chrome's remote debugging (USB debugging) not working for Samsung Galaxy S3 running android 4.3

Ever since I upgraded my Samsung Galaxy S3 to android 4.3 (from 4.1.2) I am unable to use Chrome's remote debugging for android (more details here). I have the developer options and USB debugging enabled on my phone, and this worked perfectly fine o...

How to delete files older than X hours

I'm writing a bash script that needs to delete old files. It's currently implemented using : find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete This will delete of the files older than 1 day. However, what if I need a finer resolutio...

How to specify a min but no max decimal using the range data annotation attribute?

I would like to specify that a decimal field for a price must be >= 0 but I don't really want to impose a max value. Here's what I have so far...I'm not sure what the correct way to do this is. [Range(typeof(decimal), "0", "??"] public decimal Pric...

How to change the color of winform DataGridview header?

I have tried to do it without success. Is it possible ?...

Making Python loggers output all messages to stdout in addition to log file

Is there a way to make Python logging using the logging module automatically output things to stdout in addition to the log file where they are supposed to go? For example, I'd like all calls to logger.warning, logger.critical, logger.error to go to ...

How to get next/previous record in MySQL?

Say I have records with ID 3,4,7,9 I want to be able to go from one to another by navigation via next/previous links. The problem is, that I don't know how to fetch record with nearest higher ID. So when I have a record with ID 4, I need to be able t...

How to push JSON object in to array using javascript

I am trying to fetch the JSON data from an url.It is in the form of object i have to push the object data into array. var my_json; $.getJSON("https://api.thingspeak.com/channels/"+did+"/feeds.json?api_key="+apikey+"&results=300", function(json1)...

Disable future dates after today in Jquery Ui Datepicker

I want to disable all the future dates after today in Jquery Ui Datepicker Here is the Demo : Code : $( "#start_date" ).datepicker( { maxDate: '0', beforeShow : function() { jQuery( t...

Programmatically get own phone number in iOS

Is there any way to get own phone number by standard APIs from iPhone SDK?...

How do I remove diacritics (accents) from a string in .NET?

I'm trying to convert some strings that are in French Canadian and basically, I'd like to be able to take out the French accent marks in the letters while keeping the letter. (E.g. convert é to e, so crème brûlée would become creme brulee) What ...

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 set a program to launch at startup

I have a small application with a CheckBox option that the user can set if they want the app to start with Windows. My question is how do I actually set the app to run at startup. ps: I'm using C# with .NET 2.0....

How do you append rows to a table using jQuery?

Hi I was trying to add a row to a table using jQuery, but it is not working. What might be the reason? And, can I put in some value to the newly added row..? Here is the code: <html> <head> <script type="text/javascript" src="jq...

Maximum length for MySQL type text

I'm creating a form for sending private messages and want to set the maxlength value of a textarea appropriate to the max length of a text field in my MySQL database table. How many characters can a type text field store? If a lot, would I be able t...

One time page refresh after first page load

I would like to implement a JavaScript code which states this: if the page is loaded completely, refresh the page immediately, but only once. I'm stuck at the "only once": window.onload = function () {window.location.reload()} this gives a loop wi...

Ping all addresses in network, windows

Is it possible in windows cmd line to check all of the network addresses (with ping or similar) to see which ones are taken/ have active devices: ie. something that does something like the following: for i = 0 to 255 ping 192.168.1.i //Print th...

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

Jquery UI Datepicker not displaying

UPDATE I have reverted back to Jquery 1.3.2 and everything is working, not sure what the problem is/was as I have not changed anything else apart of the jquery and ui library versions. UPDATE END I having an issue with the JQuery UI datepicker. The ...

Pass Multiple Parameters to jQuery ajax call

I have the following jquery code to call a webmethod in an aspx page $.ajax({ type: "POST", url: "popup.aspx/GetJewellerAssets", contentType: "application/json; charset=utf-8", data: '{"jewellerId":' + filter + '}', dataType: "js...

Header and footer in CodeIgniter

I really don't enjoy writing in every controller: $this->load->view('templates/header'); $this->load->view('body'); $this->load->view('templates/footer'); Is it possible to do, that header and footer would be included...

How to generate and validate a software license key?

I'm currently involved in developing a product (developed in C#) that'll be available for downloading and installing for free but in a very limited version. To get access to all the features the user has to pay a license fee and receive a key. That k...

jQuery UI: Datepicker set year range dropdown to 100 years

Using the Datepicker the year drop down by default shows only 10 years. The user has to click the last year in order to get more years added. How can we set the initial range to be 100 years so that the user will see a large list by default? ...

Get the IP address of the machine

This Question is almost the same as the previously asked Get the IP Address of local computer-Question. However I need to find the IP address(es) of a Linux Machine. So: How do I - programmatically in C++ - detect the IP addresses of the linux serve...

What does a lazy val do?

I noticed that Scala provide lazy vals. But I don't get what they do. scala> val x = 15 x: Int = 15 scala> lazy val y = 13 y: Int = <lazy> scala> x res0: Int = 15 scala> y res1: Int = 13 The REPL shows that y is a lazy val, bu...

Huge performance difference when using group by vs distinct

I am performing some tests on a HSQLDB server with a table containing 500 000 entries. The table has no indices. There are 5000 distinct business keys. I need a list of them. Naturally I started with a DISTINCT query: SELECT DISTINCT business_key FR...

pip install: Please check the permissions and owner of that directory

While installing pip and python I have ran into a that says: The directory '/Users/Parthenon/Library/Logs/pi' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of ...

REST API - Bulk Create or Update in single request

Let's assume there are two resources Binder and Doc with association relationship meaning that the Doc and Binder stand on their own. Doc might or might not belong to Binder and Binder might be empty. If I want to design a REST API that allows a use...

Resetting MySQL Root Password with XAMPP on Localhost

So for the past hour I've been trying to figure out how to reset my 'root' password for MySQL as I cannot log into PHPMyAdmin. I've tried changing the password in the config.inc.php file and searching through other methods. I cannot find a successful...

How To Save Canvas As An Image With canvas.toDataURL()?

I'm currently building a HTML5 web app/Phonegap native app and I can't seem to figure out how to save my canvas as an image with canvas.toDataURL(). Can somebody help me out? Here's the code, what's wrong with it? //My canvas was named "canvasSigna...

Relative path to absolute path in C#?

I have xml files that contain href file paths to images (e.g. "....\images\image.jpg"). The hrefs contain relative paths. Now, I need to extract the hrefs to the images and turn them into absolute paths in the file system. I know about the GetFullPa...

MySQL 1062 - Duplicate entry '0' for key 'PRIMARY'

I have the following table in MySQL version 5.5.24 DROP TABLE IF EXISTS `momento_distribution`; CREATE TABLE IF NOT EXISTS `momento_distribution` ( `momento_id` INT(11) NOT NULL, `momento_idmember` INT(11) NOT NULL, `created_...

Split String into an array of String

I'm trying to find a way to split a String into an array of String(s), and I need to split it whenever a white spice is encountered, example "hi i'm paul" into" "hi" "i'm" "paul" How do you represent white spaces in split() method using ...

When does SQLiteOpenHelper onCreate() / onUpgrade() run?

I have created my tables in my SQLiteOpenHelper onCreate() but receive SQLiteException: no such table or SQLiteException: no such column errors. Why? NOTE: (This is the amalgamated summary of tens of similar questions every week. Attem...

jQuery - selecting elements from inside a element

let's say I have a markup like this: <div id="foo"> ... <span id="moo"> ... </span> ... </div> and I want to select #moo. why $('#foo').find('span') works, but $('span', $('#foo')); doesn't ?...

argparse module How to add option without any argument?

I have created a script using argparse. The script needs to take a configuration file name as an option, and user can specify whether they need to proceed totally the script or only simulate it. The args to be passed: ./script -f config_file -s or ...

Mocking methods of local scope objects with Mockito

I need some help with this: Example: void method1{ MyObject obj1=new MyObject(); obj1.method1(); } I want to mock obj1.method1() in my test but to be transparent so I don't want make and change of code. Is there any way to do this in Mock...

Why would someone use WHERE 1=1 AND <conditions> in a SQL clause?

Why would someone use WHERE 1=1 AND <conditions> in a SQL clause (Either SQL obtained through concatenated strings, either view definition) I've seen somewhere that this would be used to protect against SQL Injection, but it seems very weird. ...

Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

I am trying to install numpy on macOS X but after executing the command pip install numpy I am getting the error: Environment error :[error 13]: permission denied : 'usr/local/bin/f2py How do I fix it?...

How to configure log4j.properties for SpringJUnit4ClassRunner?

Suddenly this keeps happening during a JUnit test. Everything was working, I wrote some new tests and this error occured. If I revert it, it won't go away. Why is that? log4j:WARN No appenders could be found for logger (org.springframework.test.cont...

How to set a background image in Xcode using swift?

How can I set a background image for my main view controller in Xcode 6 using swift? I know that you can do this in the assistant editor as below: override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.yellowCol...

Parse string to DateTime in C#

I have date and time in a string formatted like that one: "2011-03-21 13:26" //year-month-day hour:minute How can I parse it to System.DateTime? I want to use functions like DateTime.Parse() or DateTime.ParseExact() if possible, to be able to spe...

Python 3 TypeError: must be str, not bytes with sys.stdout.write()

I was looking for a way to run an external process from python script and print its stdout messages during the execution. The code below works, but prints no stdout output during runtime. When it exits I am getting the following error: sys.stdout...

How to get the Facebook user id using the access token

I have a Facebook desktop application and am using the Graph API. I am able to get the access token, but after that is done - I don't know how to get the user's ID. My flow is like this: I send the user to https://graph.facebook.com/oauth/author...

Easy interview question got harder: given numbers 1..100, find the missing number(s) given exactly k are missing

I had an interesting job interview experience a while back. The question started really easy: Q1: We have a bag containing numbers 1, 2, 3, …, 100. Each number appears exactly once, so there are 100 numbers. Now one number is randomly picked out o...

Draw line in UIView

I need to draw a horizontal line in a UIView. What is the easiest way to do it. For example, I want to draw a black horizontal line at y-coord=200. I am NOT using Interface Builder. ...

Omit rows containing specific column of NA

I want to know how to omit NA values in a data frame, but only in some columns I am interested in. For example, DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA), z=c(NA, 33, 22)) but I only want to omit the data where y is NA, therefore the r...

Unable to launch the IIS Express Web server

I have an asp.net MVC 4 solution. When I try to open it using Visual studio 2012, I get following error: Microsoft Visual Studio Configuring Web https://localhost: for ASP.NET 4.5 failed. You must manually configure this site for ASP.NET 4...

How to solve SQL Server Error 1222 i.e Unlock a SQL Server table

I am working in a database where I load data in a raw table by a data loader. But today the data loader got stuck for unknown reasons. Then I stopped the data loader from windows task manager. But then I again tried to load data in the raw table but ...

coercing to Unicode: need string or buffer, NoneType found when rendering in django admin

I have this error since a long time but can't figure it out : Caught TypeError while rendering: coercing to Unicode: need string or buffer, NoneType found It happens in admin when I try to add or modify on one of my models (display works fine) Thi...

How to convert unix timestamp to calendar date moment.js

I have a unix timestamp, and I'm trying to convert it into a calendar date such as MM/DD/YYYY. So far, I have this: $(document).ready(function() { var value = $("#unixtime").val(); //this retrieves the unix timestamp var dateString = moment(val...

How do I remove a CLOSE_WAIT socket connection

I have written a small program that interacts with a server on a specific port. The program works fine, but: Once the program terminated unexpectedly, and ever since that socket connection is shown in CLOSE_WAIT state. If I try to run a program it h...

Datanode process not running in Hadoop

I set up and configured a multi-node Hadoop cluster using this tutorial. When I type in the start-all.sh command, it shows all the processes initializing properly as follows: starting namenode, logging to /usr/local/hadoop/libexec/../logs/hadoop-ro...

VBA: How to display an error message just like the standard error message which has a "Debug" button?

As usual, I create an error-handler using On Error Goto statement, there I put a few lines of cleaning codes and display the error message, but now I don't want to lose the comfortableness of the default handler which also point me to the exact line ...

capture div into image using html2canvas

I'm trying to capture a div into an image using html2canvas I have read some similar question here like How to upload a screenshot using html2canvas? create screenshot of web page using html2canvas (unable to initialize properly) I have tried t...

package javax.servlet.http does not exist

I have the jre7 and jdk1.7.0 installed along with the Tomcat 7.0 but it shows this error. servlet.http is not the only one that "does not exist", there are also other (servlet.) components. Can anybody help me with this? UPDATE: This error occurs w...

How do I clone a github project to run locally?

I am trying to follow this railscast tutorial for authlogic - and it points to the source here - I have git installed - how do I replicate the source onto my localhost so that I can follow the tutorial like in the screencast?...

What is the difference between Hibernate and Spring Data JPA

What are the main differences between Hibernate and Spring Data JPA? When should we not use Hibernate or Spring Data JPA? Also, when may Spring JDBC template perform better than Hibernate / Spring Data JPA?...