Questions Tagged with #Physics

Refers to real-world physics. For simulation of physics in games use the [game-physics] tag instead, for questions using an existing physics engine use [physics-engine]. Physics is a science that studies the interactions of energy and matter. Questions with this tag concern the simulation or implementation of real-world physics concepts in programming.

Unity 2d jumping script

Does anyone have a good jumping script for 2d games in unity? The code I have works but still is far from jumping, it looks like it is flying. using UnityEngine; using System.Collections; public cla..

Heap space out of memory

My application currently consumes quite a lot of memory because it is running physics simulations. The issue is that consistently, at the 51st simulation, Java will throw an error usually because of a..

Ball to Ball Collision - Detection and Handling

With the help of the Stack Overflow community I've written a pretty basic-but fun physics simulator. You click and drag the mouse to launch a ball. It will bounce around and eventually stop on the..

What is the meaning of polyfills in HTML5?

What is the meaning of polyfills in HTML5? I saw this word in many sites about HTML5, e.g. HTML5-Cross-Browser-Polyfills. So here we're collecting all the shims, fallbacks, and polyfills in orde..

CSS - make div's inherit a height

I'm trying to make a box with rounded corners where the height and width of the div depends on the content, so it's automatically adjust to it... You can see the example here:

css label width not taking effect

I have a generic form, which I'd like to style to align the labels and the input fields. For some reason when I give a width to the label selector, nothing happens: HTML: <form id="report-uplo..

Fast way to get the min/max values among properties of object

I have an object in javascript like this: { "a":4, "b":0.5 , "c":0.35, "d":5 } Is there a fast way to get the minimum and maximum value among the properties without having to loop through them all?..

How can I check the syntax of Python script without executing it?

I used to use perl -c programfile to check the syntax of a Perl program and then exit without executing it. Is there an equivalent way to do this for a Python script?..

Deep-Learning Nan loss reasons

Perhaps too general a question, but can anyone explain what would cause a Convolutional Neural Network to diverge? Specifics: I am using Tensorflow's iris_training model with some of my own data and k..

Iterate through <select> options

I have a <select> element in HTML. This element represents a drop down list. I'm trying to understand how to iterate through the options in the <select> element via JQuery. How do I use J..

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

Counting inversions in an array

I'm designing an algorithm to do the following: Given array A[1... n], for every i < j, find all inversion pairs such that A[i] > A[j]. I'm using merge sort and copying array A to array B and th..

Core dumped, but core file is not in the current directory?

While running a C program, It says "(core dumped)" but I can't see any files under the current path. I have set and verified the ulimit: ulimit -c unlimited ulimit -a I also tried to find a file..

Loop over array dimension in plpgsql

In plpgsql, I want to get the array contents one by one from a two dimension array. DECLARE m varchar[]; arr varchar[][] := array[['key1','val1'],['key2','val2']]; BEGIN for m in select arr L..

Is there an equivalent method to C's scanf in Java?

Java has the notion of format strings, bearing a strong resemblance to format strings in other languages. It is used in JDK methods like String#format() for output conversion. I was wondering if ther..

Delete last char of string

I am retrieving a lot of information in a list, linked to a database and I want to create a string of groups, for someone who is connected to the website. I use this to test but this is not dynamic, ..

Structs in Javascript

Previously, when I needed to store a number of related variables, I'd create a class. function Item(id, speaker, country) { = id; this.speaker = spkr; = country; } va..

HTML - Arabic Support

i have a website in which i have to put some lines in Arabic.... how to do it... where to get the Arabic text characters... how to make the page support Arabic... i have to put a line per page and t..

MySQL/SQL: Group by date only on a Datetime column

Having a table with a column like: mydate DATETIME ... I have a query such as: SELECT SUM(foo), mydate FROM a_table GROUP BY a_table.mydate; This will group by the full datetime, including hours a..

Resolving PKIX path building failed Error?

Edit :- Tried to format the question and accepted answer in more presentable way at mine Blog Here is the original issue. I am getting this error: detailed message

TypeError: 'NoneType' object has no attribute '__getitem__'

I'm having an issue and I have no idea why this is happening and how to fix it. I'm working on developing a Videogame with python and pygame and I'm getting this error: File "/home/matt/Smoking-Gam..

How to run iPhone emulator WITHOUT starting Xcode?

On my old Mac running Snow Leopard, I could type "ios" into spotlight and it would start up the iPhone/iPad emulator by itself. I have since had to get a new machine running Lion. I have installed Xc..

How to output in CLI during execution of PHP Unit tests?

When running a PHPUnit test, I would like to be able to dump output so I can debug one or two things. I have tried the following (similar to the PHPUnit Manual example); class theTest extends PHPUni..

How do I apply a diff patch on Windows?

There are plenty of programs out there that can create a diff patch, but I'm having a heck of a time trying to apply one. I'm trying to distribute a patch, and I got a question from a user about how t..

What is the use of the JavaScript 'bind' method?

What is the use of bind() in JavaScript?..

Getting new Twitter API consumer and secret keys

I am working on a Twitter project where I want to use OAuth but I don't know where to get the consumer and secret keys. How can I get these?..

Differences between cookies and sessions?

I am training in web developement and am learning about JSP & Servlets. I have some knowledge of HttpSession - I have used it in some of my sample projects. In browsers I have seen the option to ..

MySQL Error 1215: Cannot add foreign key constraint

I am trying to forward engineer my new schema onto my db server, but I can't figure out why I am getting this error. I've tried to search for the answer here, but everything I've found has said to ei..

How to print out all the elements of a List in Java?

I am trying to print out all the elements of a List, however it is printing the pointer of the Object rather than the value. This is my printing code... for(int i=0;i<list.size();i++){ System..

How to convert SecureString to System.String?

All reservations about unsecuring your SecureString by creating a System.String out of it aside, how can it be done? How can I convert an ordinary System.Security.SecureString to System.String? I'm ..

Increase heap size in Java

I am working on a Windows 2003 server (64-bit) with 8 GB RAM. How can I increase the heap memory maximum? I am using the -Xmx1500m flag to increase the heap size to 1500 Mb. Can I increase the heap me..

TypeError: p.easing[this.easing] is not a function

When trying to show a div element with jQuery, i got this error: [23:50:35.971] TypeError: p.easing[this.easing] is not a function @ file:///D:/html5%20puzzle/jquery.js:2 The relevant function is t..

How to store arbitrary data for some HTML tags

I'm making a page which has some interaction provided by javascript. Just as an example: links which send an AJAX request to get the content of articles and then display that data in a div. Obviously ..

How to fix: "You need to use a Theme.AppCompat theme (or descendant) with this activity"

I am having trouble running my Android app in a fullscreen mode per instructions of a video. When it tries to run, the app crashes with the error. "You need to use a Theme.AppCompat theme (or descend..

Create a string with n characters

Is there a way in java to create a string with a specified number of a specified character? In my case, I would need to create a string with 10 spaces. My current code is: StringBuffer outputBuffer..

pandas read_csv and filter columns with usecols

I have a csv file which isn't coming in correctly with pandas.read_csv when I filter the columns with usecols and use multiple indexes. import pandas as pd csv = r"""dummy,date,loc,x bar,2009010..

Why does calling sumr on a stream with 50 tuples not complete

While investigating a bug today, I noticed that calling sumr on a stream with 50 (Int, Int) tuples never completes, but it does on a smaller stream. Calling .toList on the larger stream first complete..

How to print out the method name and line number and conditionally disable NSLog?

I'm doing a presentation on debugging in Xcode and would like to get more information on using NSLog efficiently. In particular, I have two questions: is there a way to easily NSLog the current met..

Get skin path in Magento?

I have a few custom PHP functions for my Magento store that I stored in myfunc.php and I need to require it from in a few different .phtml files. How do I do that? I mean I can use an absolute path b..

Is there a better way to do optional function parameters in JavaScript?

I've always handled optional parameters in JavaScript like this: function myFunc(requiredArg, optionalArg){ optionalArg = optionalArg || 'defaultValue'; // Do stuff } Is there a better way to ..

What does "atomic" mean in programming?

In the Effective Java book, it states: The language specification guarantees that reading or writing a variable is atomic unless the variable is of type long or double [JLS, 17.4.7]. What d..

What programming language does facebook use?

I don't know much about programming languages, but am interested in a career with facebook, so I was wondering if someone could tell me what programming language facebook uses. Also, do any other soc..

How to reference Microsoft.Office.Interop.Excel dll?

I had developed a system that deals with excel sheets in 2006 using MS VS 2005. Now, I can not use the same reference with MS VS 2012. var app = new Microsoft.Office.Interop.Excel.Application(); Wor..

Run batch file from Java code

I am trying to run a batch file that is in another directory from my Java executable. I have the following code : try { Process p = Runtime.getRuntime().exec("cmd /c start \"C:\\Program ..

How to set custom header in Volley Request

How can custom headers be set for a Volley request? At the moment, there is way to set body content for a POST request. I've a simple GET request, but I need to pass the custom headers alongwith. I do..

How to pass data to view in Laravel?

Im passing data to my blade view with return View::make('blog', $posts); and in my blade view I'm trying to run an @foreach ($posts as $post) I end up with an error saying that $posts isn't defined. ..

SQL Server, How to set auto increment after creating a table without data loss?

I have a table table1 in SQL server 2008 and it has records in it. I want the primary key table1_Sno column to be an auto-incrementing column. Can this be done without any data transfer or cloning ..

Check if a specific value exists at a specific key in any subarray of a multidimensional array

I need to search a multidimensional array for a specific value in any of the indexed subarrays. In other words, I need to check a single column of the multidimensional array for a value. If the valu..

Validating URL in Java

I wanted to know if there is any standard APIs in Java to validate a given URL? I want to check both if the URL string is right i.e. the given protocol is valid and then to check if a connection can b..

textarea character limit

I would like to be able to limit the number of characters in a textarea. The method I am using works great in Google Chrome, but is slow in Firefox, and doesn't work in IE. Javascript: function len(..

python exception message capturing

import ftplib import urllib2 import os import logging logger = logging.getLogger('ftpuploader') hdlr = logging.FileHandler('ftplog.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(mess..

How to add an item to an ArrayList in Kotlin?

How to add an item to an ArrayList in Kotlin?..

Best way to convert strings to symbols in hash

What's the (fastest/cleanest/straightforward) way to convert all keys in a hash from strings to symbols in Ruby? This would be handy when parsing YAML. my_hash = YAML.load_file('yml') I'd like to ..

estimating of testing effort as a percentage of development time

Does anyone use a rule of thumb basis to estimate the effort required for testing as a percentage of the effort required for development? And if so what percentage do you use?..

JQuery window scrolling event?

I have an ad in my header and a fixed ad at the bottom of my page that is always there. I want the fixed ad to appear only if the user has scrolled under the header ad. I looked into the JQuery docume..

How to calculate percentage when old value is ZERO

I need the logic for the following situation. I am clueless in doing this. Consider for January I have 10$ revenue and for February I have 20$ revenue. My growth would be ((20-10)/10)*100% = 100..

Interview Question: Merge two sorted singly linked lists without creating new nodes

This is a programming question asked during a written test for an interview. "You have two singly linked lists that are already sorted, you have to merge them and return a the head of the new list wi..

How to display and hide a div with CSS?

In my script there are three divs. I want to display div with class="ab" when I hover on first line and display div with class="abc", when hover on second line. Otherwise I want to display div with cl..

What does the SQL Server Error "String Data, Right Truncation" mean and how do I fix it?

We are doing some performance tests on our website and we are getting the following error a lot: *** 'C:\inetpub\foo.plex' log message at: 2008/10/07 13:19:58 DBD::ODBC::st execute failed: [Microsoft..

jQuery attr('onclick')

I'am trying to change "onclick" attribute in jQuery but it doesn't change, here is my code: $('#stop').click(function() { $('next').attr('onclick','stopMoving()'); } I have an element with id=..

Add multiple items to already initialized arraylist in java

I'm googling it and can't seem to find the syntax. My arraylist might be populated differently based on a user setting, so I've initialized it ArrayList<Integer> arList = new ArrayList<Integ..

Multi-statement Table Valued Function vs Inline Table Valued Function

A few examples to show, just incase: Inline Table Valued CREATE FUNCTION MyNS.GetUnshippedOrders() RETURNS TABLE AS RETURN SELECT a.SaleId, a.CustomerID, b.Qty FROM Sales.Sales a INNER JOIN Sal..

In DB2 Display a table's definition

Hello everybody I am learning DB2 and would like to know how to see a table's characteristics after I create one. Similar to the EXPLAIN TABLE command in MySQL. Thank you...

htaccess remove index.php from url

I have a problem whereby google has indexed some pages with the wrong url. The url they are indexing is: I need it to redirect to: http://www.ex..

How do I rename the android package name?

Pressing Shift+F6 seems only to rename the last directory. For example, in the project com.example.test it will offer to rename test only. The same applies if I navigate to package name in .java or Ma..

What's the difference between a Python module and a Python package?

What's the difference between a Python module and a Python package? See also: What's the difference between "package" and "module" (for other languages)..

MsgBox "" vs MsgBox() in VBScript

I'm trying to write a VBScript and I'm using functions such as Randomize, and MsgBox. I'm curious as to what is the difference of using () and not using them. For example: Randomize - This line works..

Tensorflow import error: No module named 'tensorflow'

I installed TensorFlow on my Windows Python 3.5 Anaconda environment The validation was successful (with a warning) (tensorflow) C:\>python Python 3.5.3 |Intel Corporation| (default, Apr 27 2017..

How to trigger click event on href element

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

what is the difference between XSD and WSDL

What is the difference between an XML Schema and WSDL? The difference I noticed is that WSDL contains XSD and in WSDL we can declare operations, but not in XSD. Is that correct?..

How to change FontSize By JavaScript?

This code is not working var span = document.getElementById("span"); = "25px"; span.innerHTML = "String"; ..

How do you get an iPhone's device name

If you open Settings -> General -> About, it'll say Bob's iPhone at the top of the screen. How do you programmatically grab that name?..

Why is Spring's ApplicationContext.getBean considered bad?

I asked a general Spring question: Auto-cast Spring Beans and had multiple people respond that calling Spring's ApplicationContext.getBean() should be avoided as much as possible. Why is that? How..

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

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

What JSON library to use in Scala?

I need to build a JSON string, something like this: [ { 'id': 1, 'name': 'John'}, { 'id': 2, 'name': 'Dani'} ] val jArray = JsArray(); jArray += (("id", "1"), ("name", "John")) jArray += (("id",..

Angular: date filter adds timezone, how to output UTC?

I'm using the date filter to render a unix timestamp in a certain format. I've noticed the filter adds the local timezone to the output. Is there any way to simply output the exact timestamp, without..

Throwing exceptions from constructors

I'm having a debate with a co-worker about throwing exceptions from constructors, and thought I would like some feedback. Is it OK to throw exceptions from constructors, from a design point of view? ..

Messagebox with input field

Is it possible to show (pop-up) a message box with an input field in it, possibly a text box? Is somewhere in the language or the framework?..

What is the difference between join and merge in Pandas?

Suppose I have two DataFrames like so: left = pd.DataFrame({'key1': ['foo', 'bar'], 'lval': [1, 2]}) right = pd.DataFrame({'key2': ['foo', 'bar'], 'rval': [4, 5]}) I want to merge them, so I try s..

How to detect if a browser is Chrome using jQuery?

I have a bit of an issue with a function running in chrome that works properly in Safari, both webkit browsers... I need to customize a variable in a function for Chrome, but not for Safari. Sadly, ..

Qt: How do I handle the event of the user pressing the 'X' (close) button?

I am developing an application using Qt. I don't know which slot corresponds to the event of "the user clicking the 'X'(close) button of the window frame" i.e. this button: If there isn't a slot fo..

Convert seconds to HH-MM-SS with JavaScript?

How can I convert seconds to an HH-MM-SS string using JavaScript?..

session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium

I'm trying to run RSelenium using the rsDriver function, but when I run rD <- rsDriver() I get a message telling me I need a newer version of Chrome: > rD <- rsDriver() checking Selenium ..

Dart SDK is not configured

I installed Flutter and set up Android Studio. Then I cloned an example of flutter on GitHub ( and launched it in Android Studio, but it warns me "Dart SDK is n..

Python: import cx_Oracle ImportError: No module named cx_Oracle error is thown

I try to write a script in .py for oracle connectivity: #!/usr/bin/python import cx_Oracle connstr='username/pwd@database' conn = cx_Oracle.connect(connstr) curs = conn.cursor() curs.execute('sele..

Display a view from another controller in ASP.NET MVC

Is it possible to display a view from another controller? Say for example I have a CategoriesController and a Category/NotFound.aspx view. While in the CategoriesController, I can easly return View("..

How to use an existing database with an Android application

I have already created an SQLite database. I want to use this database file with my Android project. I want to bundle this database with my application. Instead of creating a new database, how can t..

Default values for Vue component props & how to check if a user did not set the prop?

1. How can I set the default value for a component prop in Vue 2? For example, there is a simple movies component that can be used in this way: <movies year="2016"><movies> Vue.compone..

Looking for simple Java in-memory cache

I'm looking for a simple Java in-memory cache that has good concurrency (so LinkedHashMap isn't good enough), and which can be serialized to disk periodically. One feature I need, but which has prove..

Runnable with a parameter?

I have a need for a "Runnable that accepts a parameter" although I know that such runnable doesn't really exist. This may point to fundamental flaw in the design of my app and/or a mental block in my..

When do I need to do "git pull", before or after "git add, git commit"?

What is the right way? git add foo.js git commit foo.js -m "commit" git pull git push Or git pull git add foo.js git commit foo.js -m "commit" git push Or git add foo.js git pull git commit foo..

How do I deal with special characters like \^$.?*|+()[{ in my regex?

I want to match a regular expression special character, \^$.?*|+()[{. I tried: x <- "a[b" grepl("[", x) ## Error: invalid regular expression '[', reason 'Missing ']'' (Equivalently stringr::str..

Is it possible to set the equivalent of a src attribute of an img tag in CSS?

Is it possible to set the src attribute value in CSS? At present, what I am doing is: <img src="pathTo/myImage.jpg"/> and I want it to be something like this <img class="myClass"/> ...

git discard all changes and pull from upstream

How do I fetch upstream repo and make it replace master? I only have one branch on my repo, which is master, and I completely messed it up, so I basically need to start over from the upstream. I think..

Histogram Matplotlib

So I have a little problem. I have a data set in scipy that is already in the histogram format, so I have the center of the bins and the number of events per bin. How can I now plot is as a histogram...

Why am I getting error for apple-touch-icon-precomposed.png

I have created a new rails3 project but I am seeing following logs many times in my server logs. Why I am getting these request and how can I avoid these? Started GET "/apple-touch-icon-precompose..

Converting Columns into rows with their respective data in sql server

I have a scenario where I need to convert columns of table to rows eg - table - stocks: ScripName ScripCode Price ----------------------------------------- 20 MICRONS 533022 ..

How do you performance test JavaScript code?

CPU Cycles, Memory Usage, Execution Time, etc.? Added: Is there a quantitative way of testing performance in JavaScript besides just perception of how fast the code runs?..

Automatic date update in a cell when another cell's value changes (as calculated by a formula)

I have a formula in C2, say =A2+B2. Whenever C2 changes value (actual value, not formula) I want to have the present date and time updated in D2. I have tried a lot of VBA codes and tricks and none o..

Remove the newline character in a list read from a file

I have a simple program that takes an ID number and prints information for the person matching the ID. The information is stored in a .dat file, with one ID number per line. The problem is that my pr..

Return values from the row above to the current row

I am trying to do simple thing: I just need to set some cells to values that are on the previous rows. I have tried =A(Row()-1) but it does not work...

SQL Server find and replace specific word in all rows of specific column

I have a table TblKit that has columns Id and Number. Id is primary key of type int and Number is varchar(50). The data in the table looks like this: Id Number --- ------ 1 KIT001 2 K..

How to get a list of column names on Sqlite3 database?

I want to migrate my iPhone app to a new database version. Since I don't have some version saved, I need to check if certain column names exist. This Stackoverflow entry suggests doing the select SE..

Trim specific character from a string

What's the JavaScript equivalent to this C# Method: var x = "|f|oo||"; var y = x.Trim('|'); // "f|oo" C# trims the selected character only at the beginning and end of the string!..

Convert spark DataFrame column to python list

I work on a dataframe with two column, mvv and count. +---+-----+ |mvv|count| +---+-----+ | 1 | 5 | | 2 | 9 | | 3 | 3 | | 4 | 1 | i would like to obtain two list containing mvv values and c..

How do I remove carriage returns with Ruby?

I thought this code would work, but the regular expression doesn't ever match the \r\n. I have viewed the data I am reading in a hex editor and verified there really is a hex D and hex A pattern in th..

Proper way to exit iPhone application?

I am programming an iPhone app, and I need to force it to exit due to certain user actions. After cleaning up memory the app allocated, what's the appropriate method to call to terminate the applicat..

Can a java lambda have more than 1 parameter?

In Java, is it possible to have a lambda accept multiple different types? I.e: Single variable works: Function <Integer, Integer> adder = i -> i + 1; System.out.println (adder.apply..

assigning column names to a pandas series

I have a pandas series object x Ezh2 2 Hmgb 7 Irf1 1 I want to save this as a dataframe with column names Gene and Count respectively I tried x_df = pd.DataFrame(x,columns = ['Gene','count..

Export pictures from excel file into jpg using VBA

I have an Excel file which includes pictures in column B and I want like to export them into several files as .jpg (or any other picture file format). The name of the file should be generated from tex..

How to find pg_config path

Complete newbie here, trying to set up Django to work with PostgreSQL. I'm using mac osx 10.6.8. I have also installed PostgreSQL 9.3 When I run pip install psycopg2 in terminal I get the following..

How to use Python's pip to download and keep the zipped files for a package?

If I want to use the pip command to download a package (and its dependencies), but keep all of the zipped files that get downloaded (say, django-socialregistration.tar.gz) - is there a way to do that?..

How to load specific image from assets with Swift

I'm new to Swift and I want to load a special image from assets. For example I have: image 1 for iphone 4s = [email protected] image 2 for iphone 5/5s = [email protected] image 3 for iphon..

tmux set -g mouse-mode on doesn't work

I've been looking around and people say that putting set -g mouse-mode on should let you scroll through the terminal output when running tmux. However, after both putting this in my ~/.tmux.conf f..

Android basics: running code in the UI thread

In the viewpoint of running code in the UI thread, is there any difference between: MainActivity.this.runOnUiThread(new Runnable() { public void run() { Log.d("UI thread", "I am the UI th..

npm can't find package.json

I'm trying to install the dependencies of some example: npm's express 2.5.8 that I've downloaded, but all of the apps throw the same error: c:\node\stylus>npm install -d npm info it worked if it e..

How do I change Bootstrap 3's glyphicons to white?

I've got the glyphicons in my page, but they are black. How do I set the glyphicons to white?..

Resource interpreted as Document but transferred with MIME type application/zip

With Chrome 12.0.742.112, if I redirect with the following headers: HTTP/1.1 302 Found Location: Content-Type: text/html; charset=utf-8 Cache-Control: no-cache..

How to get request URL in Spring Boot RestController

I am trying to get the request URL in a RestController. The RestController has multiple methods annotated with @RequestMapping for different URIs and I am wondering how I can get the absolute URL from..

How do I POST a x-www-form-urlencoded request using Fetch?

I have some parameters that I want to POST form-encoded to my server: { 'userName': '[email protected]', 'password': 'Password!', 'grant_type': 'password' } I'm sending my request (current..

Another Repeated column in mapping for entity error

Despite all of the others post, I can't find a solution for this error with GlassFish, on MacOSX, NetBeans 7.2. Here the error : SEVERE: Exception while invoking class org.glassfish.persistence.jpa.J..

Sql server - log is full due to ACTIVE_TRANSACTION

I have a very large database (50+ GB). In order to free space in my hard drive, I tried deleting old records from one of the tables . I ran the command: delete from Table1 where TheDate<'2004-01-0..

AccessDenied for ListObjects for S3 bucket when permissions are s3:*

I am getting: An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied When I try to get folder from my S3 bucket. Using this command: aws s3 cp s3://bucket-na..

Ruby Hash to array of values

I have this: hash = { "a"=>["a", "b", "c"], "b"=>["b", "c"] } and I want to get to this: [["a","b","c"],["b","c"]] This seems like it should work but it doesn't: hash.each{|key,value| val..

How to enable mbstring from php.ini?

I have real difficulties with enabling mbstring extension on my localhost. I'm using XAMPP 1.7.4, for Windows, which has PHP 5.3.5, and tried to edit my php.ini file according to the documentation a..

How to a convert a date to a number and back again in MATLAB

I have the date 1/11/2010 and use the function = date(year(A1),month(A1),day(A1)) to convert the date to the number to 40189 with Excel. Can I use MATLAB to convert the number 40189 back to the ..

dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib with anything php related

Using any php application results in: dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib Referenced from: /usr/local/bin/php Reason: image not found [1] 4494 trace trap php Most of my p..

Remove all child elements of a DOM node in JavaScript

How would I go about removing all of the child elements of a DOM node in JavaScript? Say I have the following (ugly) HTML: <p id="foo"> <span>hello</span> <div>world&..

How to select all records from one table that do not exist in another table?

table1 (id, name) table2 (id, name) Query: SELECT name FROM table2 -- that are not in table1 already ..

Clearing an HTML file upload field via JavaScript

I want to reset a file upload field when the user selects another option. Is this possible via JavaScript? I'm suspecting that the file upload element is treated differently because it interacts with..

How to autoplay HTML5 mp4 video on Android?

I had developed a mobile page by to play mp4 video. I know iOS had disabled the autoplay function to minimize user bandwidth, so how can i autoplay HTML5 mp4 video on Android ? I had alrea..

How to edit the size of the submit button on a form?

Hi I don't want an image for my submit button so I have gone with the default submit button but I want to edit its width and height. How do I do that? <input type="submit" id="search" value="Searc..

AngularJS view not updating on model change

i'm trying to figure out how Angular works and am having trouble getting my view to update when the model changes.. HTML <div ng-app="test"> <p ng-controller="TestCtrl"> ..

Where Is Machine.Config?

I want to apply a change so That I can use Server GC settings for my C# 3.5 app - I can do that by editing the machine.config file. The only problem is I do not know where that is. How can I find th..

The condition has length > 1 and only the first element will be used

I have a dataframe, trip: > head(trip.mutations) Ref.y Variant.y 1 T C 2 G C 3 A C 4 T C 5 C A 6 G A I want to add a third column, mutType, that follows these ru..

Date formatting in WPF datagrid

I want to change is the date column from a format "DD/MM/YYYY HH:MM:SS" to "DD.MM.YYYY". <DataGrid Name="dgBuchung" AutoGenerateColumns="True" ..

Count occurrences of a char in a string using Bash

I need to count the number of occurrences of a char in a string using Bash. In the following example, when the char is (for example) t, it echos the correct number of occurrences of t in var, but whe..

Eclipse can't find / load main class

My Eclipse (Indigo) was running just fine. I created a simple class Hello. It is placed in package cont in the folder ch13. However, when I try to run it from Eclipse I get info from Java Virtual M..

change pgsql port

I have currently an installed pgsql instance that is running on port 1486. I want to change this port to 5433, how should I proceed for this?..

Move to next item using Java 8 foreach loop in stream

I have a problem with the stream of Java 8 foreach attempting to move on next item in loop. I cannot set the command like continue;, only return; works but you will exit from the loop in this case. I ..

Unable to find the requested .Net Framework Data Provider in Visual Studio 2010 Professional

Why am I getting "Unable to find the requested .Net Framework Data Provider" when trying to setup a new datasource in Visual Studio 2010 Professional? My stats: Windows 7 64bit 16gig RAM Visual Stu..

What are the differences between if, else, and else if?

I am trying to discern the difference between if else else if When do you use them and when not? I have a homework assignment with a ton of instances and I am running into code error due to no..

Removing all empty elements from a hash / YAML?

How would I go about removing all empty elements (empty list items) from a nested Hash or YAML file?..

Extracting the last n characters from a string in R

How can I get the last n characters from a string in R? Is there a function like SQL's RIGHT?..

Python TypeError: cannot convert the series to <class 'int'> when trying to do math on dataframe

I have a data frame that looks something like this: defaultdict(<class 'list'>, {'XYF': TimeUS GyrX GyrY GyrZ AccX \ 0 207146570 0.0..

How to represent a DateTime in Excel

What is the best way of representing a DateTime in Excel? We use Syncfusions Essential XlsIO to output values to an Excel document which works great. But I can't figure out how to display a DateTime i..

The connection to adb is down, and a severe error has occurred

Possible Duplicate: The connection to adb is down, and a severe error has occured I am currently trying to develop an application for Android in the latest release of Eclipse. When I try to..

how to use Blob datatype in Postgres

I am using a Postgresql database in my rails application. To store large file or data in database I have used blob data type in MySql. For Postgres which data type I have to use instead of blob in MyS..

JQuery show and hide div on mouse click (animate)

This is my HTML code: <div id="showmenu">Click Here</div> <div class="menu" style="display: none;"> <ul> <li>Button1</li> <li>Button2<..

Why I am getting Cannot pass parameter 2 by reference error when I am using bindParam with a constant value?

I'm using this code and I'm beyond frustration: try { $dbh = new PDO('mysql:dbname=' . DB . ';host=' . HOST, USER, PASS); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); ..

Timing a command's execution in PowerShell

Is there a simple way to time the execution of a command in PowerShell, like the 'time' command in Linux? I came up with this: $s=Get-Date; .\do_something.ps1 ; $e=Get-Date; ($e - $s).TotalSeconds ..

Using context in a fragment

How can I get the context in a fragment? I need to use my database whose constructor takes in the context, but getApplicationContext() and FragmentClass.this don't work so what can I do? Database co..

angular 4: *ngIf with multiple conditions

I'm confused a bit. I need to hide block if result have one of several cases. But seems it not working correctly... <div *ngIf="currentStatus !== 'open' || currentStatus !== 'reopen' "> &l..

How to save a bitmap on internal storage

this is my code I and I want to save this bitmap on my internal storage. The public boolean saveImageToInternalStorage is a code from google but I don't know how to use it. when I touch button2 follow..

Passing in class names to react components

I am trying to pass in a classname to a react component to change it's style and cannot seem to get working: class Pill extends React.Component { render() { return ( <button classNam..

How to fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function?

I'm trying to implement the binary classification example using the IMDb dataset in Google Colab. I have implemented this model before. But when I tried to do it again after a few days, it returned a ..

Remove part of string after "."

I am working with NCBI Reference Sequence accession numbers like variable a: a <- c("NM_020506.1","NM_020519.1","NM_001030297.2","NM_010281.2","NM_011419.3", "NM_053155.2") To get information ..

How can I read comma separated values from a text file in Java?

I have got this text file with latitude and longitude values of different points on a map. How can I split my string into latitudes and longitudes? What is the general way to do these type of things ..

How to make a phone call programmatically?

I'm passing to an activity the number to call by a bundle and then, in such activity, I have a button to call to that number, this is the code: callButton.setOnClickListener(new OnClickListener() { ..


A very frequently asked question here is how to do an upsert, which is what MySQL calls INSERT ... ON DUPLICATE UPDATE and the standard supports as part of the MERGE operation. Given that PostgreSQL ..

How do I use WPF bindings with RelativeSource?

How do I use RelativeSource with WPF bindings and what are the different use-cases?..

ESLint not working in VS Code?

ESLint is not working for me in VS Code. I have the plugin installed in VS Code, and ESLint itself as a developer dependency in my package.json, which I have installed as well. I modified the followi..

What is a StackOverflowError?

What is a StackOverflowError, what causes it, and how should I deal with them?..

Format number as percent in MS SQL Server

I am trying to simply format a number as a percent with two decimal places. If it is 37 divided by 38 (aka .973684210526315789), I would like it to show 97.36 % in the SQL output. I know it is recomme..

How can I remove all text after a character in bash?

How can I remove all text after a character, in this case a colon (":"), in bash? Can I remove the colon, too? I have no idea how to. ..

php mail setup in xampp

I'm learning PHP and have installed Xampp on my computer. But I have a problem with the setup as the email option doesn't seem to be working. After doing some reading I think it has something to d..

Jdbctemplate query for string: EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0

I am using Jdbctemplate to retrieve a single String value from the db. Here is my method. public String test() { String cert=null; String sql = "select ID_NMB_SRZ from codb_owner..

How do you share code between projects/solutions in Visual Studio?

I have two solutions which have some common code, so I'd like to extract it out and share it between them. Furthermore, I'd like to be able to release that library independently because it might be us..

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)

I have a bunch of client point of sale (POS) systems that periodically send new sales data to one centralized database, which stores the data into one big database for report generation. The client P..

jQuery - Uncaught RangeError: Maximum call stack size exceeded

The following code (see Fiddle here) throws the stack overflow referred to in the question title. I'm trying to get a box shadow to display around a circular image in a pulse effect. Can anyone point ..

C# adding a character in a string

I know I can append to a string but I want to be able to add a specific character after every 5 characters within the string from this string alpha = abcdefghijklmnopqrstuvwxyz to this string alpha ..

Modify request parameter with servlet filter

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

How to parse XML using jQuery?

How do I parse XML, and how can I navigate the result using jQuery? Here is my sample XML: <Pages> <Page Name="test"> <controls> <test>this is a test.</test>..

Is there a CSS selector for elements containing certain text?

I am looking for a CSS selector for the following table: Peter | male | 34 Susanne | female | 12 Is there any selector to match all TDs containing "male"?..

Pandas read in table without headers

How can I read in a .csv file (with no headers) and when I only want a subset of the columns (say 4th and 7th out of a total of 20 columns), using pandas? I cannot seem to be able to do usecols..

VBA (Excel) Initialize Entire Array without Looping

I am fairly new to VBA, so this may be a simple question but here goes. I would like to initialize an entire array myArray, say of integers, in VBA. I know that I can do this by a simple initializati..

Hidden property of a button in HTML

I am trying to show three buttons on one button click. Before a button click all three buttons are hidden. I set the hidden property and I am also calling a function on a button click. The problem is ..

Delete a dictionary item if the key exists

Is there any other way to delete an item in a dictionary only if the given key exists, other than: if key in mydict: del mydict[key] The scenario is that I'm given a collection of keys to be re..

Python - Dimension of Data Frame

New to Python. In R, you can get the dimension of a matrix using dim(...). What is the corresponding function in Python Pandas for their data frame?..

Spring - download response as a file

I am writing application using AngularJS and Spring. I would like to send request to the server and download response returned from controller as a file. In controller I have content of csv file (as s..

How to get MAC address of your machine using a C program?

I am working on Ubuntu. How can I get MAC address of my machine or an interface say eth0 using C program...

Changing the action of a form with JavaScript/jQuery

I'm having an issue that is driving me crazy. I'm trying to modify the openid-selector to support facebook. I'm using RPXNow as my provider so it requires the form to be submitted to a different url t..

Android Studio - Auto complete and other features not working

I installed android studio.. it was working fine. Now all the sudden, none of the auto complete features are working.. I can type anything anywhere no variable checking, no help with functions or chec..

Regular Expression usage with ls

I am trying to use ER (Extended Regular Expressions) with ls like ls .+\..+. I am trying to print all files which contains an extension (I know I could have used ls *.*, but I wanted to try using ER..

CSS image resize percentage of itself?

I am trying to resize an img with a percentage of itself. For example, I just want to shrink the image by half by resizing it to 50%. But applying width: 50%; will resize the image to be 50% of the co..

How do you check if a selector matches something in jQuery?

In Mootools, I'd just run if ($('target')) { ... }. Does if ($('#target')) { ... } in jQuery work the same way?..

How to execute VBA Access module?

Ok I'm using Access 2003 and I've just started learning Access and VBA a few days ago. I wrote some code in a module and there are no errors when I press the play button on the debugger toolbar up top..

Python slice first and last element in list

Is there a way to slice only the first and last item in a list? For example; If this is my list: >>> some_list ['1', 'B', '3', 'D', '5', 'F'] I want to do this (obviously [0,-1] is not va..

Simpler way to check if variable is not equal to multiple string values?

Current Codes: <?php // See the AND operator; How do I simplify/shorten this line? if( $some_variable !== 'uk' && $some_variable !== 'in' ) { // Do something } ?> And: ..

How to increase Maximum Upload size in cPanel?

I am using cPanel of my website to increase maximum upload file size for wordpress media uploads. I have used the codes(found out from google) for this purpose wp-config.php, .htaccess but nothing is ..

How to install SimpleJson Package for Python I am just diving into the Python world and want to make a simple twitter application which requires the installation of simplejson but not sure how I can set it..

Good tutorial for using HTML5 History API (Pushstate?)

I am looking into using the HTML5 History API to resolve deep linking problems with AJAX loaded content, but I am struggling to get off the ground. Does any one know of any good resources? I want to ..

TypeError: not all arguments converted during string formatting python

The program is supposed to take in two names, and if they are the same length it should check if they are the same word. If it's the same word it will print "The names are the same". If they are the ..

JAX-RS — How to return JSON and HTTP status code together?

I'm writing a REST web app (NetBeans 6.9, JAX-RS, TopLink Essentials) and trying to return JSON and HTTP status code. I have code ready and working that returns JSON when the HTTP GET method is called..

Update Angular model after setting input value with jQuery

I have this simple scenario: Input element which value is changed by jQuery's val() method. I am trying to update the angular model with the value that jQuery set. I tried to write a simple direct..

Print a variable in hexadecimal in Python

I'm trying to find a way to print a string in hexadecimal. For example, I have this string which I then convert to its hexadecimal value. my_string = "deadbeef" my_hex = my_string.decode('hex') How..

Getting "Lock wait timeout exceeded; try restarting transaction" even though I'm not using a transaction

I'm running the following MySQL UPDATE statement: mysql> update customer set account_import_id = 1; ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction I'm not using a tra..

change background image in body

How do i change the background image in CSS at run time? I have the following background image in body and can the image be changed at run time? body { height: 100%; background: #fff8db url(../imag..

Running Java Program from Command Line Linux

I am not very experience with java and this is driving me crazy. I wrote a java program FileManagement and I need to run it from the command line. I can compile it from the command line with javac Fi..

How to select top 10 in Access query?

My Access database table has 2 columns: name and price. I want to do a query that select the top 10 highest prices. How to do this? Thanks...

C# - Simplest way to remove first occurrence of a substring from another string

I need to remove the first (and ONLY the first) occurrence of a string from another string. Here is an example replacing the string "\\Iteration". This: ProjectName\\Iteration\\Release1\\Iteration..

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'

This is the Warning im getting in console, Im confused with this warning: Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is ..

Best practice to look up Java Enum

We have a REST API where clients can supply parameters representing values defined on the server in Java Enums. So we can provide a descriptive error, we add this lookup method to each Enum. Seems l..