Examples On Programing Languages

C# getting its own class name

If I have a class called MyProgram, is there a way of retrieving "MyProgram" as a string?...

Entity Framework - Linq query with order by and group by

I have Measurement Objects with the relevant Properties CreationTime (DateTime) and Reference (String) and some other values. I'd like to write an efficient linq query to a DbContext that groups my Measurement objects by a given Reference orders ...

Can't use WAMP , port 80 is used by IIS 7.5

I am trying to use WAMP on Windows 7, my WAMP is online, but when I open localhost I get the welcome page of IIS 7.5, although I have uninstalled IIS 7.5 from my PC! Apache server test says that port 80 is used my Microsoft-HTTPAPI/2.0 MS Visual St...

How do I reverse a commit in git?

I'm not really familiar with how git works. I pushed a commit by mistake and want to revert it. I did a git reset --hard HEAD~1 Beware Fellow Googlers: This does not only revert the commit, but discards all file changes! and now the project is r...

Can I install the "app store" in an IOS simulator?

The IOS simulator in my computer doesn't have app store. I want to use the app store to test a program I wrote on my simulator. Is it possible to install the app store in my simulator?...

How do I replace all the spaces with %20 in C#?

I want to make a string into a URL using C#. There must be something in the .NET framework that should help, right?...

POST: sending a post request in a url itself

I have been given a url .. www.abc.com/details and asked to send my name and phone number on this url using POST. They have told me to set the content-type as application/json and the body as valid JSON with the following keys: name: name of the use...

jquery how to use multiple ajax calls one after the end of the other

I am in mobile app and I use multiple Ajax calls to receive data from web server like below function get_json() { $(document).ready(function() { $.ajax({ url: 'http://www.xxxxxxxxxxxxx', data: { na...

What does "javascript:void(0)" mean?

<a href="javascript:void(0)" id="loginlink">login</a> I've seen such hrefs many times, but I don't know what exactly that means....

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

How much does it cost to develop an iPhone application?

How much can a developer charge for an iPhone app like Twitterrific? I want to know this because I need such an application with the same functionality for a new community website. I can do Ruby but have no experience with Objective-C. So it would b...

.ssh directory not being created

To generate the .ssh dir I use this command: ssh-keygen taken from this tutorial: http://ebiquity.umbc.edu/Tutorials/Hadoop/05%20-%20Setup%20SSHD.html But the .ssh directory is not created so when I use cd ~/.ssh I get this error: "no such file ...

C default arguments

Is there a way to specify default arguments to a function in C?...

How to change MySQL column definition?

I have a mySQL table called test: create table test( locationExpect varchar(120) NOT NULL; ); I want to change the locationExpect column to: create table test( locationExpect varchar(120); ); How can it be done quickly?...

What does "res.render" do, and what does the html file look like?

What does res.render do, and what does the html file look like? My end goal is to load arbitrary comma-separated-values from a text file into an html file (for example). I was only able to deduce that a view was the html file, and callback give...

Android background music service

I am developing an entertainment app in android. I want to play background music, and I want to use service for that. App have 3 activities and music must be played across all activities. Also, when activity is paused, music must PAUSE and stopped wh...

How do I handle too long index names in a Ruby on Rails ActiveRecord migration?

I am trying to add an unique index that gets created from the foreign keys of four associated tables: add_index :studies, ["user_id", "university_id", "subject_name_id", "subject_type_id"], :unique => true The database’s limitation for th...

MVC4 HTTP Error 403.14 - Forbidden

I have build a .net4.5 ASP.NET MVC4 web app which works fine locally (IIS Express & dev server) but once i deploy it to my web server it throws the 403 error. I have installed .Net 4.5RC on the server and even tried the aspnet_regiis -i bit that...

Android ADB device offline, can't issue commands

I can't connect to my device anymore using ADB through the command line or in Eclipse. Running the command adb devices returns the device name, but it says it's offline. Things I've tried. Toggled Android debugging mode Reinstalled the Google ...

.gitignore file for java eclipse project

I have java project that uses the Eclipse IDE. The Eclipse workspace is pointing to this directory: /home/srvimgprd/BUSPROJ/code_development/dime/executables/clientcode/java_axis/Eclipse I have placed a .gitignore file in the workspace directory ...

.mp4 file not playing in chrome

I want to show a video on my website. I have created a .mp4 file and using the HTML5 video tag to add it to the html. The problem is that it is not being displayed in chrome. I would also like to know how I can replay it again and again....

How to insert a picture into Excel at a specified cell position with VBA

I'm adding ".jpg" files to my Excel sheet with the code below : 'Add picture to excel xlApp.Cells(i, 20).Select xlApp.ActiveSheet.Pictures.Insert(picPath).Select 'Calgulate new picture size With xlApp.Selection.ShapeRange .LockAspectRatio = msoT...

How to connect to SQL Server from another computer?

I want to connect from home using SQL Server 2005 to another PC. I had a look on the msd...but before connecting it says I should connect to another computer using the computer management and it didn't work out....I can only connect to computers fro...

ln (Natural Log) in Python

In this assignment I have completed all the problems except this one. I have to create a python script to solve an equation (screenshot). Unfortunately, in my research all over the internet I cannot figure out how in the world to either convert ln t...

How can I use break or continue within for loop in Twig template?

I try to use a simple loop, in my real code this loop is more complex, and I need to break this iteration like: {% for post in posts %} {% if post.id == 10 %} {# break #} {% endif %} <h2>{{ post.heading }}</h2> {% end...

Return index of highest value in an array

From an array that looks something like the following, how can I get the index of the highest value in the array. For the array below, the desired result would be '11'. Array ( [11] => 14 [10] => 9 [12] => 7 [13] => 7 ...

'printf' with leading zeros in C

I have a floating point number such as 4917.24. I'd like to print it to always have five characters before the decimal point, with leading zeros, and then three digits after the decimal place. I tried printf("%05.3f", n) on the embedded sys...

Remove duplicates from a dataframe in PySpark

I'm messing around with dataframes in pyspark 1.4 locally and am having issues getting the dropDuplicates method to work. It keeps returning the error: "AttributeError: 'list' object has no attribute 'dropDuplicates'" Not quite sure why a...

Instantiating a generic type

I'm trying to convert an existing class to use generics, and am getting stumped while converting the constructors. The original class was a POJO that contained logic for moving from one room to another in a text-based console game. Literally, it was...

CSS technique for a horizontal line with words in the middle

I'm trying to make a horizontal rule with some text in the middle. For example: ----------------------------------- my title here ----------------------------- Is there a way to do that in CSS? Without all the "-" dashes obviously....

Read Session Id using Javascript

Is it by any means possible to read the browser session id using javascript?...

Is there a "null coalescing" operator in JavaScript?

Is there a null coalescing operator in Javascript? For example, in C#, I can do this: String someString = null; var whatIWant = someString ?? "Cookies!"; The best approximation I can figure out for Javascript is using the conditional operator: v...

File Upload without Form

Without using any forms whatsoever, can I just send a file/files from <input type="file"> to 'upload.php' using POST method using jQuery. The input tag is not inside any form tag. It stands individually. So I don't want to use jQuery plugins li...

Can I call jQuery's click() to follow an <a> link if I haven't bound an event handler to it with bind or click already?

I have a timer in my JavaScript which needs to emulate clicking a link to go to another page once the time elapses. To do this I'm using jQuery's click() function. I have used $().trigger() and window.location also, and I can make it work as intended...

How do you give iframe 100% height

I'm trying <iframe height="100%" ...> but it still doesn't resize it. When i try the height in pixles it works. edit: 100% seems to be working on IE but not firefox...

jQuery: get parent tr for selected radio button

I have the following HTML: <table id="MwDataList" class="data" width="100%" cellspacing="10px"> .... <td class="centerText" style="height: 56px;"> <input id="selectRadioButton" type="radio" name="selectRadioGroup">...

How do I bind a List<CustomObject> to a WPF DataGrid?

I'm new to WPF and want to do some basic databinding. I have a List of a CustomObject and want to bind it to a DataGrid. MainWindow.xaml.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; usi...

How to set background color of a View

I'm trying to set the background color of a View (in this case a Button). I use this code: // set the background to green v.setBackgroundColor(0x0000FF00 ); v.invalidate(); It causes the Button to disappear from the screen. What am I doing wron...

How do I ALTER a PostgreSQL table and make a column unique?

I have a table in PostgreSQL where the schema looks like this: CREATE TABLE "foo_table" ( "id" serial NOT NULL PRIMARY KEY, "permalink" varchar(200) NOT NULL, "text" varchar(512) NOT NULL, "timestamp" timestamp with time zone NOT NUL...

System.loadLibrary(...) couldn't find native library in my case

I want to use a existing native library from another Android project, so I just copied the NDK built library (libcalculate.so) to my new Android project. In my new Android project I created a folder libs/armeabi/ and put libcalculate.so there. There ...

Regex to test if string begins with http:// or https://

I'm trying to set a regexp which will check the start of a string, and if it contains either http:// or https:// it should match it. How can I do that? I'm trying the following which isn't working: ^[(http)(https)]:// ...

How to remove illegal characters from path and filenames?

I need a robust and simple way to remove illegal path and file characters from a simple string. I've used the below code but it doesn't seem to do anything, what am I missing? using System; using System.IO; namespace ConsoleApplication1 { class...

Clearing Magento Log Data

I have a question regarding clearing of the log data in Magento. I have more than 2.3GB of data in Magento 1.4.1, and now I want to optimize the database, because it's too slow due to the size of the data. I checked the log info (URL,Visitors) and i...

Can I nest a <button> element inside an <a> using HTML5?

I am doing the following: <a href="www.stackoverflow.com"> <button disabled="disabled" >ABC</button> </a> This works good but I get a HTML5 validation error that says "Element 'button' must not be nested within eleme...

How to measure time taken between lines of code in python?

So in Java, we can do How to measure time taken by a function to execute But how is it done in python? To measure the time start and end time between lines of codes? Something that does this: import some_time_library starttime = some_time_library....

How to make a WPF window be on top of all other windows of my app (not system wide)?

I want my window to be on top of all other windows in my application only. If I set the TopMost property of a window, it becomes on top of all windows of all applications and I don't want that....

Java ByteBuffer to String

Is this a correct approach to convert ByteBuffer to String in this way, String k = "abcd"; ByteBuffer b = ByteBuffer.wrap(k.getBytes()); String v = new String(b.array()); if(k.equals(v)) System.out.println("it worked"); else System.out.prin...

Print the contents of a DIV

Whats the best way to print the contents of a DIV?...

Visual Studio 2015 is very slow

I just finished the installation and the whole IDE is super slow. It seems like it's making some kind of heavy CPU calls in the background where the whole IDE literally freezes and becomes unresponsive for about 2-3 seconds. I was not having this is...

How do I get the Date & Time (VBS)

How do I get the current date and time using VBS (for Windows. I'm not looking for VBScript for ASP/ASPX or webpages)....

How can I draw vertical text with CSS cross-browser?

I want to rotate a single word of text by 90 degrees, with cross-browser (>= IE6, >= Firefox 2, any version of Chrome, Safari, or Opera) support. How can this be done?...

How might I convert a double to the nearest integer value?

How do you convert a double into the nearest int?...

How to make <div> fill <td> height

I've looked through several posts on StackOverflow, but haven't been able to find an answer to this rather simple question. I have an HTML construct like this: <table> <tr> <td class="thatSetsABackground"> <div clas...

JPA - Persisting a One to Many relationship

Maybe this is a stupid question but it's bugging me. I have a bi-directional one to many relationship of Employee to Vehicles. When I persist an Employee in the database for the first time (i.e. it has no assigned ID) I also want its associated Vehi...

How do I get the scroll position of a document?

How to get the scroll position value of a document?...

How to Deserialize JSON data?

I am new to working with JSON data. I am reading data from a web service. The query data sent back is the following: [["B02001_001E","NAME","state"], ["4712651","Alabama","01"], ["691189","Alaska","02"], ["6246816","Arizona","04"], ["18511620",...

IndexError: list index out of range and python

I'm telling my program to print out line 53 of an output. Is this error telling me that there aren't that many lines and therefore can not print it out?...

jquery Ajax call - data parameters are not being passed to MVC Controller action

I'm passing two string parameters from a jQuery ajax call to an MVC controller method, expecting a json response back. I can see that the parameters are populated on the client side but the matching parameters on the server side are null. Here is th...

How to output loop.counter in python jinja template?

I want to be able to output the current loop iteration to my template. According to the docs: http://wsgiarea.pocoo.org/jinja/docs/loops.html, there is a loop.counter variable that I am trying to use. I have the following: <ul> {% for user ...

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

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

Editable 'Select' element

I would like to have a select element in the form but besides the options in the dropdown, it would be useful to be able to edit it and add new option but not with another input text, I need all in once. Is it possible? ...

How to loop backwards in python?

I'm talking about doing something like: for(i=n; i>=1; --i) { //do something with i } I can think of some ways to do so in python (creating a list of range(1,n+1) and reverse it, using while and --i, ...) but I wondered if there's a more ele...

What exactly is Python's file.flush() doing?

I found this in the Python documentation for File Objects: flush() does not necessarily write the file’s data to disk. Use flush() followed by os.fsync() to ensure this behavior. So my question is: what exactly is Python's flush doing? I thou...

How to remove specific value from array using jQuery

I have an array that looks like this: var y = [1, 2, 3]; I would like to remove 2 from array y. How can I remove a particular value from an array using jQuery? I have tried pop() but that always removes the last element....

How can I sharpen an image in OpenCV?

How can I sharpen an image using OpenCV? There are many ways of smoothing or blurring but none that I could see of sharpening....

Can I connect to SQL Server using Windows Authentication from Java EE webapp?

I am currently investigating how to make a connection to a SQL Server database from my Java EE web application using Windows Authentication instead of SQL Server authentication. I am running this app off of Tomcat 6.0, and am utilizing the Microsoft ...

Google Maps API warning: NoApiKeys

I've been using Google Maps API v3 for some time without an API key, and it worked well. It still works, but I get a warning in the console: Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-me...

remove kernel on jupyter notebook

How can I remove a kernel from jupyter notebook? I have R kernel on my jupyter notebook. Recently kernel always dies right after I open a new notebook....

RegEx: Grabbing values between quotation marks

I have a value like this: "Foo Bar" "Another Value" something else What regex will return the values enclosed in the quotation marks (e.g. Foo Bar and Another Value)?...

Arduino error: does not name a type?

I have written a library, but have problem with error does not name a type. I've tryed everything, searched for couple of hours and no luck. Library is placed in the "libraries" folder of the arduino sketch folder. Please help!!! I am using OSX, but ...

Is there any simple way to convert .xls file to .csv file? (Excel)

Is there any simple way to convert .xls file to .csv file ? (Excel) in C# code ? i mean to take an existing .xls file and convert them to .csv file Thanks in advance...

How can I make sticky headers in RecyclerView? (Without external lib)

I want to fix my header views in the top of the screen like in the image below and without using external libraries. In my case, I don't want to do it alphabetically. I have two different types of views (Header and normal). I only want to fix to t...

Compilation error: stray ‘\302’ in program etc

I am having problem compiling the followed exploit code: http://downloads.securityfocus.com/vulnerabilities/exploits/59846-1.c I am using: "gcc file.c" and "gcc -O2 file.c" but both of them gets the following errors: sorbolinux-exec.c: In functio...

How to find specific lines in a table using Selenium?

Here is an example code: <div id="productOrderContainer"> <table class="table gradient myPage"> So this table being in productOrderContainer has several columns and depending on several things will have several rows which all have seve...

What is the best java image processing library/approach?

I am using both the JAI media apis and ImageMagick? ImageMagick has some scalability issues and the JNI based JMagick isn't attractive either. JAI has poor quality results when doing resizing operations compared to ImageMagick. Does anyone know of ...

Save file to specific folder with curl command

In a shell script, I want to download a file from some URL and save it to a specific folder. What is the specific CLI flag I should use to download files to a specific folder with the curl command, or how else do I get that result?...

Windows service on Local Computer started and then stopped error

Usually, I get this error: (The "service name" service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other service or programs) when there's something wrong with my code, like non-existing driv...

How to search in a List of Java object

I have a List of object and the list is very big. The object is class Sample { String value1; String value2; String value3; String value4; String value5; } Now I have to search for a specific value of an object in the list. S...

How to stop a looping thread in Python?

What's the proper way to tell a looping thread to stop looping? I have a fairly simple program that pings a specified host in a separate threading.Thread class. In this class it sleeps 60 seconds, the runs again until the application quits. I'd li...

Reading a binary input stream into a single byte array in Java

The documentation says that one should not use available() method to determine the size of an InputStream. How can I read the whole content of an InputStream into a byte array? InputStream in; //assuming already present byte[] data = new byte[in.ava...

jquery live hover

I'm using the following jquery code to show a contextual delete button only for table rows we are hovering with our mouse. This works but not for rows that have been added with js/ajax on the fly... Is there a way to make this work with live events?...

Matplotlib tight_layout() doesn't take into account figure suptitle

If I add a subtitle to my matplotlib figure it gets overlaid by the subplot's titles. Does anybody know how to easily take care of that? I tried the tight_layout() function, but it only makes things worse. Example: import numpy as np import matplot...

How to programmatically clear application data

I am developing automated tests for an android application (using Robotium). In order to ensure the consistency and reliability of tests, I would like to start each test with clean state (of the application under test). In order to do so, I need to c...

Error when checking Java version: could not find java.dll

why do I get this? How can I fix it? C:\Users\ash>java version Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.7.0_01', but '1.7' is required. Error: could not find java.dll Error: Could not find Java...

How to import JsonConvert in C# application?

I created a C# library project. The project has this line in one class: JsonConvert.SerializeObject(objectList); I'm getting error saying the name JsonConvert doesn't exist in the current context. To fix that, I added System.ServiceModel....

What is HTTP "Host" header?

Given that the TCP connection is already established when the HTTP request is sent, the IP address and port are implicitly known -- a TCP connection is an IP + Port. So, why do we need the Host header? Is this only needed for the case where there ar...

Printing all variables value from a class

I have a class with information about a Person that looks something like this: public class Contact { private String name; private String location; private String address; private String email; private String phone; private S...

gem install: Failed to build gem native extension (can't find header files)

I am using Fedora 14 and I have MySQL and MySQL server 5.1.42 installed and running. Now I tried to do this as root user: gem install mysql But I get this error: Building native extensions. This could take a while... ERROR: Error installing mys...

Const in JavaScript: when to use it and is it necessary?

I've recently come across the const keyword in JavaScript. From what I can tell, it is used to create immutable variables, and I've tested to ensure that it cannot be redefined (in Node.js): const x = 'const'; const x = 'not-const'; // Will give an...

AngularJS : ng-click not working

I am new in AngularJs, ng-click is not working as expected. I searched on the internet , Follow the tutorial , (that was working) - but this is not working!!! My Code: <div class="row" ng:repeat="follower in myform.all_followers | partition:2"&...

No Title Bar Android Theme

In my application I want to use the Theme.NoTitleBar, but on the other hand I also don't want to loose the internal Theme of the Android OS.. I searched on the net and Found the following answer.. I have modified my styles.xml and added the following...

Uninstall mongoDB from ubuntu

I have installed MongoDB 3.0.1 following the commands in Install MongoDB Community Edition on Ubuntu on my ubuntu 14.04 64 bit system and I installed Robomongo interface to use that. When I try to connect MongoDB using Robomongo I get an error that...

Max length for client ip address

Possible Duplicate: Maximum length of the textual representation of an IPv6 address? What would you recommend as the maximum size for a database column storing client ip addresses? I have it set to 16 right now, but could I get an ip addr...

Java logical operator short-circuiting

Which set is short-circuiting, and what exactly does it mean that the complex conditional expression is short-circuiting? public static void main(String[] args) { int x, y, z; x = 10; y = 20; z = 30; // T T // T F // F T // F F ...

iPhone 6 and 6 Plus Media Queries

Does anyone know specific screen sizes to target media queries for iPhone 6 and 6 Plus? Also, the icon sizes and splash screens?...

Android Saving created bitmap to directory on sd card

I created a bitmap and now i want to save that bitmap to a directory somewhere. Can anyone show me how this is done. Thanks FileInputStream in; BufferedInputStream buf; try { in = new FileInputStream("/mnt/sdca...

Calculating moving average

I'm trying to use R to calculate the moving average over a series of values in a matrix. The normal R mailing list search hasn't been very helpful though. There doesn't seem to be a built-in function in R will allow me to calculate moving averages. D...

Unzipping files in Python

I read through the zipfile documentation, but couldn't understand how to unzip a file, only how to zip a file. How do I unzip all the contents of a zip file into the same directory?...

Dealing with commas in a CSV file

I am looking for suggestions on how to handle a csv file that is being created, then uploaded by our customers, and that may have a comma in a value, like a company name. Some of the ideas we are looking at are: quoted Identifiers (value "," values ...

PHP post_max_size overrides upload_max_filesize

In my site host, I have seen (via phpinfo) that post_max_size = 8Mb upload_max_filesize = 16Mb This led me to think that I should be able to upload as file as big as 16Mb. However, when I do this through a post method (as normal), post_max_size ...

"Cannot create an instance of OLE DB provider" error as Windows Authentication user

I am trying to run openrowset from MS SQL Server on an Oracle server. When i execute the following command: select * from OPENROWSET('OraOLEDB.Oracle','srv';'user';'pass', 'select * from table') the following error occurs Msg 7302, Level 16, St...

How to split a large text file into smaller files with equal number of lines?

I've got a large (by number of lines) plain text file that I'd like to split into smaller files, also by number of lines. So if my file has around 2M lines, I'd like to split it up into 10 files that contain 200k lines, or 100 files that contain 20k...

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

UnicodeEncodeError: 'latin-1' codec can't encode character

What could be causing this error when I try to insert a foreign character into the database? >>UnicodeEncodeError: 'latin-1' codec can't encode character u'\u201c' in position 0: ordinal not in range(256) And how do I resolve it? Thanks!...

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

JavaScript Adding an ID attribute to another created Element

I have some code here that will do the following. The code creates an element "p" then I append it to a "div" in the HTML. I would like that "p" I just created have an unique identifier (ID) and set the name of the ID. So later on when the user wants...

How add "or" in switch statements?

This is what I want to do: switch(myvar) { case: 2 or 5: ... break; case: 7 or 12: ... break; ... } I tried with "case: 2 || 5" ,but it didn't work. The purpose is to not write same code for different values....

Laravel Eloquent get results grouped by days

I currently have a table of page_views that records one row for each time a visitor accesses a page, recording the user's ip/id and the id of the page itself. I should add that the created_at column is of type: timestamp, so it includes the hours/min...

How to create folder with PHP code?

Can we create folder with PHP code? I want that whenever a new user create his new account his folder automatically creates and a PHP file also created.Is this possible?...

What is external linkage and internal linkage?

I want to understand the external linkage and internal linkage and their difference. I also want to know the meaning of const variables internally link by default unless otherwise declared as extern. ...

Explicitly set column value to null SQL Developer

I am new to Oracle DB and I am using Oracle SQL Developer (Ver 3.0.02) to query the DB. I wanted to explicitly set one column to null? How do I do that in the SQL Developer GUI? Previously in MSSQL, clicking CTRL+0 will explicitly set the value to ...

Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference

Given the following examples, why is outerScopeVar undefined in all cases? var outerScopeVar; var img = document.createElement('img'); img.onload = function() { outerScopeVar = this.width; }; img.src = 'lolcat.png'; alert(outerScopeVar); va...

Node.js spawn child process and get terminal output live

I have a script that outputs 'hi', sleeps for a second, outputs 'hi', sleeps for 1 second, and so on and so forth. Now I thought I would be able to tackle this problem with this model. var spawn = require('child_process').spawn, temp = spawn('PAT...

Generating a random & unique 8 character string using MySQL

I'm working on a game which involves vehicles at some point. I have a MySQL table named "vehicles" containing the data about the vehicles, including the column "plate" which stores the License Plates for the vehicles. Now here comes the part I'm hav...

Android - How to regenerate R class?

Possible Duplicate: Developing for Android in Eclipse: R.java not generating I have imported a project into my Eclipse IDE, but it's giving me an error since R file is not generated automatically. How can I edit the R file so that it matc...

Show hide fragment in android

I am developing application which contains 2 fragments and i want to show hide according to my need. Following code has simple example of my problem. This simple Fragmentactivity contains 1 button and one listfragment. This simple example works fla...

How can I make robocopy silent in the command line except for progress?

I'm using robocopy to do backups with a PowerShell script, and it's pretty awesome, except that I'd like it to only show the progress percentage while it copies and not all of the other information. The other information clutters the command window,...

Simple regular expression for a decimal with a precision of 2

What is the regular expression for a decimal with a precision of 2? Valid examples: 123.12 2 56754 92929292929292.12 0.21 3.1 Invalid examples: 12.1232 2.23332 e666.76 The decimal point may be optional, and integers may also be included....

How do I get the real .height() of a overflow: hidden or overflow: scroll div?

I have a question regarding how to get a div height. I'm aware of .height() and innerHeight(), but none of them does the job for me in this case. The thing is that in this case I have a div that is overflown width a overflow: scroll and the div has a...

Simplest way to read json from a URL in java

This might be a dumb question but what is the simplest way to read and parse JSON from URL in Java? In Groovy, it's a matter of few lines of code. Java examples that I find are ridiculously long (and have huge exception handling block). All I want ...

drop down list value in asp.net

I want to add a value to the drop down list that cannot be selected, like a title. Ex: I have a month drop down list. The very first item should be "select month" this should not be selected. And next is from January to december. How can I do that? ...

Calling a Fragment method from a parent Activity

I see in the Android Fragments Dev Guide that an "activity can call methods in a fragment by acquiring a reference to the Fragment from FragmentManager, using findFragmentById() or findFragmentByTag()." The example that follows shows how to get a fr...

Setting table row height

I have this code: <table class="topics" > <tr> <td style="white-space: nowrap; padding: 0 5px 0 0; color:#3A5572; font-weight: bold;">Test</td> <td style="padding: 0 4px 0 0;">1.0</td> ...

JavaScript - onClick to get the ID of the clicked button

How do find the id of the button which is being clicked? <button id="1" onClick="reply_click()"></button> <button id="2" onClick="reply_click()"></button> <button id="3" onClick="reply_click()"></button> function...

How to horizontally center an element

How can I horizontally center a <div> within another <div> using CSS? <div id="outer"> <div id="inner">Foo foo</div> </div> ...

Correct redirect URI for Google API and OAuth 2.0

I am making an application with the Google Maps API. I want to be able to have one person on a computer, watch what another person has edited to a map. I am thinking of passing information of the map to a Google Fusion Table. The other person will be...

How to properly stop the Thread in Java?

I need a solution to properly stop the thread in Java. I have IndexProcessorclass which implements the Runnable interface: public class IndexProcessor implements Runnable { private static final Logger LOGGER = LoggerFactory.getLogger(IndexProc...

Get battery level and state in Android

How can I get battery level and state (plugged in, discharging, charging, etc)? I researched the developer docs and I found a BatteryManager class. But it doesn't contain any methods, just constants. How do I even use it?...

Javascript onclick hide div

I want to hide this warning div using javascript inside it. I'm i getting the javascript right? I want to hide/close the div when i click on the close icon (images/close_icon.gif) <div> <strong>Warning:</strong> These are new ...

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

Laravel eloquent update record without loading from database

I'm quite new to laravel and I'm trying to update a record from form's input. However I see that to update the record, first you need to fetch the record from database. Isn't is possible to something like to update a record (primary key is set): $p...

How can I save an image with PIL?

I have just done some image processing using the Python image library (PIL) using a post I found earlier to perform fourier transforms of images and I can't get the save function to work. The whole code works fine but it just wont save the resulting ...

"Failed to install the following Android SDK packages as some licences have not been accepted" error

I am getting this error in jitpack, I've tried everything on the internet. Below is my error Failed to install the following Android SDK packages as some licences have not been accepted. platforms;android-26 Android SDK Platform 26 build-...

how to convert object to string in java

I have a function that returns map value (String) as a generic Object. How do I convert it back to string. I tried toString() but all i get is end[Ljava.lang.String;@ff2413 public Object getParameterValue(String key) { Iterator iterator=params.e...

What is Unicode, UTF-8, UTF-16?

What's the basis for Unicode and why the need for UTF-8 or UTF-16? I have researched this on Google and searched here as well but it's not clear to me. In VSS when doing a file comparison, sometimes there is a message saying the two files have diff...

Changing the background color of a drop down list transparent in html

I'm trying to change the background color of a drop down list in HTML to transparent. HTML <select id="nname"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes"&g...

In bootstrap how to add borders to rows without adding up?

I'm using bootstrap version 3.0.1 to make a grid and when I add a border to the rows of the grid I can see that the rows that are together add up there borders, I get a thicker border. This is my code: <!DOCTYPE html> <html> <head&...

Select parent element of known element in Selenium

I have a certain element that I can select with Selenium 1. Unfortunately I need to click the parent element to get the desired behaviour. The element I can easily locate has attribute unselectable, making it dead for clicking. How do I navigate upw...

Modify property value of the objects in list using Java 8 streams

I have a list of Fruit objects in ArrayList and I want to modify fruitName to its plural name. Refer the example: @Data @AllArgsConstructor @ToString class Fruit { long id; String name; String country; } List<Fruit> fruits = Lis...

Can there be an apostrophe in an email address?

Possible Duplicate: What characters are allowed in email address? I have an email address with an apostrophe in it and am wondering if that is valid?...

How can I override Bootstrap CSS styles?

I need to modify bootstrap.css to fit my website. I feel it's better to create a separate custom.css file instead of modifying bootstrap.css directly, one reason being that should bootstrap.css get an update, I'll suffer trying to re-include all my m...

AWS S3: The bucket you are attempting to access must be addressed using the specified endpoint

I am trying to delete uploaded image files with the AWS-SDK-Core Ruby Gem. I have the following code: require 'aws-sdk-core' def pull_picture(picture) Aws.config = { :access_key_id => ENV["AWS_ACCESS_KEY_ID"], :secret_access...

scrollbars in JTextArea

How do I add scrollbars to a JTextArea?...

Python FileNotFound

I am fairly new to python. I am trying to make a script that will read sudoku solutions and determent if they are correct or not. Things I need: 1] Prompt the user to enter a file/file path which includes the sudoku numbers. Its a .txt file of 9 r...

Add colorbar to existing axis

I'm making some interactive plots and I would like to add a colorbar legend. I don't want the colorbar to be in its own axes, so I want to add it to the existing axes. I'm having difficulties doing this, as most of the example code I have found creat...

Alter SQL table - allow NULL column value

Initially, the table "MyTable" has been defined in the following way: CREATE TABLE IF NOT EXISTS `MyTable` ( `Col1` smallint(6) NOT NULL AUTO_INCREMENT, `Col2` smallint(6) DEFAULT NULL, `Col3` varchar(20) NOT NULL, ); How to update it in suc...

Synchronous request in Node.js

If I need to call 3 http API in sequential order, what would be a better alternative to the following code: http.get({ host: 'www.example.com', path: '/api_1.php' }, function(res) { res.on('data', function(d) { http.get({ host: 'www.example...

Why can't I inherit static classes?

I have several classes that do not really need any state. From the organizational point of view, I would like to put them into hierarchy. But it seems I can't declare inheritance for static classes. Something like that: public static class Base { ...

How to create a static library with g++?

Can someone please tell me how to create a static library from a .cpp and a .hpp file? Do I need to create the .o and the .a? I would also like to know how can I compile a static library in and use it in other .cpp code. I have header.cpp, header.hpp...

How to set the allowed url length for a nginx request (error code: 414, uri too large)

I am using Nginx in front of 10 mongrels. When I make a request with size larger then 2900 I get back an: error code 414: uri too large Does anyone know the setting in the nginx configuration file which determines the allowed uri length ?...

How to stop asynctask thread in android?

I want to stop a AsyncTask thread from another AsyncTask thread. I have tried like new AsyncTask.cancel(true) to stop the background process but it didn't stop. Could any one help me on this?...

CSS Inset Borders

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

PHP - Notice: Undefined index:

Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” I am trying to do a registration form that registers a user in a database (MySQL). The code is supposed to register: Name Surname Username Pass...

Visual Studio move project to a different folder

How do I move a project to a different folder in Visual Studio? I am used to this structure in my projects. -- app ---- Project.Something ---- Project.SomethingElse I want to rename the whole namespace SomethingElse to SomethingNew, what's the bes...

Distinct by property of class with LINQ

I have a collection: List<Car> cars = new List<Car>(); Cars are uniquely identified by their property CarCode. I have three cars in the collection, and two with identical CarCodes. How can I use LINQ to convert this collection to Car...

Process.start: how to get the output?

I would like to run an external command line program from my Mono/.NET app. For example, I would like to run mencoder. Is it possible: To get the command line shell output, and write it on my text box? To get the numerical value to show a progress...

ES6 class variable alternatives

Currently in ES5 many of us are using the following pattern in frameworks to create classes and class variables, which is comfy: // ES 5 FrameWork.Class({ variable: 'string', variable2: true, init: function(){ }, addItem: f...

How do I run a command on an already existing Docker container?

I created a container with -d so it's not interactive. docker run -d shykes/pybuilder bin/bash I see that the container has exited: CONTAINER ID IMAGE COMMAND CREATED STATUS ...

refresh both the External data source and pivot tables together within a time schedule

In my last post Auto refresh pivottables data in excel on first run, i found that on my first execution the query from the External data source is refreshed and takes approximately 1 min to execute. and in my second run, the pivot tables are updated...

How to display all elements in an arraylist?

Say I have a car class with attributes make and registration, and i create an ArrayList to store them. How do I display all the elements in the ArrayList? I have this code right now: public Car getAll() { for(int i = 0; i < cars.size(); i++...

Bootstrap: change background color

I'm new to learning Bootstrap and I'm looking have 2 col-md-6 divs next to one another having one background-color blue and the other white. How can I change one background color and not both? I'm trying to get a look similar to below the full width...

Does swift have a trim method on String?

Does swift have a trim method on String? For example: let result = " abc ".trim() // result == "abc" ...

Why can't I have "public static const string S = "stuff"; in my Class?

When trying to compile my class I get an error: The constant 'NamespaceName.ClassName.CONST_NAME' cannot be marked static. at the line: public static const string CONST_NAME = "blah"; I could do this all of the time in Java. What am I doi...

PHP max_input_vars

I'm getting a max_input_vars error message. I understand there's a php.ini setting that can change this starting with version 5.3.9 however, I'm running version 5.1.6. When I view the configuration information for my 5.1.6 server it shows max_inp...

Why use argparse rather than optparse?

I noticed that the Python 2.7 documentation includes yet another command-line parsing module. In addition to getopt and optparse we now have argparse. Why has yet another command-line parsing module been created? Why should I use it instead of opt...

How to set a maximum execution time for a mysql query?

I would like to set a maximum execution time for sql queries like set_time_limit() in php. How can I do ?...

How can I write text on a HTML5 canvas element?

Is it possible to write text on HTML5 canvas? ...

All shards failed

I was working on elastic search and it was working perfectly. Today I just restarted my remote server (Ubuntu). Now I am searching in my indexes, it is giving me this error. {"error":"SearchPhaseExecutionException[Failed to execute phase [query_fetc...

Zoom to fit all markers in Mapbox or Leaflet

How do I set view to see all markers on map in Mapbox or Leaflet? Like Google Maps API does with bounds? E.g: var latlngbounds = new google.maps.LatLngBounds(); for (var i = 0; i < latlng.length; i++) { latlngbounds.extend(latlng[i]); } map.fi...

How can I make a SQL temp table with primary key and auto-incrementing field?

What am I missing here? I'm trying to get the ID field to be the primary key and auto increment so that I don't need to insert it explicitly. CREATE TABLE #tmp ( ID INT IDENTITY(1, 1) , AssignedTo NVARCHAR(100), AltBusinessSeverity NVARCHAR(100), De...

How do I analyze a program's core dump file with GDB when it has command-line parameters?

My program operates like this: exe -p param1 -i param2 -o param3 It crashed and generated a core dump file, core.pid. I want to analyze the core dump file by gdb ./exe -p param1 -i param2 -o param3 core.pid But GDB recognizes the parameters of...

Define global variable with webpack

Is it possible to define a global variable with webpack to result something like this: var myvar = {}; All of the examples I saw were using external file require("imports?$=jquery!./file.js")...

Force the origin to start at 0

How can I set the origin / interception of the y-axis and x-axis in ggplot2? The line of the x-axis should be exactly at y=Z. With Z=0 or another given value....

Swift UIView background color opacity

I have a UIView with a UILabel in it. I want the UIView to have white background color, but with an opacity of 50%. The problem whith setting view.alpha = 0.5 is that the label will have an opacity of 50% as well, so I figured out that it maybe would...

Export HTML table to pdf using jspdf

I need to export the HTML table to pdf file using jspdf. I tried the below code but it displays the blank/empty output in pdf file. Any suggestions or sample code for this would be helpful. ` <script type="text/javascript"> function demo1(...

Is it possible to add dynamically named properties to JavaScript object?

In JavaScript, I've created an object like so: var data = { 'PropertyA': 1, 'PropertyB': 2, 'PropertyC': 3 }; Is it possible to add further properties to this object after its initial creation if the properties name is not determined u...

Extracting text from a PDF file using PDFMiner in python?

I am looking for documentation or examples on how to extract text from a PDF file using PDFMiner with Python. It looks like PDFMiner updated their API and all the relevant examples I have found contain outdated code(classes and methods have changed)...

Converting a string to int in Groovy

I have a String that represents an integer value and would like to convert it to an int. Is there a groovy equivalent of Java's Integer.parseInt(String)?...

Setting CSS pseudo-class rules from JavaScript

I'm looking for a way to change the CSS rules for pseudo-class selectors (such as :link, :hover, etc.) from JavaScript. So an analogue of the CSS code: a:hover { color: red } in JS. I couldn't find the answer anywhere else; if anyone knows that thi...

How to get just one file from another branch

I am using git and working on master branch. This branch has a file called app.js. I have an experiment branch in which I made a bunch of changes and tons of commits. Now I want to bring all the changes done only to app.js from experiment to master ...

How to use python numpy.savetxt to write strings and float number to an ASCII file?

I have a set of lists that contain both strings and float numbers, such as: import numpy as num NAMES = num.array(['NAME_1', 'NAME_2', 'NAME_3']) FLOATS = num.array([ 0.5 , 0.2 , 0.3 ]) DAT = num.column_stack((NAMES, FLOATS)) I want...

Unprotect workbook without password

I have a popular VBA code to unprotect a worksheet, but I am still running into the issue that the Workbook is protected. Sub PasswordBreaker() 'Breaks worksheet password protection. Dim i As Integer, j As Integer, k As Integer Dim l As In...

data.frame Group By column

I have a data frame DF. Say DF is: A B 1 1 2 2 1 3 3 2 3 4 3 5 5 3 6 Now I want to combine together the rows by the column A and to have the sum of the column B. For example: A B 1 1 5 2 2 3 3 3 11 I am doing this currently using an SQL ...

The builds tools for v120 (Platform Toolset = 'v120') cannot be found

Using visual studio 2012 on windows 8 x64 aparantly this is caused by msbuild being moved into .net but I havn't seen how to fix it yet. 4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(44,5): error MSB8020:...

Escape double quote in grep

I wanted to do grep for keywords with double quotes inside. To give a simple example: echo "member":"time" | grep -e "member\"" That does not match. How can I fix it?...

Converting XDocument to XmlDocument and vice versa

It's a very simple problem that I have. I use XDocument to generate an XML file. I then want to return it as a XmlDocument class. And I have an XmlDocument variable which I need to convert back to XDocument to append more nodes. So, what is the most...

A simple jQuery form validation script

I made a simple validation form using jQuery. It's working alright. The thing is I'm not satisfied with my code. Is there another way around to write my code with the same output result? $(document).ready(function(){ $('.submit').click(function(){ ...

How to retrieve SQL result column value using column name in Python?

Is there a way to retrieve SQL result column value using column name instead of column index in Python? I'm using Python 3 with mySQL. The syntax I'm looking for is pretty much like the Java construct: Object id = rs.get("CUSTOMER_ID"); I've a ta...

Compare objects in Angular

Is it possible to do a "deep" comparison of two object in Angular? What I would like to do is compare each key/value pair. For example: Object 1 { key1: "value1", key2: "value2", key3: "value3" } Object 2 { key1: "value1", key2: "...

CSS3 background image transition

I'm trying to make a "fade-in fade-out" effect using the CSS transition. But I can't get this to work with the background image... The CSS: .title a { display: block; width: 340px; height: 338px; color: black; background: transp...

Can I use VARCHAR as the PRIMARY KEY?

I have a table for storing coupons/discounts, and I want to use the coupon_code column as the primary key, which is a VARCHAR. My rationale is that, each coupon will have a unique code, and the only commands I will be running are SELECT ... FROM ......

Location of the android sdk has not been setup in the preferences in mac os?

I am installing the Android SDK along with Eclipse in mac os. Whenever I try to start a new project development I get an error location of the android sdk has not been setup in the preferences How do I resolve this problem?...

Why am I getting this redefinition of class error?

Apologies for the code dump: gameObject.cpp: #include "gameObject.h" class gameObject { private: int x; int y; public: gameObject() { x = 0; y = 0; } gameObject(int inx, int iny) { x = inx; ...

How to pass data using NotificationCenter in swift 3.0 and NSNotificationCenter in swift 2.0?

I'm implementing socket.io in my swift ios app. Currently on several panels I'm listening to the server and wait for incoming messages. I'm doing so by calling the getChatMessage function in each panel: func getChatMessage(){ SocketIOManager.s...

Google API authentication: Not valid origin for the client

When making an auth request to the Google API (gapi), it's returning false on the checkOrigin. I have removed any client id's or anything that would link directly to my account and replaced it with a regex indicating what the data is for reference. ...

Build Step Progress Bar (css and jquery)

You've seen iterations of this type of progress bar on sites like paypal. How does one go about setting this up using CSS and jquery? I have 4 pages and each page is a step... so 4 steps....

How to view or edit localStorage

I created a Chrome extension and am using localStorage for storing data. I am accessing localStorage through "background_page". It works fine but how can I manually view its values? In Firefox you can use Firebug. Anyone have any suggestions?...

How can I compare two lists in python and return matches

I want to take two lists and find the values that appear in both. a = [1, 2, 3, 4, 5] b = [9, 8, 7, 6, 5] returnMatches(a, b) would return [5], for instance....

Execute raw SQL using Doctrine 2

I want to execute raw SQL using Doctrine 2 I need to truncate the database tables and initialize tables with default test data....

Resetting Select2 value in dropdown with reset button

What would be the best way to reset the selected item to default? I'm using Select2 library and when using a normal button type="reset", the value in the dropdown doesn't reset. So when I press my button I want "All" to be shown again. jQuery $("#...

Getting individual colors from a color map in matplotlib

If you have a Colormap cmap, for example: cmap = matplotlib.cm.get_cmap('Spectral') How can you get a particular colour out of it between 0 and 1, where 0 is the first colour in the map and 1 is the last colour in the map? Ideally, I would be abl...

Git fails when pushing commit to github

I cloned a git repo that I have hosted on github to my laptop. I was able to successfully push a couple of commits to github without problem. However, now I get the following error: Compressing objects: 100% (792/792), done. error: RPC failed; re...

Volley JsonObjectRequest Post request not working

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

Spring - @Transactional - What happens in background?

I want to know what actually happens when you annotate a method with @Transactional? Of course, I know that Spring will wrap that method in a Transaction. But, I have the following doubts: I heard that Spring creates a proxy class? Can someone exp...

How to pass url arguments (query string) to a HTTP request on Angular?

I would like to trigger HTTP request from an Angular component, but I do not know how to add URL arguments (query string) to it. this.http.get(StaticSettings.BASE_URL).subscribe( (response) => this.onGetForecastResult(response.json()), (error)...

Cannot serve WCF services in IIS on Windows 8

When I try to serve a WCF service on IIS in a Windows 8 machine, I get the well known error The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloa...

calling another method from the main method in java

I have class foo{ public static void main(String[] args){ do(); } public void do(){} } but then when I call do() from main by running the command java foo on the command line, java complains that you can't call a method from a ...

Vue is not defined

I am trying to build a demo app with Vue.js. What I am getting is an odd error that Vue is not defined. <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Vue JS Intro</title> </head&...

How to hide column of DataGridView when using custom DataSource?

I have a small app in c#, it has a DataGridView that gets filled using: grid.DataSource = MyDatasource array; MyClass hold the structure for the columns, it looks something like this: class MyDatasource { private string column1; pr...

How to format date with hours, minutes and seconds when using jQuery UI Datepicker?

Is it possible to format a date with jQuery UI Datepicker as to show hours, minutes and seconds? This is my current mockup: _x000D_ _x000D_ $(function() {_x000D_ $('#datepicker').datepicker({ dateFormat: 'yyy-dd-mm HH:MM:ss' }).val();_x000D_ })...

Set NA to 0 in R

After merging a dataframe with another im left with random NA's for the occasional row. I'd like to set these NA's to 0 so I can perform calculations with them. Im trying to do this with: bothbeams.data = within(bothbeams.data, { bothbea...

Remove all classes that begin with a certain string

I have a div with id="a" that may have any number of classes attached to it, from several groups. Each group has a specific prefix. In the javascript, I don't know which class from the group is on the div. I want to be able to clear all classes with ...

Get current controller in view

I have a View - _Edit which lives in News M/V/C. I reuse the V/M via the CategoryController as: return PartialView("/Views/News/_Edit.cshtml", model); How from within the View - _Edit can I alert the controller name? When I: alert('@ViewContext...

Access a JavaScript variable from PHP

I need to access a JavaScript variable with PHP. Here's a stripped-down version of the code I'm currently trying, which isn't working: <script type="text/javascript" charset="utf-8"> var test = "tester"; </script> <?php echo ...

How to push a single file in a subdirectory to Github (not master)

I have changed a single file in a subdirectory of my repository and I want to push just that file to Github. I've made a small change to one file, and I don't want to re-upload the entire repository. It seems like all of the instructions that I'v...

How to obtain the total numbers of rows from a CSV file in Python?

I'm using python (Django Framework) to read a CSV file. I pull just 2 lines out of this CSV as you can see. What I have been trying to do is store in a variable the total number of rows the CSV also. How can I get the total number of rows? file = o...

What does "xmlns" in XML mean?

I saw the following line in an XML file: xmlns:android="http://schemas.android.com/apk/res/android" I have also seen xmlns in many other XML files that I've come across. What is it?...

How can I Insert data into SQL Server using VBNet

I am new to vb.net I need to insert data in table by using vb.net please can any one help I have tried this Here I tried Sample Code I got this exception Column name or number of supplied values does not match table definition. thanks advance ...

C++ trying to swap values in a vector

This is my swap function: template <typename t> void swap (t& x, t& y) { t temp = x; x = y; y = temp; return; } And this is my function (on a side note v stores strings) call to swap values but whenever I try to call ...

String date to xmlgregoriancalendar conversion

I have written this function : public static XMLGregorianCalendar getXMLGregorianCalendar(String date) throws OmniException{ XMLGregorianCalendar xmlCalender=null; GregorianCalendar calender = new GregorianCalendar(); calender.setTime(Ut...

nginx: connect() failed (111: Connection refused) while connecting to upstream

Trying to deploy my first portal . I am getting 502 gateway timeout error in browser when i was sending the request through browser when i checked the logs , i got this error 2014/02/03 09:00:32 [error] 16607#0: *1 connect() failed (111: Connec...

How to remove duplicates from Python list and keep order?

Given a list of strings, I want to sort it alphabetically and remove duplicates. I know I can do this: from sets import Set [...] myHash = Set(myList) but I don't know how to retrieve the list members from the hash in alphabetical order. I'm not ...

Binding ComboBox SelectedItem using MVVM

I have a problem with the SelectedItem in my ComboBox. <ComboBox Name="cbxSalesPeriods" ItemsSource="{Binding SalesPeriods}" DisplayMemberPath="displayPeriod" SelectedItem="{Binding SelectedSalesPeriod}" SelectedV...

Changing cursor to waiting in javascript/jquery

How would i get my cursor to change to this loading icon when a function is called and how would i change it back to a normal cursor in javascript/jquery...

The APK file does not exist on disk

When I am trying debug application on Android Studio gives this log output : The APK file /Users/MyApplicationName/app/build/outputs/apk/app-debug.apk does not exist on disk. I restarted Android Studio, but I can't solve this problem . How...

How to list all the roles existing in Oracle database?

How to list all the roles existing in Oracle database? I have been searching in the tables : ROLE_TAB_PRIVS ROLE_SYS_PRIVS ROLE_ROLE_PRIVS SELECT * FROM ROLE_TAB_PRIVS WHERE ROLE = 'ROLETEST'; but I can't find a role that I have just created....

Update value of a nested dictionary of varying depth

I'm looking for a way to update dict dictionary1 with the contents of dict update wihout overwriting levelA dictionary1={'level1':{'level2':{'levelA':0,'levelB':1}}} update={'level1':{'level2':{'levelB':10}}} dictionary1.update(update) print diction...

Parsing JSON using Json.net

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

Remove or adapt border of frame of legend using matplotlib

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

Vertical alignment of text and icon in button

I'm having trouble vertically aligning a font-awesome icon with text within a button under the Bootstrap framework. I've tried so many things including setting the line-height, but nothing is working. <button id="edit-listing-form-house_Continue"...

Add column to SQL query results

I'm putting together a report in SSRS. The dataset is populated with a SQL query of an MS SQL server. It's querying several similar tables using Union All. The problem is that there's some information loss. The different tables are for different work...

Get contentEditable caret index position

I'm finding tons of good, crossbrowser anwers on how to SET the cursor or caret index position in a contentEditable element, but none on how to GET or find its index... What I want to do is know the index of the caret within this div, on keyup. So...

Plotting multiple curves same graph and same scale

This is a follow-up of this question. I wanted to plot multiple curves on the same graph but so that my new curves respect the same y-axis scale generated by the first curve. Notice the following example: y1 <- c(100, 200, 300, 400, 500) y2 <...

Facebook API "This app is in development mode"

What does "development mode" mean for a facebook app? I find no exact explanation of what I can and can't do while in development mode and what's the relation with the "Not available to all users because your app is not live". Some people also refer...

unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9

I am trying to run Selenium tests on Debian 7 but without success. The error is: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9.248316,platform=Linux 3.2.0-4-686-pae x86) (WARNING: The server did not provi...

Pandas read_sql with parameters

Are there any examples of how to pass parameters with an SQL query in Pandas? In particular I'm using an SQLAlchemy engine to connect to a PostgreSQL database. So far I've found that the following works: df = psql.read_sql(('select "Timestamp","Va...

TextView bold via xml file?

Is there a way to bold the text in a TextView via XML? <TextView android:textSize="12dip" android:textAppearance="bold" -> ?? </TextView> Thanks...

HTML5 Audio stop function

I am playing a small audio clip on click of each link in my navigation HTML Code: <audio tabindex="0" id="beep-one" controls preload="auto" > <source src="audio/Output 1-2.mp3"> <source src="audio/Output 1-2.ogg"> </aud...

linux script to kill java process

I want linux script to kill java program running on console. Following is the process running as jar. [rapp@s1-dlap0 ~]$ ps -ef |grep java rapp 9473 1 0 15:03 pts/1 00:00:15 java -jar wskInterface-0.0.1-SNAPSHOT-jar-with-dependencies.jar ...

SQL Server 2008 Insert with WHILE LOOP

I have existing records like ID Hospital ID Email Description 1 15 [email protected] Sample Description 2 15 [email protected] Random Text I need to use a WHILE loop to insert rows with Hospit...

Show week number with Javascript?

I have the following code that is used to show the name of the current day, followed by a set phrase. <script type="text/javascript"> <!-- // Array of day names var dayNames = new Array( "It's Sunday, the weekend is nearly...

Android: long click on a button -> perform actions

I want to use the same button to perform 2 different methods. One method when user single clicks it and a second method (different) when the user LONG clicks it. I use this for the single short click (which works great): Button downSelected = (Butt...

Unable to show a Git tree in terminal

Killswitchcollective.com's old article, 30 June 2009, has the following inputs and outputs git co master git merge [your_branch] git push upstream A-B-C-D-E A-B-C-D-E-F-G \ ----> \ your branch ...

Byte Array to Image object

I am given a byte[] array in Java which contains the bytes for an image, and I need to output it into an image. How would I go about doing this? Much thanks...

How to prevent background scrolling when Bootstrap 3 modal open on mobile browsers?

How to prevent background scrolling when Bootstrap 3 modal open on mobile platforms? On desktop browsers the background is prevented from scrolling and works as it should. On mobile browsers (Safari ios, Chrome ios, etc), when a modal is opened an...

Can I delete data from the iOS DeviceSupport directory?

After going through and cleaning my disk with old things that I didn't need anymore, I came across the iOS DeviceSupport folder in ~/Library/Developer/Xcode which was taking nearly 20 GB. A similar question has been asked before, but since then man...

Best way to access web camera in Java

I need to access web camera using Java. This is what I want to do Access web cam Now the user can see web cam working because his face is visible on screen (have heard some libs are there which doesn't show the video output of webcam) when user c...

Hide Show content-list with only CSS, no javascript used

I've been searching for a good trick to make a Hide/Show content or a list with only CSS and no javascript. I've managed to make this action: <!DOCTYPE html> <head> <style> #cont {display: none; } .show:focus + .hid...

Bootstrap Navbar toggle button not working

When I shrink the window and click the button it doesn't work. Button doesn't respond. What seems to be the problem here could anyone tell me please? <button type="button" class="navbar-toggle" data-toggle="collapse" da...

.bashrc: Permission denied

I try to work with a project in vagrant. I have made the command vagrant ssh, and connected to VM. Now I need to edit .bashrc file to set path to the source code. But first I couldn't find that file. So I googled and find that the way is call comman...

awk without printing newline

I want the variable sum/NR to be printed side-by-side in each iteration. How do we avoid awk from printing newline in each iteration ? In my code a newline is printed by default in each iteration for file in cg_c ep_c is_c tau xhpl printf "\n $file"...

Selecting multiple columns with linq query and lambda expression

I'm new to C# ASP.NET, and am working on my first application. I'm trying to create a linq statment that return an arrary. I have a table of products. I want to be able to select name, id, and price, for each product where the status == 1. I am st...

Chrome/jQuery Uncaught RangeError: Maximum call stack size exceeded

I am getting the error "Uncaught RangeError: Maximum call stack size exceeded" on chrome. here is my jQuery function $('td').click(function () { if ($(this).context.id != null && $(this).context.id != '') { foo($('#docId'...

How to handle calendar TimeZones using Java?

I have a Timestamp value that comes from my application. The user can be in any given local TimeZone. Since this date is used for a WebService that assumes the time given is always in GMT, I have a need to convert the user's parameter from say (EST)...

do { ... } while (0) — what is it good for?

Possible Duplicate: Why are there sometimes meaningless do/while and if/else statements in C/C++ macros? I've been seeing that expression for over 10 years now. I've been trying to think what it's good for. Since I see it mostly in #define...

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided does not match the recipient window's origin ('null')

I have a game in heroku, now I'm trying to make it work in Facebook canvas, but, while it works in Firefox, in Chrome and IE doesn't. IE shows a warning with a button, when clicking the button, it shows the content. In chrome, I get this error: Fa...

Replace preg_replace() e modifier with preg_replace_callback

I'm terrible with regular expressions. I'm trying to replace this: public static function camelize($word) { return preg_replace('/(^|_)([a-z])/e', 'strtoupper("\\2")', $word); } with preg_replace_callback with an anonymous function. I don't und...

async/await - when to return a Task vs void?

Under what scenarios would one want to use public async Task AsyncMethod(int num) instead of public async void AsyncMethod(int num) The only scenario that I can think of is if you need the task to be able to track its progress. Additionally...

CSS: Set Div height to 100% - Pixels

I have a header on my page which is just over 100px (111px to be exact) The div below it needs to extend to the bottom of the viewport, as if i had set the bottom to 0px. The problem lies in the fact that i cannot specify top and bottom in ie6 (bug)....

How to completely DISABLE any MOUSE CLICK

After the user clicks on...."log in" button, and other events, I made a loading script -to let users know they have to wait (Until ajax replies back). How can I DISABLE any MOUSE CLICKS (right click, left click, double click, middle click, x click),...

How can I take a screenshot with Selenium WebDriver?

Is it possible to take a screenshot using Selenium WebDriver? (Note: Not Selenium Remote Control)...

VirtualBox: mount.vboxsf: mounting failed with the error: No such device

I'm using VirtualBox with OS X as host and CentOS on the guest VM. In OS X I created folder myfolder, added it as shared folder to the VM, turned on the VM, in CentOS created folder /home/user/myfolder and typing: sudo mount -t vboxsf myfolder /hom...

Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null

I have a component in React which I am importing in index.js, but it is giving this error: Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null index.js: import React from 'reac...

Message: Trying to access array offset on value of type null

I'm getting this error on multiple occasion in a script (invoiceplane) I have been using for a few years now but which hasn't been maintained unfortunately by its creators: Message: Trying to access array offset on value of type null My server has...

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

Remove a specific character using awk or sed

I have a command output from which I want to remove the double quotes ". Regex: strings -a libAddressDoctor5.so |\ grep EngineVersion | awk '{if(NR==2)print}' | awk '{print$2}' Output: EngineVersion="5.2.5.624" I'd like to know how to remove u...

VSCode regex find & replace submatch math?

%s@{fileID: \(213[0-9]*\)@\='{fileID: '.(submatch(1)-1900)@ I am using this regex search and replace command in vim to subtract a constant from each matching id. I can do the regex find in VSCode but how can I reference the submatch for maths &...

Can I clear cell contents without changing styling?

Is there a way to clear the contents of multiple cells, but without changing the background/font properties of the cells? I am currently using Range("X").Cells.Clear but its removing my background color and I would prefer not to have to "repaint" it...

How to share data between different threads In C# using AOP?

How to share data between different threads In C# without using the static variables? Can we create a such machanism using attribute? Will Aspect oriented programming help in such cases? To acheive this all the different threads should work on sing...

What is the mouse down selector in CSS?

I have noticed that buttons and other elements have a default styling and behave in 3 steps: normal view, hover/focus view and mousedown/click view, in CSS I can change the styling of normal view and hover view like this: button{ background:#333; ...

Scroll to element on click in Angular 4

I want to be able to scroll to a target when a button is pressed. I was thinking something like this. <button (click)="scroll(#target)">Button</button> And in my component.ts a method like. scroll(element) { window.scrollTo...

HTML/CSS - Adding an Icon to a button

I making some css buttons and I want to add an icon before the text, "Button Text". But I dont know how I should do this... HTML <div class="btn btn_red"><a href="#">Crimson</a><span></span></div> CSS body { ...

Unable to find a @SpringBootConfiguration when doing a JpaTest

I'm new to frameworks (just passed the class) and this is my first time using Spring Boot. I'm trying to run a simple Junit test to see if my CrudRepositories are indeed working. The error I keep getting is: Unable to find a @SpringBootConfigur...

Spark - SELECT WHERE or filtering?

What's the difference between selecting with a where clause and filtering in Spark? Are there any use cases in which one is more appropriate than the other one? When do I use DataFrame newdf = df.select(df.col("*")).where(df.col("somecol").leq(10...

C# version of java's synchronized keyword?

Does c# have its own version of the java "synchronized" keyword? I.e. in java it can be specified either to a function, an object or a block of code, like so: public synchronized void doImportantStuff() { // dangerous code goes here. } or pu...

Which Ruby version am I really running?

I'm running Ubuntu 12.04 LTS, and installed Ruby via RVM. The problem is, when I type ruby -v into the terminal, it says that my Ruby version is 1.8.7, and using the shotgun gem for Sinatra also says that I'm running Ruby 1.8.7. But when I type rv...

Best programming based games

Back when I was at school, I remember tinkering with a Mac game where you programmed little robots in a sort of pseudo-assembler language which could then battle each other. They could move themselves around the arena, look for opponents in different...

View the change history of a file using Git versioning

How can I view the change history of an individual file in Git, complete details with what has changed? I have got as far as: git log -- [filename] which shows me the commit history of the file, but how do I get at the content of each of the fil...

How can I get the name of an html page in Javascript?

I have an html page and I would like inside the html page to retrieve the name of the html document via Javascript. Is that possible? e.g. name of html document = "indexOLD.html"...

Run a php app using tomcat?

Is it possible to run a PHP app using tomcat? Before you tell me to just use httpd, I already have a Java application running on my webserver at host/myapp. Now I want to install RoundCube at host/roundcube. One is PHP and one is Java. I keep seei...

Show a popup/message box from a Windows batch file

Is there a way to display a message box from a batch file (similar to how xmessage can be used from bash-scripts in Linux)?...

The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via

I am trying to make a WCF service over basicHttpBinding to be used over https. Here's my web.config: <!-- language: xml --> <service behaviorConfiguration="MyServices.PingResultServiceBehavior" name="MyServices.PingResultService"&g...

How to plot vectors in python using matplotlib

I am taking a course on linear algebra and I want to visualize the vectors in action, such as vector addition, normal vector, so on. For instance: V = np.array([[1,1],[-2,2],[4,-7]]) In this case I want to plot 3 vectors V1 = (1,1), M2 = (-2,2)...

How can foreign key constraints be temporarily disabled using T-SQL?

Are disabling and enabling foreign key constraints supported in SQL Server? Or is my only option to drop and then re-create the constraints?...

LEFT JOIN vs. LEFT OUTER JOIN in SQL Server

What is the difference between LEFT JOIN and LEFT OUTER JOIN?...

Array as session variable

Is it possible to make an array a session variable in PHP? The situation is that I have a table (page 1) with some cells having a link to a particular page. The next page will have a list of names (page 2, which I want to keep in a session array) wi...

Debug/run standard java in Visual Studio Code IDE and OS X?

Love the light-weight Visual Studio Code in OS X. Have always wanted the ability to write, debug and run standard java (NOT javascript) from VSC in OS X. Found the following extension which allows you to debug and run java from VSC: https://marketpl...

How to set or change the default Java (JDK) version on OS X?

How can you change the default version of Java on a mac?...

Regex to match string containing two names in any order

I need logical AND in regex. something like jack AND james agree with following strings 'hi jack here is james' 'hi james here is jack' ...

Passing data into "router-outlet" child components

I've got a parent component that goes to the server and fetches an object: // parent component @Component({ selector : 'node-display', template : ` <router-outlet [node]="node"></router-outlet> ` }) export class Nod...

Copying files from server to local computer using SSH

I am having trouble copying files from a remote server using SSH. Using PuTTY I log in to the server using SSH. Once I find the file I would like to copy over to my computer, I use the command: scp [email protected]:/dir/of/file.txt \local\dir\ It...

make div's height expand with its content

I have these nested divs and I need the main container to expand (in height) to accommodate the DIVs inside <!-- head --> ... <!-- /head --> <body class="main"> <div id="container"> <div i...

How do I revert a Git repository to a previous commit?

How do I revert from my current state to a snapshot made on a certain commit? If I do git log, then I get the following output: $ git log commit a867b4af366350be2e7c21b8de9cc6504678a61b` Author: Me <[email protected]> Date: Thu Nov 4 18:59:41 2010 ...

How to use OpenCV SimpleBlobDetector

Instead of any additional blob detection library, how do I use the cv::SimpleBlobDetector class and its function detectblobs()?...

Python pip install fails: invalid command egg_info

I find that recently often when I try to install a Python package using pip, I get the error(s) below. I found a reference online that one has to use "python2 setup.py install" from the download directory, and indeed find that this will then work if...

How to open every file in a folder

I have a python script parse.py, which in the script open a file, say file1, and then do something maybe print out the total number of characters. filename = 'file1' f = open(filename, 'r') content = f.read() print filename, len(content) Right no...

Prevent overwriting a file using cmd if exist

I am currently writing a .bat batch file that executes an installation file. Before it runs the installation file I check to see if the directory exists to avoid re-installing the application. I do this by using a If Not Exist filename statement. If...

Django: List field in model?

In my model, I want a field that has a list of triplets. e.g. [[1, 3, 4], [4, 2, 6], [8, 12, 3], [3, 3, 9]]. Is there a field that can store this data in the database?...

How to catch exception output from Python subprocess.check_output()?

I'm trying to do a Bitcoin payment from within Python. In bash I would normally do this: bitcoin sendtoaddress <bitcoin address> <amount> so for example: bitcoin sendtoaddress 1HoCUcbK9RbVnuaGQwiyaJGGAG6xrTPC9y 1.4214 if it is succe...

How to skip to next iteration in jQuery.each() util?

I'm trying to iterate through an array of elements. jQuery's documentation says: jquery.Each() documentation Returning non-false is the same as a continue statement in a for loop, it will skip immediately to the next iteration. I've tried call...

Are HTTPS URLs encrypted?

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

SQL Server: use CASE with LIKE

I am pretty new to SQL and hope someone here can help me with this. I have a stored procedure where I would like to pass a different value depending on whether a column contains a certain country or not. So far I only used CASE when checking for ...

Adding machineKey to web.config on web-farm sites

We (our IT partner really) recently changed some DNS for a web farmed site we have, so that the two production server have round-robin DNS switching between them. Prior to this switch we didn't really have problems with WebResource.axd files. Since t...

ajax jquery simple get request

I am making this simple get request using jquery ajax: $.ajax({ url: "https://app.asana.com/-/api/0.1/workspaces/", type: 'GET', success: function(res) { console.log(res); alert(res); } }); It's returning an empty s...

How do I Search/Find and Replace in a standard string?

Is there a way to replace all occurrences of a substring with another string in std::string? For instance: void SomeFunction(std::string& str) { str = str.replace("hello", "world"); //< I'm looking for something nice like this } ...

Collections.emptyList() vs. new instance

In practice, is it better to return an empty list like this: return Collections.emptyList(); Or like this: return new ArrayList<Foo>(); Or is this completely dependent upon what you're going to do with the returned list?...

How to join entries in a set into one string?

Basically, I am trying to join together the entries in a set in order to output one string. I am trying to use syntax similar to the join function for lists. Here is my attempt: list = ["gathi-109","itcg-0932","mx1-35316"] set_1 = set(list) set_2 = ...

Output data with no column headings using PowerShell

I want to be able to output data from PowerShell without any column headings. I know I can hide the column heading using Format-Table -HideTableHeaders, but that leaves a blank line at the top. Here is my example: get-qadgroupmember 'Domain Admins'...

How to initialize all the elements of an array to any specific value in java

In C/C++ we have memset() function which can fulfill my wish but in Java how can i initialize all the elements to a specific value? Whenever we write int[] array=new int[10]; , this simply initialize an array of size 10 having all elements equal to z...

Understanding generators in Python

I am reading the Python cookbook at the moment and am currently looking at generators. I'm finding it hard to get my head round. As I come from a Java background, is there a Java equivalent? The book was speaking about 'Producer / Consumer', however...

How to check which version of Keras is installed?

Question is the same as the title says. I prefer not to open Python and I use either MacOS or Ubuntu....

Converting newline formatting from Mac to Windows

I need a conversion utility/script that will convert a .sql dump file generated on Mac to one readable on Windows. This is a continuation of a problem I had here. The issue seems to be with newline formatting in text files, but I can't find a tool ...

Combining two expressions (Expression<Func<T, bool>>)

I have two expressions of type Expression<Func<T, bool>> and I want to take to OR, AND or NOT of these and get a new expression of the same type Expression<Func<T, bool>> expr1; Expression<Func<T, bool>> expr2; ....

SQL - How to find the highest number in a column?

Let's say I have the following data in the Customers table: (nothing more) ID FirstName LastName ------------------------------- 20 John Mackenzie 21 Ted Green 22 Marcy Nate What sort of SELECT statement can get me t...

How to start anonymous thread class

I have the following code snippet: public class A { public static void main(String[] arg) { new Thread() { public void run() { System.out.println("blah"); } }; } } Here, how do I call...

Can I scroll a ScrollView programmatically in Android?

Is there any way to scroll a ScrollView programmatically to a certain position? I have created dynamic TableLayout which is placed in a ScrollView. So I want that on a specific action (like clicking a Button, etc.) the particular row should scroll a...

Check if an element is present in an array

The function I am using now to check this is the following: function inArray(needle,haystack) { var count=haystack.length; for(var i=0;i<count;i++) { if(haystack[i]===needle){return true;} } return false; } It works....

Save ArrayList to SharedPreferences

I have an ArrayList with custom objects. Each custom object contains a variety of strings and numbers. I need the array to stick around even if the user leaves the activity and then wants to come back at a later time, however I don't need the array a...

System.BadImageFormatException: Could not load file or assembly (from installutil.exe)

I am trying to install a Windows service using InstallUtil.exe and am getting the error message System.BadImageFormatException: Could not load file or assembly '{xxx.exe}' or one of its dependencies. An attempt was made to load a program with an ...

Hide div by default and show it on click with bootstrap

I want to show and hide a div, but I want it to be hidden by default and to be able to show and hide it on click. Here is the code that I have made : <a class="button" onclick="$('#target').toggle();"> <i class="fa fa-level-down"></...

How to hide Soft Keyboard when activity starts

I have an Edittext with android:windowSoftInputMode="stateVisible" in Manifest. Now the keyboard will be shown when I start the activity. How to hide it? I cannot use android:windowSoftInputMode="stateHidden because when keyboard is visible then mini...

HTML - how to make an entire DIV a hyperlink?

How do I make an entire DIV a clickable hyperlink. Meaning, I essentially want to do: <div class="myclass" href="example.com"> <div>...</div> <table><tr>..</tr></table> .... </div> And wh...

Bootstrap 3: How do you align column content to bottom of row

I have a row in Bootstrap 3 and 3 columns in that row. I want to align two of the columns to the bottom of the row and keep the first column at the top. When I use the traditional approach with position relative in the parent and absolute for both co...

How to get a path to a resource in a Java JAR file

I am trying to get a path to a Resource but I have had no luck. This works (both in IDE and with the JAR) but this way I can't get a path to a file, only the file contents: ClassLoader classLoader = getClass().getClassLoader(); PrintInputStream(c...

how to do bitwise exclusive or of two strings in python?

I would like to perform a bitwise exclusive or of two strings in python, but xor of strings are not allowed in python. How can I do it ?...

The definitive guide to form-based website authentication

Form-based authentication for websites We believe that Stack Overflow should not just be a resource for very specific technical questions, but also for general guidelines on how to solve variations on common problems. "Form based authentication...

Intel's HAXM equivalent for AMD on Windows OS

Is there any equivalent of Intel's HAXM for AMD (Windows OS) or has anybody been able to hack HAXM to make it work on AMD processors (Windows OS)? Also, would Genymotion (http://www.genymotion.com) be significantly faster compared to the default Goo...

Setting up Eclipse with JRE Path

I have downloaded and extracted Eclipse. I have Eclipse in the following directory: C:\Applications\eclipse. When I try and run the executable , I get the following message : I currently have the following folder: C:\Program Files (x86)\Java\jre7...

Is it possible for UIStackView to scroll?

Let's say I have added more views in UIStackView which can be displayed, how I can make the UIStackView scroll?...

Create a simple HTTP server with Java?

What's the easiest way to create a simple HTTP server with Java? Are there any libraries in commons to facilitate this? I only need to respond to GET/POST, and I can't use an application server. What's the easiest way to accomplish this?...

Run a command shell in jenkins

I'm trying to execute a command shell in Jenkins, I'm working on Windows 7. In the console output I have this: Building in workspace C:\Program Files (x86)\Jenkins\workspace\test [test] $ sh -xe C:\Windows\TEMP\hudson6299483223982766034.sh The syste...

Changing Jenkins build number

Is there a way to change the build number that is sent via email after a job completes? The problem is that are product builds are NOT being done by Jenkins, so we want to be able to get the build number(ie. from a text file) and update the build nu...

How can I print to the same line?

I want to print a progress bar like so: [# ] 1% [## ] 10% [########## ] 50% But these should all be printed to the same line in the terminal instead of a new one. What I mean by that is that each new ...

How to get a certain element in a list, given the position?

So I've got a list: list<Object> myList; myList.push_back(Object myObject); I'm not sure but I'm confident that this would be the "0th" element in the array. Is there any function I can use that will return "myObject"? Object copy = myList....

Execute a file with arguments in Python shell

I would like to run a command in Python Shell to execute a file with an argument. For example: execfile("abc.py") but how to add 2 arguments?...

How to save RecyclerView's scroll position using RecyclerView.State?

I have a question about Android's RecyclerView.State. I am using a RecyclerView, how could I use and bind it with RecyclerView.State? My purpose is to save the RecyclerView's scroll position....

How can I test if a letter in a string is uppercase or lowercase using JavaScript?

How can I test if a letter in a string is uppercase or lowercase using JavaScript?...

Launching a website via windows commandline

I have a program launching a website via the following command. cmd "start /max http://url.com" When launching a website via this method it uses the default browser with its default settings for opening a new window. for example, Firefox and IE w...

Leading zeros for Int in Swift

I'd like to convert an Int in Swift to a String with leading zeros. For example consider this code: for myInt in 1 ... 3 { print("\(myInt)") } Currently the result of it is: 1 2 3 But I want it to be: 01 02 03 Is there a clean way of doi...

How do I split a string by a multi-character delimiter in C#?

What if I want to split a string using a delimiter that is a word? For example, This is a sentence. I want to split on is and get This and a sentence. In Java, I can send in a string as a delimiter, but how do I accomplish this in C#?...

Convert hex to binary

I have ABC123EFFF. I want to have 001010101111000001001000111110111111111111 (i.e. binary repr. with, say, 42 digits and leading zeroes). How?...

Attach Authorization header for all axios requests

I have a react/redux application that fetches a token from an api server. After the user authenticates I'd like to make all axios requests have that token as an Authorization header without having to manually attach it to every request in the action....

Matching special characters and letters in regex

I am trying to validate a string, that should contain letters numbers and special characters &-._ only. For that I tried with a regular expression. var pattern = /[a-zA-Z0-9&_\.-]/ var qry = 'abc&*'; if(qry.match(pattern)) { alert('v...

What does "export" do in shell programming?

As far as I can tell, variable assignment is the same whether it is or is not preceded by "export". What's it for?...

add scroll bar to table body

I want to do this as easily as possible with out any additional libraries. In my very long table I want to add a scrollbar to the <tbody> tag so that the head is always visible but it wont work. can you please help. fiddle : http://jsfiddle....

ASP.NET email validator regex

Does anyone know what the regex used by the email validator in ASP.NET is?...

Check Postgres access for a user

I have looked into the documentation for GRANT Found here and I was trying to see if there is a built-in function that can let me look at what level of accessibility I have in databases. Of course there is: \dp and \dp mytablename But this does not...

Html Agility Pack get all elements by class

I am taking a stab at html agility pack and having trouble finding the right way to go about this. For example: var findclasses = _doc.DocumentNode.Descendants("div").Where(d => d.Attributes.Contains("class")); However, obviously you can add c...

Unable to copy file - access to the path is denied

I am using Visual Studio 2005. After taking code from version control first, the c#.net application runs correctly. But, after doing some modifications, when I build I am getting the following error: Error 383 Unable to copy file "..\root\leaf...

LINQ Group By into a Dictionary Object

I am trying to use LINQ to create a Dictionary<string, List<CustomObject>> from a List<CustomObject>. I can get this to work using "var", but I don't want to use anonymous types. Here is what I have var x = (from CustomObject o in...

Java way to check if a string is palindrome

I want to check if a string is a palindrome or not. I would like to learn an easy method to check the same using least possible string manipulations...

Disabling right click on images using jquery

I want to know how to disable right click on images using jQuery. I know only this: <script type="text/javascript" language="javascript"> $(document).ready(function() { $(document).bind("contextmenu",function(e) { retur...

How to get a Static property with Reflection

So this seems pretty basic but I can't get it to work. I have an Object, and I am using reflection to get to it's public properties. One of these properties is static and I'm having no luck getting to it. Public Function GetProp(ByRef obj As Objec...

Node.js, can't open files. Error: ENOENT, stat './path/to/file'

I have developed a node.js program using the express framework on my computer, where it runs fine with no complaints. However, when I run the program on my SUSE Studio appliance, where it is intended to live, I receive an error at any file interacti...

How to display multiple images in one figure correctly?

I am trying to display 20 random images on a single Figure. The images are indeed displayed, but they are overlaid. I am using: import numpy as np import matplotlib.pyplot as plt w=10 h=10 fig=plt.figure() for i in range(1,20): img = np.random.r...

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 7: ordinal not in range(128)

I have this code: printinfo = title + "\t" + old_vendor_id + "\t" + apple_id + '\n' # Write file f.write (printinfo + '\n') But I get this error when running it: f.write(printinfo + '\n') UnicodeEncodeError: 'ascii' codec can't en...

Nuget connection attempt failed "Unable to load the service index for source"

While trying to connect to Nuget, I'm getting the error below, and then I am unable to connect: [nuget.org] Unable to load the service index for source https://api.nuget.org/v3/index.json. An error occurred while sending the request. Unable to conne...

Is there a Python caching library?

I'm looking for a Python caching library but can't find anything so far. I need a simple dict-like interface where I can set keys and their expiration and get them back cached. Sort of something like: cache.get(myfunction, duration=300) which will...

Meaning of @classmethod and @staticmethod for beginner?

Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or....

Format numbers in JavaScript similar to C#

Is there a simple way to format numbers in JavaScript, similar to the formatting methods available in C# (or VB.NET) via ToString("format_provider") or String.Format()?...

invalid operands of types int and double to binary 'operator%'

After compiling the program I am getting below error invalid operands of types int and double to binary 'operator%' at line "newnum1 = two % (double)10.0;" Why is it so? #include<iostream> #include<math> using namespace std; int main...

How to add minutes to my Date

I have this date object: SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd HH:mm"); Date d1 = df.parse(interviewList.get(37).getTime()); value of d1 is Fri Jan 07 17:40:00 PKT 2011 Now I am trying to add 10 minutes to the date above. Calend...

C++ floating point to integer type conversions

What are the different techniques used to convert float type of data to integer in C++? #include <iostream> using namespace std; struct database { int id, age; float salary; }; int main() { struct database employee; employee.id = 1; ...

How to urlencode data for curl command?

I am trying to write a bash script for testing that takes a parameter and sends it through curl to web site. I need to url encode the value to make sure that special characters are processed properly. What is the best way to do this? Here is my ...

Writing file to web server - ASP.NET

I simply want to write the contents of a TextBox control to a file in the root of the web server directory... how do I specify it? Bear in mind, I'm testing this locally... it keeps writing the file to my program files\visual studio\Common\IDE direc...

How do I set an absolute include path in PHP?

In HTML, I can find a file starting from the web server's root folder by beginning the filepath with "/". Like: /images/some_image.jpg I can put that path in any file in any subdirectory, and it will point to the right image. With PHP, I t...

OVER_QUERY_LIMIT in Google Maps API v3: How do I pause/delay in Javascript to slow it down?

I'm hitting an issue that is WELL discussed in these forums, but none of the recommendations seem to be working for me so I'm looking for some full javascript that works when saved as an html file. The issue is I keep hitting the OVER_QUERY_LIMIT er...

How to force DNS refresh for a website?

I'm moving my web application to another server and in the next few days I'll refresh the DNS to point to the new IP location. Unfortunately some browsers and SOs keep a DNS cache that will make users point to the old IP location. Some users are roo...

How to pause a YouTube player when hiding the iframe?

I have a hidden div containing a YouTube video in an <iframe>. When the user clicks on a link, this div becomes visible, the user should then be able to play the video. When the user closes the panel, the video should stop playback. How can I ...

How to set proxy for wget?

I want to download something with wget using a proxy: HTTP Proxy: 127.0.0.1 Port: 8080 The proxy does not need username and password. How can I do this?...

MySQL - Operand should contain 1 column(s)

While working on a system I'm creating, I attempted to use the following query in my project: SELECT topics.id, topics.name, topics.post_count, topics.view_count, COUNT( posts.solved_post ) AS solved_post, (SELECT users.username AS posted_by, us...

Hibernate: best practice to pull all lazy collections

What I have: @Entity public class MyEntity { @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true) @JoinColumn(name = "myentiy_id") private List<Address> addreses; @OneToMany(cascade = CascadeType.ALL, fe...

Regular Expression for alphanumeric and underscores

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

MySQL Trigger - Storing a SELECT in a variable

I have a trigger in which I want to have a variable that holds an INT I get from a SELECT, so I can use it in two IF statements instead of calling the SELECT twice. How do you declare/use variables in MySQL triggers?...

T-SQL datetime rounded to nearest minute and nearest hours with using functions

In SQL server 2008, I would like to get datetime column rounded to nearest hour and nearest minute preferably with existing functions in 2008. For this column value 2007-09-22 15:07:38.850, the output will look like: 2007-09-22 15:08 -- nearest min...

Python write line by line to a text file

I am trying to output the result from a Python script to a text file where each output should be saved to a line. f1=open('./output.txt', 'a') f1.write(content + "\n") When I open output.txt with the regular notepad the results look like this: co...

Fully change package name including company domain

Let's suppose this is the package name: package com.company.name. How do I change company? P.S. I saw how to change name but not company. I'm using Android Studio....

How to assert greater than using JUnit Assert?

I have these values coming from a test previousTokenValues[1] = "1378994409108" currentTokenValues[1] = "1378994416509" and I try // current timestamp is greater assertTrue(Long.parseLong(previousTokenValues[1]) > Long.parseLong(curren...

jQuery xml error ' No 'Access-Control-Allow-Origin' header is present on the requested resource.'

I am working on this personal project of mine just for fun where I want to read an xml file which is located at http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml and parse the xml and use it to convert values between the currencies. So ...

Recursion in Python? RuntimeError: maximum recursion depth exceeded while calling a Python object

Possible Duplicate: Maximum recursion depth? I have another problem with my code. I'm wrtiting my first program in Vpython and I have to make a simulation of mixing two gases. First i had a problem with borders, but now when the balls(tha...

Correct way to initialize HashMap and can HashMap hold different value types?

So I have two questions about HashMaps in Java: What is the correct way to initialize a HashMap? I think it might be best in my situation to use: HashMap x = new HashMap(); But Eclipse keeps suggesting that I use: HashMap<something, somethin...

Reading and writing binary file

I'm trying to write code to read a binary file into a buffer, then write the buffer to another file. I have the following code, but the buffer only stores a couple of ASCII characters from the first line in the file and nothing else. int length; ch...

Jenkins "Console Output" log location in filesystem

I want to access and grep Jenkins Console Output as a post build step in the same job that creates this output. Redirecting logs with >> log.txt is not a solution since this is not supported by my build steps. Build: echo "This is log" Post...

How to set-up a favicon?

I am trying to do a very simple preliminary exercise to setting up a website which is creating a favicon. This is the code I am using: <!DOCTYPE html > <html lang="en-US"> <head profile="http://www.w3.org/2005/10/profile"> <li...

Open multiple Eclipse workspaces on the Mac

How can I open multiple Eclipse workspaces at the same time on the Mac? On other platforms, I can just launch extra Eclipse instances, but the Mac will not let me open the same application twice. Is there a better way than keeping two copies of Ecli...

C free(): invalid pointer

I am teaching myself C. My goal is to make a C function that just walks a query string and splits on the ampersand and the equals sign. I am getting stuck on this error from Valgrind. ==5411== Invalid free() / delete / delete[] / realloc() ==5411== ...

Hive Alter table change Column Name

I am trying to rename a columnName in Hive. Is there a way to rename column name in Hive . tableA (column1 ,_c1,_c2) to tableA(column1,column2,column3) ??...

How can I initialize C++ object member variables in the constructor?

I've got a class that has a couple of objects as member variables. I don't want the constructors for these members to be called when declared, so I'm trying to hang onto a pointer to the object explicitly. I have no idea what I'm doing. I thought may...

jquery function val() is not equivalent to "$(this).value="?

When I try to set a text input to blank (when clicked) using $(this).value="", this does not work. I have to use $(this).val(''). Why? What is the difference? What is the mechanism behind the val function in jQuery? $(document).ready(function() { ...

Apache: The requested URL / was not found on this server. Apache

I've installed Apache 2.2 server and PHP 5.3 on Windows XP SP3. After the initial install, Apache loaded the test page, i.e., http:/localhost (C:/Program Files/Apache2.2/htdocs/index.html) showed "It works!". After configuring Apache and installing...

! [rejected] master -> master (fetch first)

Is there a good way to explain how to resolve "! [rejected] master -> master (fetch first)'" in Git? When I use this command $ git push origin master it display an error message. ! [rejected] master -> master (fetch first) error: fai...

Alternative for frames in html5 using iframes

I am new to HTML5 and I have done some research and found out that the use of <frameset> is outdated and from what I read <iframes> are not. So can someone help me, I want to obtain the same result as the example shown but while using <...

How do you discover model attributes in Rails?

I am finding it difficult to easily see what attributes/properties exist on all of my model classes since they are not explicitly defined in my class files. To discover model attributes, I keep the schema.rb file open and flip between it and whateve...

Build the full path filename in Python

I need to pass a file path name to a module. How do I build the file path from a directory name, base filename, and a file format string? The directory may or may not exist at the time of call. For example: dir_name='/home/me/dev/my_reports' base...

CSS: How to remove pseudo elements (after, before,...)?

I would like to use a switch for the layout of paragraph tags on a webpage. I use the after pseudoelement: p:after {content: url("../img/paragraph.gif");} Now I need to remove this CSS code from the page. How can this be done easily? I want to ...

How to install all required PHP extensions for Laravel?

I need to make my Ubuntu 16.04. Is there a way using the GUI or is the simplest way to do this by using terminal? I have already installed PHP 7.1, MariaDB. I need to enable: OpenSSL PHP Extension PDO PHP Extension Mbstring PHP Extension Tokenize...

How can I do SELECT UNIQUE with LINQ?

I have a list like this: Red Red Brown Yellow Green Green Brown Red Orange I am trying to do a SELECT UNIQUE with LINQ, i.e. I want Red Brown Yellow Green Orange var uniqueColors = from dbo in database.MainTable where dbo.Propert...

How to correctly set Http Request Header in Angular 2

I have an Ionic 2 application using Angular 2, which is sending an Http PUT to a ASP.NET Core API server. Here's the method I'm using to send the request: public update(student: Student): Promise<Student> { let headers = new Headers(); ...

Is there a good JSP editor for Eclipse?

I need a nice JSP editor plugin for Eclipse. What are my choices?...

Print raw string from variable? (not getting the answers)

I'm trying to find a way to print a string in raw form from a variable. For instance, if I add an environment variable to Windows for a path, which might look like 'C:\\Windows\Users\alexb\', I know I can do: print(r'C:\\Windows\Users\alexb\') But...

How do you debug MySQL stored procedures?

My current process for debugging stored procedures is very simple. I create a table called "debug" where I insert variable values from the stored procedure as it runs. This allows me to see the value of any variable at a given point in the script, bu...

og:type and valid values : constantly being parsed as og:type=website

Could someone sugggest why the FB debug/lint tool is saying og:type is "website" despite the og:type being set to og:bar? https://developers.facebook.com/tools/debug/og/object?q=www.shamrockirishbar.com%2Fpubquiz As a result its not validating the ...

Firebase TIMESTAMP to date and Time

I am using firebase for my chat application. In chat object I am adding time stamp using Firebase.ServerValue.TIMESTAMP method. I need to show the message received time in my chat application using this Time stamp . if it's current time i need to s...

How do I add more members to my ENUM-type column in MySQL?

The MySQL reference manual does not provide a clearcut example on how to do this. I have an ENUM-type column of country names that I need to add more countries to. What is the correct MySQL syntax to achieve this? Here's my attempt: ALTER TABLE ca...

Error converting data types when importing from Excel to SQL Server 2008

Every time that I try to import an Excel file into SQL Server I'm getting a particular error. When I try to edit the mappings the default value for all numerical fields is float. None of the fields in my table have decimals in them and they aren't ...

Can't connect to docker from docker-compose

I installed docker-machine 0.1.0 and docker-compose 1.1.0 on Mac OS 10.8.5.Docker-machine is running normally and able to connect by docker-machine ssh. $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM dev...

Homebrew refusing to link OpenSSL

I'm on: OSX 10.11.6, Homebrew version 0.9.9m OpenSSL 0.9.8zg 14 July 2015 I'm trying to play with with dotnetcore and by following their instructions, I've upgraded/installed the latest version of openssl: > brew install openssl ==> Downloa...

Listen to changes within a DIV and act accordingly

I have a function that grabs an XML document and transforms it according to an XSL document. It then places the result into a div with the id laneconfigdisplay. What I want to do is, separate to the transformation logic, setup a jQuery change event...

PHP Convert String into Float/Double

I have list of string (size in bytes), I read those from file. Let say one of the string is 2968789218, but when I convert it to float it become 2.00. This is my code so far : $string = "2968789218"; $float = (float)$string; //$float = floatval($st...

what does it mean "(include_path='.:/usr/share/pear:/usr/share/php')"?

I have file structure on EC2 like : but facing some file referencing problem. index.php -db -config.php -cron -cron1.php I have tried file referencing as: `require_once (dirname(__FILE__).'/db/config.php');` `require_once (($_SERVER['DOCUMENT...

Check if an element is present in a Bash array

I was wondering if there is an efficient way to check if an element is present within an array in Bash? I am looking for something similar to what I can do in Python, like: arr = ['a','b','c','d'] if 'd' in arr: do your thing else: do some...

Javascript Cookie with no expiration date

I would like to set up a cookie that never expires. Would that even be possible? document.cookie = "name=value; expires=date; path=path;domain=domain; secure"; I don't want to make the date really large, I am just wondering if there was a value f...

z-index not working with position absolute

I opened the console (chrome\firefox) and ran the following lines: $("body").append("<div id=\"popupFrame\" style=\"width:100%;height:100%;background-color:black;opacity:0.5;position:absolute;top:0;left:0;z-index:1;\" />"); $("body").append("&...

Conditional formatting, entire row based

I've searched and read through answers related to conditional formatting, but I can't seem to get mine to work, so maybe I'm doing something wrong. I have a worksheet for work. It contains a list of animals in our shelter. What I'm attempting to do ...

How to randomize Excel rows

How can I randomize lots of rows in Excel? For example I have an excel sheet with data in 3 rows. 1 A dataA 2 B dataB 3 C dataC I want to randomize the row order. For example 2 B dataB 1 A dataA 3 C dataC I could make a new column and fill it ...

onchange equivalent in angular2

i'm using onchange to save the value of my input range into firebase , but i have an error who say that my function is not defined. this is my function saverange(){ this.Platform.ready().then(() => { this.rootRef.child("users").child(this....

URL Encode a string in jQuery for an AJAX request

I'm implementing Google's Instant Search in my application. I'd like to fire off HTTP requests as the user types in the text input. The only problem I'm having is that when the user gets to a space in between first and last names, the space is not en...

What is the point of the diamond operator (<>) in Java 7?

The diamond operator in java 7 allows code like the following: List<String> list = new LinkedList<>(); However in Java 5/6, I can simply write: List<String> list = new LinkedList(); My understanding of type erasure is that the...

How to export table data in MySql Workbench to csv?

I am wondering how do I export table data into a csv? I read that I need to use mysql workbench command line but I can not figure out how to launch the cmd line(don't know what the command is). Running on Windows 7 64bit....

Read file line by line using ifstream in C++

The contents of file.txt are: 5 3 6 4 7 1 10 5 11 6 12 3 12 4 Where 5 3 is a coordinate pair. How do I process this data line by line in C++? I am able to get the first line, but how do I get the next line of the file? ifstream myfile; myfile.open (...

Chrome refuses to execute an AJAX script due to wrong MIME type

I'm trying to access a script as JSON via AJAX, which works fine on Safari and other browsers but unfortunately will not execute in Chrome. It's coming with the following error: Refused to execute script from '*' because its MIME type ('applicati...

Cannot use mkdir in home directory: permission denied (Linux Lubuntu)

I am trying to create a directory in my home directory on Linux using the mkdir command, but am getting a 'permission denied' error. I have recently installed Lubuntu on my laptop, and have the only user profile on the computer. Here's what happene...

How to use Greek symbols in ggplot2?

My categories need to be named with Greek letters. I am using ggplot2, and it works beautifully with the data. Unfortunately I cannot figure out how to put those greek symbols on the x axis (at the tick marks) and also make them appear in the legen...

Import SQL file into mysql

I have a database called nitm. I haven't created any tables there. But I have a SQL file which contains all the necessary data for the database. The file is nitm.sql which is in C:\ drive. This file has size of about 103 MB. I am using wamp server. ...

How to add a new line in textarea element?

I want to add a newline in a textarea. I tried with \n and <br/> tag but are not working. You can see above the HTML code. Can you help me to insert a newline in a textarea? <textarea cols='60' rows='8'>This is my statement one.\n This is...

What is the difference between properties and attributes in HTML?

After the changes made in jQuery 1.6.1, I have been trying to define the difference between properties and attributes in HTML. Looking at the list on the jQuery 1.6.1 release notes (near the bottom), it seems one can classify HTML properties and att...

Android WSDL/SOAP service client

I have some web services that uses WSDL/SOAP for communication. Specifically, I am using PHP and Nusoap to make them. How can I use these web services on Android? I am going to get a new Android phone soon, so I need to know. It is easy to do it wi...

How to create a stopwatch using JavaScript?

if(stopwatch >= track[song].duration) track[song].duration finds the duration of a soundcloud track. I am looking to create a stopwatch function that starts counting milliseconds when you click on the swap ID stopwatch so that when the function...

DateTime.Now.ToShortDateString(); replace month and day

I need to change format of this.TextBox3.Text = DateTime.Now.ToShortDateString(); so it returns (for example) 25.02.2012, but I need 02.25.2012 How can this be done?...

How do I compare two columns for equality in SQL Server?

I have two columns that are joined together on certain criteria, but I would also like to check if two other columns are identical and then return a bit field if they are. Is there a simpler solution than using CASE WHEN? Ideally I could just use: ...

Regex for string not ending with given suffix

I have not been able to find a proper regex to match any string not ending with some condition. For example, I don't want to match anything ending with an a. This matches b ab 1 This doesn't match a ba I know the regex should be ending with $ ...

Removing pip's cache?

I need to install psycopg2 v2.4.1 specifically. I accidentally did: pip install psycopg2 Instead of: pip install psycopg2==2.4.1 That installs 2.4.4 instead of the earlier version. Now even after I pip uninstall psycopg2 and attempt to rein...

How to run vbs as administrator from vbs?

Can anyone help me with running vbs from itself but with administrator rights? I need rename computer with Windows 8 via VBScript, but it's possible only if I run my script through administrator command line (CMD → Run as Administrator...

How to access the first property of a Javascript object?

Is there an elegant way to access the first property of an object... where you don't know the name of your properties without using a loop like for .. in or jQuery's $.each For example, I need to access foo1 object without knowing the name of foo...

How to change the datetime format in pandas

My dataframe has a DOB column (example format 1/1/2016) which by default gets converted to pandas dtype 'object': DOB object Converting this to date format with df['DOB'] = pd.to_datetime(df['DOB']), the date gets converted to: 2016-01-26 and its ...

Build a simple HTTP server in C

I need to build a simple HTTP server in C. Any guidance? Links? Samples?...

Undo a particular commit in Git that's been pushed to remote repos

What is the simplest way to undo a particular commit that is: not in the head or HEAD Has been pushed to the remote. Because if it is not the latest commit, git reset HEAD doesn't work. And because it has been pushed to a remote, git rebase ...

How to integrate SAP Crystal Reports in Visual Studio 2017

Is it possible to use the report designer in the current release of Visual Studio 2017? The SAP crystal report wiki for visual studio integration only states: "RC build currently not supported - Tested opening existing app and it works". I ...

How to check if a Constraint exists in Sql server?

I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some other databases we use, the constraint has a different name. How do I check if there's a constraint with the name FK_Cha...

How do I "decompile" Java class files?

What program can I use to decompile a class file? Will I actually get Java code, or is it just JVM assembly code? On Java performance questions on this site I often see responses from people who have "decompiled" the Java class file to see how the c...

Create a table without a header in Markdown

Is it possible to create a table without a header in Markdown? The HTML would look like this: <table> <tr> <td>Key 1</td> <td>Value 1</td> </tr> <tr> <td>Key 2</td> <td&...

Forbidden You don't have permission to access /wp-login.php on this server

I have one problem with all my WordPress's sites. I can access in all and navigate in the posts, pages and other. But when I go to wp-login.php I view the form and put user and password. And when I clicking access goes here: Forbidden You don't have...

Error message "No exports were found that match the constraint contract name"

This morning I faced a problem while opening my Visual Studio solution, and when I tried to run it, it said: No exports were found that match the constraint contract name How can I fix this problem?...

How do I connect to a terminal to a serial-to-USB device on Ubuntu 10.10 (Maverick Meerkat)?

I am trying to connect minicom to a serial device that is connected via a USB-to-serial adapter. This is a PL2303 and from everything I've read no additional drivers are required. The device is recognised as a PL2303. I'm a beginner at minicom. Is t...

iframe refuses to display

I am trying to load a simple iframe into one of my web pages but it is not displaying. I am getting this error in Chrome: Refused to display 'https://cw.na1.hgncloud.com/crossmatch/index.do' in a frame because an ancestor violates the following Con...

multiprocessing.Pool: When to use apply, apply_async or map?

I have not seen clear examples with use-cases for Pool.apply, Pool.apply_async and Pool.map. I am mainly using Pool.map; what are the advantages of others?...

How to add data to DataGridView

I'm having a Structure like X={ID="1", Name="XX", ID="2", Name="YY" }; How to dump this data to a DataGridView of two columns The gridView is like ID | Name Can we use LINQ to do this. I'm new to DataGridView Pleaese help me to do thi...

Check file extension in upload form in PHP

I check the file extension for upload or not uploaded. My example methods worked, but now I need to understand if my methods (using pathinfo) is true. Is there another better and faster way? $filename = $_FILES['video_file']['name']; $ext = pathinfo...

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

Configuring so that pip install can work from github

We'd like to use pip with github to install private packages to our production servers. This question concerns what needs to be in the github repo in order for the install to be successful. Assuming the following command line (which authenticates j...

Why do I get a "Null value was assigned to a property of primitive type setter of" error message when using HibernateCriteriaBuilder in Grails

I get the following error when using a primitive attribute in my grails domain object: Null value was assigned to a property of primitive type setter of MyDomain.myAttribute org.hibernate.PropertyAccessException: Null value was assigned to a proper...

Inserting HTML elements with JavaScript

Instead of tediously search for workarounds for each type of attribute and event when using the following syntax: elem = document.createElement("div"); elem.id = 'myID'; elem.innerHTML = ' my Text ' document.body.insertBefore(elem,document.body.chil...

how to concat two columns into one with the existing column name in mysql?

I want to concatenate two columns in a table with a existing column name using mysql. An example: I am having a column FIRSTNAME and LASTNAME and so many columns also. I want to concatenate these two columns with the name of FIRSTNAME only. So I t...

Can't change table design in SQL Server 2008

I created a table tbl_Candidate, but I forgot to set the primary key to the table and I saved it without primary key. Next time I'm going to set primary key in SQL Server 2008 Express, I get a message like I have to drop the table and recreate when ...

How to convert DateTime to a number with a precision greater than days in T-SQL?

Both queries below translates to the same number SELECT CONVERT(bigint,CONVERT(datetime,'2009-06-15 15:00:00')) SELECT CAST(CONVERT(datetime,'2009-06-15 23:01:00') as bigint) Result 39978 39978 The generated number will be different only if the...

How to get maximum value from the Collection (for example ArrayList)?

There is an ArrayList which stores integer values. I need to find the maximum value in this list. E.g. suppose the arrayList stored values are : 10, 20, 30, 40, 50 and the max value would be 50. What is the efficient way to find the maximum value? ...

What is the canonical way to trim a string in Ruby without creating a new string?

This is what I have now - which looks too verbose for the work it is doing. @title = tokens[Title].strip! || tokens[Title] if !tokens[Title].nil? Assume tokens is a array obtained by splitting a CSV line. now the functions like strip! chomp...

Twitter Bootstrap 3.0 how do I "badge badge-important" now

In version two I could use badge badge-important I see that the .badge element no longer has contextual (-success,-primary,etc..) classes. How do i achieve the same thing in version 3? Eg. I want warning badges and important badges in my UI...

What linux shell command returns a part of a string?

I want to find a linux command that can return a part of the string. In most programming languages, it's the substr() function. Does bash have any command that can be used for this purpose. I want to be able to do something like this... substr "abcde...

Installing specific package versions with pip

I'm trying to install version 1.2.2 of the MySQL_python adaptor, using a fresh virtualenv created with the --no-site-packages option. The current version shown in PyPi is 1.2.3. Is there a way to install the older version? I found an article stating ...

need to test if sql query was successful

I have this query and if it returns successful, I want another function to process, if not, do not process that function. Here is the code for running the query global $DB; $DB->query("UPDATE exp_members SET group_id = '$group_id' WHERE member_i...

how to add new <li> to <ul> onclick with javascript

How do I add a list element to an existing ul using a function from an onclick? I need it to add to this type of list ... <ul id="list"> <li id="element1">One</li> <li id="element2">Two</li> <li id="element3">Thre...

Map.Entry: How to use it?

I'm working on creating a calculator. I put my buttons in a HashMap collection and when I want to add them to my class, which extends JPanel, I don't know how can I get the buttons from my collection. So I found on the internet the 2 last lines of my...

How can I count the number of elements of a given value in a matrix?

Does anyone know how to count the number of times a value appears in a matrix? For example, if I have a 1500 x 1 matrix M (vector) which stores the values of weekdays (1 - 7), how could I count how many Sundays (1), Mondays(2), ... , Saturdays(7) ar...

bootstrap 4 row height

I try to have something like this with bootstrap 4 with equal size in the height of green rows and red row _x000D_ _x000D_ <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" rel="stylesheet"/>...

Jackson JSON: get node name from json-tree

How can I receive the node names from a JSON tree using Jackson? The JSON-File looks something like this: { node1:"value1", node2:"value2", node3:{ node3.1:"value3.1", node3.2:"value3.2" } } I have JsonNode roo...

Can't push to the heroku

I was pushing the current git repository into the heroku. That online application was developed using Scala and IntelliJ. And I don't know how to fix this error. $ git push heroku master Counting objects: 3, done. Delta compression using up to 4 thr...

How are Anonymous inner classes used in Java?

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

How to copy files from 'assets' folder to sdcard?

I have a few files in the assets folder. I need to copy all of them to a folder say /sdcard/folder. I want to do this from within a thread. How do I do it? ...

SQL select statements with multiple tables

Given the following two tables: Person table id (pk) first middle last age Address table id(pk) person_id (fk person.id) street city state zip How do I create an SQL statement that returns all information for people with zip code 97229...

gcc error: wrong ELF class: ELFCLASS64

I was trying to compile a program using an external compiled object coreset.o. I wrote the public01.c test file and my functions are in computation.c, both of which compiles. However its failing on linking it together. What might be the problem? ...

Change private static final field using Java reflection

I have a class with a private static final field that, unfortunately, I need to change it at run-time. Using reflection I get this error: java.lang.IllegalAccessException: Can not set static final boolean field Is there any way to change the value?...

How to extract the n-th elements from a list of tuples?

I'm trying to obtain the n-th elements from a list of tuples. I have something like: elements = [(1,1,1),(2,3,7),(3,5,10)] I wish to extract only the second elements of each tuple into a list: seconds = [1, 3, 5] I know that it could be done w...

How to name variables on the fly?

Is it possible to create new variable names on the fly? I'd like to read data frames from a list into new variables with numbers at the end. Something like orca1, orca2, orca3... If I try something like paste("orca",i,sep="")=list_name[[i]] I ge...

Hyper-V: Create shared folder between host and guest with internal network

Set up: Host: Windows 10 Enterprise Guest: Windows 10 Professional Hypervisor: Hyper-V Aim: Create a shared folder between Host and Guest via an internal network to exchange files How can I achieve this?...

How to fix java.net.SocketException: Broken pipe?

I am using apache commons http client to call url using post method to post the parameters and it is throwing the below error rarely. java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) a...

How to place a JButton at a desired location in a JFrame using Java

I want to put a Jbutton on a particular coordinate in a JFrame. I put setBounds for the JPanel (which I placed on the JFrame) and also setBounds for the JButton. However, they dont seem to function as expected. My Output: This is my code: impor...

HTML Input Type Date, Open Calendar by default

I have a task which is to show the calendar by default to select date in the input field of html. For suppose this is the code: input type="date" name="bday" Ok, now when I click on the input box, the calendar appears. Tell me how to show the ca...

Replace string within file contents

How can I open a file, Stud.txt, and then replace any occurences of "A" with "Orange"?...

How to delete columns in a CSV file?

I have been able to create a csv with python using the input from several users on this site and I wish to express my gratitude for your posts. I am now stumped and will post my first question. My input.csv looks like this: day,month,year,lat,long...

Is it possible to open a Windows Explorer window from PowerShell?

I'm sure this must be possible, but I can't find out how to do it. Any clues?...

Lazy Method for Reading Big File in Python?

I have a very big file 4GB and when I try to read it my computer hangs. So I want to read it piece by piece and after processing each piece store the processed piece into another file and read next piece. Is there any method to yield these pieces ? ...

Static linking vs dynamic linking

Are there any compelling performance reasons to choose static linking over dynamic linking or vice versa in certain situations? I've heard or read the following, but I don't know enough on the subject to vouch for its veracity. 1) The difference in ...

array filter in python?

For example, I have two lists A = [6, 7, 8, 9, 10, 11, 12] subset_of_A = [6, 9, 12]; # the subset of A the result should be [7, 8, 10, 11]; the remaining elements Is there a built-in function in python to do this?...

How do I write a bash script to restart a process if it dies?

I have a python script that'll be checking a queue and performing an action on each item: # checkqueue.py while True: check_queue() do_something() How do I write a bash script that will check if it's running, and if not, start it. Roughly the...

Spring Bean Scopes

Can someone explain what the scopes are in Spring beans I've always just used 'prototype' but are there other parameters I can put in place of that? Example of what I'm talking about <bean id="customerInfoController" class="com.action.Controller...

Git - Undo pushed commits

I have a project in a remote repository, synchronized with a local repository (development) and the server one (prod). I've been making some commited changes already pushed to remote and pulled from the server. Now, I want to undo those changes. So I...

simple Jquery hover enlarge

I'm not sure where I'm going wrong. I'm trying to create a very simple hover-enlarge plugin with Jquery using the scale function. Here is my code: $(document).ready(function(){ $("#content img").toggle("scale",{ percent: "80%" },0); $(...

Get DateTime.Now with milliseconds precision

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

Getting Error - ORA-01858: a non-numeric character was found where a numeric was expected

I am getting the error in the below sql: ORA-01858: a non-numeric character was found where a numeric was expected SELECT c.contract_num, CASE WHEN ( MAX (TO_CHAR (TO_DATE (c.event_dt, 'YYYY-MM-DD'), 'MMDD')) ...

When to choose mouseover() and hover() function?

What are the differences between jQuery .mouseover() and .hover() functions? If they are totally same why jQuery uses both?...

How to check if a stored procedure exists before creating it

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

Why am I getting "IndentationError: expected an indented block"?

if len(trashed_files) == 0 : print "No files trashed from current dir ('%s')" % os.path.realpath(os.curdir) else : index=raw_input("What file to restore [0..%d]: " % (len(trashed_files)-1)) if index == "*" : for tfile in trashed_f...

Adding :default => true to boolean in existing Rails column

I've seen a few questions (namely this one) here on SO about adding a default boolean value to an existing column. So I tried the change_column suggestion but I mustn't be doing it right. I tried: $ change_column :profiles, :show_attribute, :boolea...

java.util.Date format conversion yyyy-mm-dd to mm-dd-yyyy

I have a java.util.Date in the format yyyy-mm-dd. I want it to be in the format mm-dd-yyyy Below is the sample util I tried out for this conversion: // Setting the pattern SimpleDateFormat sm = new SimpleDateFormat("mm-dd-yyyy"); // myDate ...

Gradle Sync failed could not find constraint-layout:1.0.0-alpha2

Problem : Error:Could not find com.android.support.constraint:constraint-layout:1.0.0-alpha2. Required by: myapp:app:unspecified Background : Android Studio 2.2 P 1...

Background blur with CSS

I want an Vista/7-aero-glass-style effect on a popup on my site, and it needs to be dynamic. I'm fine with this not being a cross-browser effect as long as the site still works on all modern browsers. My first attempt was to use something like #dia...

INSERT INTO from two different server database

I am trying to copy the data of testdabse.invoice table to basecampdev.invoice table. testdabse is a local database while basecampdev is in the server. My query for copying data to another table doesn't work, it says Invalid object name 'basecam...

Convert hex string (char []) to int?

I have a char[] that contains a value such as "0x1800785" but the function I want to give the value to requires an int, how can I convert this to an int? I have searched around but cannot find an answer. Thanks....

PySpark: withColumn() with two conditions and three outcomes

I am working with Spark and PySpark. I am trying to achieve the result equivalent to the following pseudocode: df = df.withColumn('new_column', IF fruit1 == fruit2 THEN 1, ELSE 0. IF fruit1 IS NULL OR fruit2 IS NULL 3.) I am trying to do this...