Examples On Programing Languages

Remove object from a list of objects in python

In Python, how can I remove an object from array of objects? Like this: x = object() y = object() array = [x,y] # Remove x I've tried array.remove() but it only works with a value, not a specific location in the array. I need to be able to delete ...

SQL (MySQL) vs NoSQL (CouchDB)

I am in the middle of designing a highly-scalable application which must store a lot of data. Just for example it will store lots about users and then things like a lot of their messages, comments etc. I have always used MySQL before but now I am min...

Apply CSS styles to an element depending on its child elements

Is it possible to define a CSS style for an element, that is only applied if the matching element contains a specific element (as the direct child item)? I think this is best explained using an example. Note: I'm trying to style the parent element,...

What is IllegalStateException?

I am trying to use the following Fastload API connection ... etc is perfect. I know exactly where it fails ........... System.out.println(" Streaming " + dataFile); pstmtFld.setAsciiStream(1, dataStream, -1); // This line fails System.out.p...

Mercurial undo last commit

How can I undo my last accidentally commited (not pushed) change in Mercurial? If possible, a way to do so with TortoiseHg would be prefered. Update In my concrete case I commited a changeset (not pushed). Then I pulled and updated from the server...

Difference between javacore, thread dump and heap dump in Websphere

Can someone tell me the exact difference between javacore, thread dump and heap dump? Under which situation each of these are used??...

Javascript variable access in HTML

Say I have the following JavaScript in a HTML page <html> <script> var simpleText = "hello_world"; var finalSplitText = simpleText.split("_"); var splitText = finalSplitText[0]; </script> <body> <a href = ...

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

How can I make text appear on next line instead of overflowing?

I have a fixed width div on my page that contains text. When I enter a long string of letters it overflows. I don't want to hide overflow I want to display the overflow on a new line, see below: <div id="textbox" style="width:400px; height:200px;...

Microsoft Visual C++ Compiler for Python 3.4

I know that there is a "Microsoft Visual C++ Compiler for Python 2.7" but is there, currently or planned, a Microsoft Visual C++ Compiler for Python 3.4 or eve Microsoft Visual C++ Compiler for Python 3.x for that matter? It would be supremely benef...

adding classpath in linux

export CLASSPATH=.;../somejar.jar;../mysql-connector-java-5.1.6-bin.jar java -Xmx500m folder.subfolder../dit1/some.xml cd .. is the above statement for setting the classpath to already existing classpath in linux is correct or not...

Flask ImportError: No Module Named Flask

I'm following the Flask tutorial here: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world I get to the point where I try ./run.py and I get: Traceback (most recent call last): File "./run.py", line 3, in <module&g...

Last Key in Python Dictionary

I am having difficulty figuring out what the syntax would be for the last key in a Python dictionary. I know that for a Python list, one may say this to denote the last: list[-1] I also know that one can get a list of the keys of a dictionary as f...

What are the differences between B trees and B+ trees?

In a b-tree you can store both keys and data in the internal and leaf nodes, but in a b+ tree you have to store the data in the leaf nodes only. Is there any advantage of doing the above in a b+ tree? Why not use b-trees instead of b+ trees everywher...

.setAttribute("disabled", false); changes editable attribute to false

I want to have textboxes related to radiobuttons. Therefore each radio button should enable it's textbox and disable the others. However when I set the disabled attribute of textbox to true, it changes the editable attribute too. I tried setting edit...

Update cordova plugins in one command

I am wondering is there an easier way to update cordova plugin? I googled, found a hook (@ year 2013), but this is not 100% what I want. I know I can do this by two steps: rm, then add but I am looking for a better (official) way to help me which p...

How do you list volumes in docker containers?

When using docker images from registries, I often need to see the volumes created by the image's containers. Note: I'm using docker version 1.3.2 on Red Hat 7. Example The postgres official image from the Docker Registry has a volume configured fo...

What is the standard Python docstring format?

I have seen a few different styles of writing docstrings in Python, is there an official or "agreed-upon" style?...

Make Div overlay ENTIRE page (not just viewport)?

So I have a problem that I think is quite common but I have yet to find a good solution for. I want to make an overlay div cover the ENTIRE page... NOT just the viewport. I don't understand why this is so hard to do... I've tried setting body, htm...

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 tired brain, so I am hoping to find here some adv...

How to avoid installing "Unlimited Strength" JCE policy files when deploying an application?

I have an app that uses 256-bit AES encryption which is not supported by Java out of the box. I know to get this to function correctly I install the JCE unlimited strength jars in the security folder. This is fine for me being the developer, I can in...

Coarse-grained vs fine-grained

What is the difference between coarse-grained and fine-grained? I have searched these terms on Google, but I couldn't find what they mean....

Vertical Align text in a Label

I have been asked to vertically align the text in the labels for the fields in a form but I don't understand why they are not moving. I have tried putting in-line styles using vertical-align:top; and other attributes like bottom and middle but it doe...

How to do vlookup and fill down (like in Excel) in R?

I have a dataset about 105000 rows and 30 columns. I have a categorical variable that I would like to assign it to a number. In Excel, I would probably do something with VLOOKUP and fill. How would I go about doing the same thing in R? Essentially,...

Python Pandas iterate over rows and access column names

I am trying to iterate over the rows of a Python Pandas dataframe. Within each row of the dataframe, I am trying to to refer to each value along a row by its column name. Here is what I have: import numpy as np import pandas as pd df = pd.DataFra...

How to split a string in shell and get the last field

Suppose I have the string 1:2:3:4:5 and I want to get its last field (5 in this case). How do I do that using Bash? I tried cut, but I don't know how to specify the last field with -f....

How do I get a consistent byte representation of strings in C# without manually specifying an encoding?

How do I convert a string to a byte[] in .NET (C#) without manually specifying a specific encoding? I'm going to encrypt the string. I can encrypt it without converting, but I'd still like to know why encoding comes to play here. Also, why should e...

How to log PostgreSQL queries?

How to enable logging of all SQL executed by PostgreSQL 8.3? Edited (more info) I changed these lines : log_directory = 'pg_log' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' log_statement = 'all' And restart PostgreSQL serv...

Gather multiple sets of columns

I have data from an online survey where respondents go through a loop of questions 1-3 times. The survey software (Qualtrics) records this data in multiple columns—that is, Q3.2 in the survey will have columns Q3.2.1., Q3.2.2., and Q3.2.3.: df &l...

Why does Java have an "unreachable statement" compiler error?

I often find when debugging a program it is convenient, (although arguably bad practice) to insert a return statement inside a block of code. I might try something like this in Java .... class Test { public static void main(String args[]) { ...

What is the use of static constructors?

Please explain to me the use of static constructor. Why and when would we create a static constructor and is it possible to overload one?...

How to use curl in a shell script?

I'm trying to run this shell script in order to install RVM in an Ubuntu box #!/bin/bash RVMHTTP="https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer" CURLARGS="-f -s -S -k" bash < <(curl $CURLARGS $RVMHTTP) but I get th...

Python class inherits object

Is there any reason for a class declaration to inherit from object? I just found some code that does this and I can't find a good reason why. class MyClass(object): # class code follows... ...

Select rows from a data frame based on values in a vector

I have data similar to this: dt <- structure(list(fct = structure(c(1L, 2L, 3L, 4L, 3L, 4L, 1L, 2L, 3L, 1L, 2L, 3L, 2L, 3L, 4L), .Label = c("a", "b", "c", "d"), class = "factor"), X = c(2L, 4L, 3L, 2L, 5L, 4L, 7L, 2L, 9L, 1L, 4L, 2L, 5L, 4L, 2L))...

do <something> N times (declarative syntax)

Is there a way in Javascript to write something like this easily: [1,2,3].times do { something(); } Any library that might support some similar syntax maybe? Update: to clarify - I would like something() to be called 1,2 and 3 times respectivel...

Python List vs. Array - when to use?

If you are creating a 1d array, you can implement it as a List, or else use the 'array' module in the standard library. I have always used Lists for 1d arrays. What is the reason or circumstance where I would want to use the array module instead? ...

how to refresh page in angular 2

I have created one router link as below. This router link loads ProductsStartComponent and then this component loads several other components using ngif and not via navigation. Since below Product categories link is visible in all pages so if I am cl...

Windows command to get service status?

I need to know the status of a service at the end of my batch script which restarts services using "net stop thingie" and "net start thingie". In my most favorite ideal world, I would like to e-mail the state to myself, to read on cold winter nights...

Python MySQLdb TypeError: not all arguments converted during string formatting

Upon running this script: #! /usr/bin/env python import MySQLdb as mdb import sys class Test: def check(self, search): try: con = mdb.connect('localhost', 'root', 'password', 'recordsdb'); cur = con.cursor()...

How to get the date from the DatePicker widget in Android?

I use a DatePicker widget in Android for the user to set a date, and want to get the date value when a confirm button is clicked, how can I do that?...

How to get last N records with activerecord?

With :limit in query, I will get first N records. What is the easiest way to get last N records?...

How do you hide the Address bar in Google Chrome for Chrome Apps?

I want to increase the screen real estate for my Chrome app. The Address Bar is useless in a Chrome App and I was wondering if there was a way to disable it....

What programming languages can one use to develop iPhone, iPod Touch and iPad (iOS) applications?

What programming languages can one use to develop iPhone, iPod Touch and iPad (iOS) applications? Also are there plans in the future to expand the amount of programming languages that iOS will support?...

Plotting time-series with Date labels on x-axis

I know that this question might be a cliche, but I'm having hard time doing it. I've data set in the following format: Date Visits 11/1/2010 696537 11/2/2010 718748 11/3/2010 799355 11/4/2010 ...

Mercurial: how to amend the last commit?

I'm looking for a counter-part of git commit --amend in Mercurial, i.e. a way to modify the commit which my working copy is linked to. I'm only interested in the last commit, not an arbitrary earlier commit. The requirements for this amend-procedure...

How to insert a character in a string at a certain position?

I'm getting in an int with a 6 digit value. I want to display it as a String with a decimal point (.) at 2 digits from the end of int. I wanted to use a float but was suggested to use String for a better display output (instead of 1234.5 will be 1234...

How do I write a Windows batch script to copy the newest file from a directory?

I need to copy the newest file in a directory to a new location. So far I've found resources on the forfiles command, a date-related question here, and another related question. I'm just having a bit of trouble putting the pieces together! How do I c...

C++ obtaining milliseconds time on Linux -- clock() doesn't seem to work properly

On Windows, clock() returns the time in milliseconds, but on this Linux box I'm working on, it rounds it to the nearest 1000 so the precision is only to the "second" level and not to the milliseconds level. I found a solution with Qt using the QTime...

How do I escape special characters in MySQL?

For example: select * from tablename where fields like "%string "hi" %"; Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'hi" "' at line 1 How do I...

Android Respond To URL in Intent

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

Convert JSON to Map

What is the best way to convert a JSON code as this: { "data" : { "field1" : "value1", "field2" : "value2" } } in a Java Map in which one the keys are (field1, field2) and the values for those fields are (value1, va...

only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

I am implementing fft as part of my homework. My problem lies in the implemention of shuffling data elements using bit reversal. I get the following warning: DeprecationWarning: using a non-integer number instead of an integer will result in an erro...

How to count the number of files in a directory using Python

I need to count the number of files in a directory using Python. I guess the easiest way is len(glob.glob('*')), but that also counts the directory itself as a file. Is there any way to count only the files in a directory?...

How to link HTML5 form action to Controller ActionResult method in ASP.NET MVC 4

I have a basic form for which I want to handle buttons inside the form by calling the ActionResult method in the View's associated Controller class. Here is the following HTML5 code for the form: <h2>Welcome</h2> <div> <h3...

Can regular JavaScript be mixed with jQuery?

For example, can I take this script (from mozilla tutorial): <html> <head> <script type="application/javascript"> function draw() { var canvas = document.getElementById("canvas"); if (canvas.getContext) { ...

How to insert data to MySQL having auto incremented primary key?

I've created a table with a primary key and enabled AUTO_INCREMENT, how do I get MYSQL use AUTO_INCREMENT? CREATE TABLE IF NOT EXISTS test.authors ( hostcheck_id INT PRIMARY KEY AUTO_INCREMENT, instance_id INT, host_object_id INT, ch...

Find and replace with sed in directory and sub directories

I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of my site: find ./ -exec sed -i 's/apple/orange/g' {} \; But it doesn't go through sub directories. What is wrong with this command? Here are s...

The POM for project is missing, no dependency information available

Background Trying to add a Java library to the local Maven repository using a clean install of Apache Maven 3.1.0, with Java 1.7. Here is how the Java archive file was added: mvn install:install-file \ -DgroupId=net.sourceforge.ant4x \ -Dartifa...

Python Dictionary contains List as Value - How to update?

I have a dictionary which has value as a list. dictionary = { 'C1' : [10,20,30] 'C2' : [20,30,40] } Let's say I want to increment all the values in list of C1 by 10, how do I do it? dictionary.get('C1'...

How do I get Bin Path?

I need to the the bin path of the executing assembly. How do you get it? I have a folder Plugins in the Bin/Debug and I need to get the location...

Close Bootstrap Modal

I have a bootstrap modal dialog box that I want to show initially, then when the user clicks on the page, it disappears. I have the following: $(function () { $('#modal').modal(toggle) }); <div class="modal" id='modal'> <div class...

WebService Client Generation Error with JDK8

I need to consume a web service in my project. I use NetBeans so I right-clicked on my project and tried to add a new "Web Service Client". Last time I checked, this was the way to create a web service client. But it resulted in an AssertionError, sa...

How can I nullify css property?

Basically I have two external css in my page. The first Main.css contains all style rules but I don't have access to it, and hence I cannot modify it. I have access to a second file Template.css , so I need to override the Main.css's values in templ...

Programmatically get own phone number in iOS

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

Convert Go map to json

I tried to convert my Go map to a json string with encoding/json Marshal, but it resulted in a empty string. Here's my code : package main import ( "encoding/json" "fmt" ) type Foo struct { Number int `json:"number"` Title str...

How to get a thread and heap dump of a Java process on Windows that's not running in a console

I have a Java application that I run from a console which in turn executes an another Java process. I want to get a thread/heap dump of that child process. On Unix, I could do a kill -3 <pid> but on Windows AFAIK the only way to get a thread d...

Reasons for a 409/Conflict HTTP error when uploading a file to sharepoint using a .NET WebRequest?

I've got a method that uses a WebRequest to upload a file to a sharepoint 2010 list/folder, using a PUT request, with the Overwrite Header set to T (overwrite). When several files are uploaded (method is called several times), some requests fail wit...

Nginx location "not equal to" regex

How do I set a location condition in Nginx that responds to anything that isn't equal to the listed locations? I tried: location !~/(dir1|file2\.php) { rewrite ^/(.*) http://example.com/$1 permanent; } But it doesn't trigger the redirect. I...

Linq UNION query to select two elements

I want to select 2 elements from my database table using LINQ query and I saw an example which use UNION I don't have much experience but I think that maybe this is what I need but I get an error which I can not fix and I'm not sure if it's fixable a...

Numpy matrix to array

I am using numpy. I have a matrix with 1 column and N rows and I want to get an array from with N elements. For example, if i have M = matrix([[1], [2], [3], [4]]), I want to get A = array([1,2,3,4]). To achieve it, I use A = np.array(M.T)[0]. Does...

How to convert a SVG to a PNG with ImageMagick?

I have a SVG file that has a defined size of 16x16. When I use ImageMagick's convert program to convert it into a PNG, then I get a 16x16 pixel PNG which is way too small: convert test.svg test.png I need to specify the pixel size of the output PN...

How do I keep jQuery UI Accordion collapsed by default?

I am working with jQuery UI Accordion and it works great, but I would like to have the accordion stay closed unless it I click on it. I am using this code right now, which allows be to toggle it closed: $("#accordion").accordion({ header: "h3", col...

How to convert char to integer in C?

Possible Duplicates: How to convert a single char into an int Character to integer in C Can any body tell me how to convert a char to int? char c[]={'1',':','3'}; int i=int(c[0]); printf("%d",i); When I try this it gives 49....

Code signing is required for product type 'Application' in SDK 'iOS 10.0' - StickerPackExtension requires a development team error

I am facing the below issue and am unable to build the application. XXX has conflicting provisioning settings. XXX is automatically provisioned, but provisioning profile WildCard has been manually specified. Set the provisioning profile value...

How to close the current fragment by using Button like the back button?

I have try to close the current fragment by using Imagebutton. I am in Fragment-A and it will turn to the Fragment-B when I click the button. And when I click the button at Fragment-B , it will turn to the Fragment-C and close the Fragment-B. If I...

How do I reference a cell within excel named range?

For example, I have a named range A10—A20 as Age; how do I get Age[5] which is same as A14. I can write "=A14" but I did like to write "=Age$5" or something similar....

CSS background image to fit width, height should auto-scale in proportion

I have body { background: url(images/background.svg); } The desired effect is that this background image will have width equal to that of the page, height changing to maintain the proportion. e.g. if the original image happens to be 100*200 (a...

Get the cartesian product of a series of lists?

How can I get the Cartesian product (every possible combination of values) from a group of lists? Input: somelists = [ [1, 2, 3], ['a', 'b'], [4, 5] ] Desired output: [(1, 'a', 4), (1, 'a', 5), (1, 'b', 4), (1, 'b', 5), (2, 'a', 4), (2...

How should I read a file line-by-line in Python?

In pre-historic times (Python 1.4) we did: fp = open('filename.txt') while 1: line = fp.readline() if not line: break print line after Python 2.1, we did: for line in open('filename.txt').xreadlines(): print line before ...

How to preventDefault on anchor tags?

Let's say I have an anchor tag such as <a href="#" ng-click="do()">Click</a> How can I prevent the browser from navigating to # in AngularJS ?...

Converting HTML to XML

I have got hundereds of HTML files that need to be conveted in XML. We are using these HTML to serve contents for applications but now we have to serve these contents as XML. HTML files are contains, tables, div's, image's, p's, b or strong tags, ...

Gradle: Execution failed for task ':processDebugManifest'

I'm getting a gradle error at building since yesterday - it just came randomly.... Full stacktrace here: My project depends on multiple libraries and it built without any problems until yesterday (even with the librarys) compile 'com.google.androi...

How to get the current plugin directory in WordPress?

I need to get the current plugin directory like [wordpress_install_dir]/wp-content/plugins/plugin_name (if getcwd() called from the plugin, it returns [wordpress_install_dir], the root of installation) thanks for help...

C# delete a folder and all files and folders within that folder

I'm trying to delete a folder and all files and folders within that folder, I'm using the code below and I get the error Folder is not empty, any suggestions on what I can do? try { var dir = new DirectoryInfo(@FolderPath); dir.Attributes = dir....

Is there a better way to run a command N times in bash?

I occasionally run a bash command line like this: n=0; while [[ $n -lt 10 ]]; do some_command; n=$((n+1)); done To run some_command a number of times in a row -- 10 times in this case. Often some_command is really a chain of commands or a pipelin...

Best way to use multiple SSH private keys on one client

I want to use multiple private keys to connect to different servers or different portions of the same server (my uses are system administration of server, administration of Git, and normal Git usage within the same server). I tried simply stacking th...

Dead simple example of using Multiprocessing Queue, Pool and Locking

I tried to read the documentation at http://docs.python.org/dev/library/multiprocessing.html but I'm still struggling with multiprocessing Queue, Pool and Locking. And for now I was able to build the example below. Regarding Queue and Pool, I'm not...

String.Format not work in TypeScript

String.Format does not work in TypeScript. Error: The property 'format' does not exist on value of type '{ prototype: String; fromCharCode(...codes: number[]): string; (value?: any): string; new(value?: any): String; }'. attributes["Title"...

fcntl substitute on Windows

I received a Python project (which happens to be a Django project, if that matters,) that uses the fcntl module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an ImportE...

Is there a way to access an iteration-counter in Java's for-each loop?

Is there a way in Java's for-each loop for(String s : stringArray) { doSomethingWith(s); } to find out how often the loop has already been processed? Aside from using the old and well-known for(int i=0; i < boundary; i++) - loop, is the cons...

CSS: Force float to do a whole new line

I have a bunch of float: left elements and some are SLIGHTLY bigger than others. I want the newline to break and have the images float all the way to the left instead of getting stuck on a bigger element. Here is the page I'm talking about : link I...

How to 'foreach' a column in a DataTable using C#?

How do I loop through each column in a datarow using foreach? DataTable dtTable = new DataTable(); MySQLProcessor.DTTable(mysqlCommand, out dtTable); foreach (DataRow dtRow in dtTable.Rows) { //foreach(DataColumn dc in dtRow) } ...

How to add a string to a string[] array? There's no .Add function

private string[] ColeccionDeCortes(string Path) { DirectoryInfo X = new DirectoryInfo(Path); FileInfo[] listaDeArchivos = X.GetFiles(); string[] Coleccion; foreach (FileInfo FI in listaDeArchivos) { //Add the FI.Name to t...

"401 Unauthorized" on a directory

I assume this is an IIS error, as this doesn't happen if I run the project on my local machine. I have my stylesheets at ~/Content/css Any files in that directory won't load on the page, and when I navigate to them directly, I get a server error: 40...

Interface type check with Typescript

This question is the direct analogon to Class type check with TypeScript I need to find out at runtime if a variable of type any implements an interface. Here's my code: interface A{ member:string; } var a:any={member:"foobar"}; if(a instance...

Login to website, via C#

I'm relatively new to using C#, and have an application that reads parts of the source code on a website. That all works; but the problem is that the page in question requires the user to be logged in to access this source code. What my program needs...

How do I deserialize a complex JSON object in C# .NET?

I have a JSON string and I need some help to deserialize it. Nothing worked for me... This is the JSON: { "response": [{ "loopa": "81ED1A646S894309CA1746FD6B57E5BB46EC18D1FAff", "drupa": "D4492C3CCE7D6F839B2BASD2F08577F89A27B4ff...

Python error: TypeError: 'module' object is not callable for HeadFirst Python code

I'm following the tutorial from the HeadFirst Python book. In chapter 7, I get an error message when trying to run the next code: Athlete class: class AthleteList(list): def __init__(self, a_name, a_dob=None, a_times=[]): list.__init__(...

How to mock location on device?

How can I mock my location on a physical device (Nexus One)? I know you can do this with the emulator in the Emulator Control panel, but this doesn't work for a physical device....

Adding a user on .htpasswd

I am using .htpasswd to password protect certain directory on my server. However, I noticed that everytime I do this sudo htpasswd -c /etc/apache2/.htpasswd newuser my current contents of .htpasswd will be overwritten. Every directory of my site has ...

Dynamically change color to lighter or darker by percentage CSS (Javascript)

We have a big application on the site and we have a few links which are, let's say blue color like the blue links on this site. Now I want to make some other links, but with lighter color. Obviously I can just do simply by the hex code adding in the ...

How to pass command-line arguments to a PowerShell ps1 file

For years, I have used the cmd/DOS/Windows shell and passed command-line arguments to batch files. For example, I have a file, zuzu.bat and in it, I access %1, %2, etc. Now, I want to do the same when I call a PowerShell script when I am in a Cmd.exe...

Launching an application (.EXE) from C#?

How can I launch an application using C#? Requirements: Must work on Windows XP and Windows Vista. I have seen a sample from DinnerNow.net sampler that only works in Windows Vista....

Looking to understand the iOS UIViewController lifecycle

Could you explain me the correct manner to manage the UIViewController lifecycle? In particular, I would like to know how to use Initialize, ViewDidLoad, ViewWillAppear, ViewDidAppear, ViewWillDisappear, ViewDidDisappear, ViewDidUnload and Dispose m...

selected value get from db into dropdown select box option using php mysql error

I need to get selected value from db into select box. please, tell me how to do it. Here is the code. Note: 'options' value depends on the category. <?php $sql = "select * from mine where username = '$user' "; $res = mysql_query($sql); w...

anaconda/conda - install a specific package version

I want to install the 'rope' package in my current active environment using conda. Currently, the following 'rope' versions are available: (data_downloader)user@user-ThinkPad ~/code/data_downloader $ conda search rope Using Anaconda Cloud api site h...

How to write a simple Html.DropDownListFor()?

In ASP.NET MVC 2, I'd like to write a very simple dropdown list which gives static options. For example I'd like to provide choices between "Red", "Blue", and "Green"....

What is the difference between 'git pull' and 'git fetch'?

What are the differences between git pull and git fetch?...

how to append a css class to an element by javascript?

Suppose a HTML element's id is known, so the element can be refereced using: document.getElementById(element_id); Does a native Javascript function exist that can be used to append a CSS class to that element?...

How can I find a specific element in a List<T>?

My application uses a list like this: List<MyClass> list = new List<MyClass>(); Using the Add method, another instance of MyClass is added to the list. MyClass provides, among others, the following methods: public void SetId(String Id...

In HTML5, should the main navigation be inside or outside the <header> element?

In HTML5, I know that <nav> can be used either inside or outside the page's masthead <header> element. For websites having both secondary and main navigation, it seems common to include the secondary navigation as a <nav> element i...

Converting characters to integers in Java

Can someone please explain to me what is going on here: char c = '+'; int i = (int)c; System.out.println("i: " + i + " ch: " + Character.getNumericValue(c)); This prints i: 43 ch:-1. Does that mean I have to rely on primitive conversions to conver...

Access HTTP response as string in Go

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

What is RSS and VSZ in Linux memory management

What are RSS and VSZ in Linux memory management? In a multithreaded environment how can both of these can be managed and tracked?...

Python and pip, list all versions of a package that's available?

Given the name of a Python package that can be installed with pip, is there any way to find out a list of all the possible versions of it that pip could install? Right now it's trial and error. I'm trying to install a version for a third party libra...

Fixing slow initial load for IIS

IIS has an annoying feature for low traffic websites where it recycles unused worker processes, causing the first user to the site after some time to get an extremely long delay (30+ seconds). I've been looking for a solution to the problem and I've...

How to fix error "Updating Maven Project". Unsupported IClasspathEntry kind=4?

I have imported maven project in STS, when I run update update project I receive: "Updating Maven Project". Unsupported IClasspathEntry kind=4 Is there a workaround for this?...

Converting json results to a date

Possible Duplicate: How to format a JSON date? I have the following result from a $getJSON call from JavaScript. How do I convert the start property to a proper date in JavaScript? [ {"id":1,"start":"/Date(1238540400000)/"}, {"id"...

ASP MVC href to a controller/view

I have this: <li><a href="/Users/Index)" class="elements"><span>Clients</span></a></li> Which works fine. But if I am already on this page or on the controller e.g. /Users/Details and I click on this link it red...

Pagination on a list using ng-repeat

I'm trying to add pages to my list. I followed the AngularJS tutorial, the one about smartphones and I'm trying to display only certain number of objects. Here is my html file: <div class='container-fluid'> <div class='row-fluid'> ...

how to hide keyboard after typing in EditText in android?

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

How to change button text or link text in JavaScript?

I have this HTML button: <button id="myButton" onClick="lock(); toggleText(this.id);">Lock</button> And this is my toggleText JavaScript function: function toggleText(button_id) { if (document.getElementById('button_id').text == "...

How do I add PHP code/file to HTML(.html) files?

I can't use PHP in my HTML pages. For example, index.html. I've tried using both: <? contents ?> and <?php contents ?> Neither of these work. My server offers PHP, and when I use a the .php extension, it works properly. Is this a...

How to remove all white spaces in java

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

Handling the null value from a resultset in JAVA

I currently have a resultset returned and in one of the columns the string value may be null (i mean no values at all). I have a condition to implement like following rs = st.executeQuery(selectSQL); output = rs.getString("column"); Since...

How to generate a random string of a fixed length in Go?

I want a random string of characters only (uppercase or lowercase), no numbers, in Go. What is the fastest and simplest way to do this?...

Sum columns with null values in oracle

I want to add two numbers together but when one of those numbers is null then the result is null. Is there a way around this. I could simply do it in the code but I would rather have it done in the query. This is a oracle database. The table stru...

How do I make Visual Studio pause after executing a console application in debug mode?

I have a collection of Boost unit tests I want to run as a console application. When I'm working on the project and I run the tests I would like to be able to debug the tests, and I would like to have the console stay open after the tests run. I se...

How to change default install location for pip

I'm trying to install Pandas using pip, but I'm having a bit of trouble. I just ran sudo pip install pandas which successfully downloaded pandas. However, it did not get downloaded to the location that I wanted. Here's what I see when I use pip sh...

$(document).click() not working correctly on iPhone. jquery

This function works perfectly on IE, Firefox and Chrome but when on the iPhone, it will only work when clicking on a <img>. Clicking on the page (anywhere but on a img) wont fire the event. $(document).ready(function () { $(document).click(...

Install Visual Studio 2013 on Windows 7

I would like to install Visual Studio 2013 on Windows 7 64-bit. For some reason, the installer says "Setup Blocked" with an error "This version of Visual Studio requires a computer with a newer version of Windows". This error is not exactly descr...

sequelize findAll sort order in nodejs

I'm trying to output all object list from database with sequelize as follow and want to get data are sorted out as I added id in where clause. exports.getStaticCompanies = function () { return Company.findAll({ where: { id: [...

Convert datetime object to a String of date only in Python

I see a lot on converting a date string to an datetime object in Python, but I want to go the other way. I've got datetime.datetime(2012, 2, 23, 0, 0) and I would like to convert it to string like '2/23/2012'....

How do I view the SQL generated by the Entity Framework?

How do I view the SQL generated by entity framework ? (In my particular case I'm using the mysql provider - if it matters)...

Laravel Request getting current path with query string

Is there a Laravel way to get the current path of a Request with its query parameters? For instance, for the URL: http://www.example.com/one/two?key=value Request::getPathInfo() would return /one/two. Request::url() would return http://www.examp...

How to obfuscate Python code effectively?

I am looking for how to hide my Python source code. print "Hello World!" How can I encode this example so that it isn't human-readable? I've been told to use base64 but I'm not sure how....

Substring in VBA

I have multiple strings in different cells like CO20: 20 YR CONVENTIONAL FH30: 30 YR FHLMC FHA31 I need to get the substring from 1 to till index of ':' or if that is not available till ending(in case of string 3). I need help writing this in...

Is there a command like "watch" or "inotifywait" on the Mac?

I want to watch a folder on my Mac (Snow Leopard) and then execute a script (giving it the filename of what was just moved into a folder (as a parameter... x.sh "filename")). I have a script all written up in bash (x.sh) that will move some files an...

Advantages of std::for_each over for loop

Are there any advantages of std::for_each over for loop? To me, std::for_each only seems to hinder the readability of code. Why do then some coding standards recommend its use? ...

Send form data with jquery ajax json

I'm new in PHP/jquery I would like to ask how to send json data from a form field like (name, age, etc) with ajax in a json format. Sadly I can't found any relevant information about this it's even possible to do it dynamically? Google searches only ...

c# datagridview doubleclick on row with FullRowSelect

I have a datagridview in my C# application and the user should only be able to click on full rows. So I set the SelectionMode to FullRowSelect. But now I want to have an Event which is fired when the user double clicks on a row. I want to have the r...

Why does Date.parse give incorrect results?

Case One: new Date(Date.parse("Jul 8, 2005")); Output: Fri Jul 08 2005 00:00:00 GMT-0700 (PST) Case Two: new Date(Date.parse("2005-07-08")); Output: Thu Jul 07 2005 17:00:00 GMT-0700 (PST) Why is the second parse incorrect?...

Print values for multiple variables on the same line from within a for-loop

I have a question that must surely seem very trivial, but the answer has always alluded me: how do you print values for multiple variables on the same line from within a for-loop? I present two solutions neither of which relies on nothing more than ...

jQuery - setting the selected value of a select control via its text description

I have a select control, and in a javascript variable I have a text string. Using jQuery I want to set the selected element of the select control to be the item with the text description I have (as opposed to the value, which I don't have). I know ...

SQL recursive query on self referencing table (Oracle)

Lets assume I have this sample data: | Name | ID | PARENT_ID | ----------------------------- | a1 | 1 | null | | b2 | 2 | null | | c3 | 3 | null | | a1.d4 | 4 | 1 | | a1.e5 | 5 | 1 | | ...

Convert text into number in MySQL query

Is it possible to convert text into a number within MySQL query? I have a column with an identifier that consists a name and a number in the format of "name-number". The column has VARCHAR type. I want to sort the rows according to the numb...

Html5 Placeholders with .NET MVC 3 Razor EditorFor extension?

Is there a way to write the Html5 placeholder using @Html.EditorFor, or should I just use the TextBoxFor extension i.e. @Html.TextBoxFor(model => model.Title, new { @placeholder = "Enter title here"}) Or would it make sense to write our own cus...

DataGridView.Clear()

Here comes the trouble. I want to delete all rows from datagridview. This how i add rows: private void ReadCompleteCallback(object clientHandle, Opc.Da.ItemValueResult[] results) { foreach (Opc.Da.ItemValueResult readResult in results) {...

Check if a value exists in ArrayList

How can I check if a value that is written in scanner exists in an ArrayList? List<CurrentAccount> lista = new ArrayList<CurrentAccount>(); CurrentAccount conta1 = new CurrentAccount("Alberto Carlos", 1052); CurrentAccount conta2 = new ...

Validate phone number using angular js

Want to set phone-number to 10 digits, How can I do this using Angular js. This is what I have tried: <form class="form-horizontal" role="form" method="post" name="registration" novalidate> <div class="form-group" ng-class="{'has-error':...

In Ruby, how do I skip a loop in a .each loop, similar to 'continue'

In Ruby, how do I skip a loop in a .each loop, similar to continue in other languages?...

How to click a browser button with JavaScript automatically?

How to click a button every second using JavaScript?...

How to get row from R data.frame

I have a data.frame with column headers. How can I get a specific row from the data.frame as a list (with the column headers as keys for the list)? Specifically, my data.frame is A B C 1 5 4.25 4.5 2 3.5 4 2.5 3 3...

Notepad++: Multiple words search in a file (may be in different lines)?

How can we perform multiple search for multiple words and the line containing them. These words can be in same or different lines. For example: 1.The CAT goes up and down the ROAD. 2. The DOG goes up and down the CITY. 3. The HORSE goes up and dow...

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

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

Using File.listFiles with FileNameExtensionFilter

I would like to get a list of files with a specific extension in a directory. In the API (Java 6), I see a method File.listFiles(FileFilter) which would do this. Since I need a specific extension, I created a FileNameExtensionFilter. However I get a...

What is the easiest/best/most correct way to iterate through the characters of a string in Java?

StringTokenizer? Convert the String to a char[] and iterate over that? Something else?...

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 to launch a Google Chrome Tab with specific URL using C#

Is there a way I can launch a tab (not a new Window) in Google Chrome with a specific URL loaded into it from a custom app? My application is coded in C# (.NET 4 Full). I'm performing some actions via SOAP from C# and once successfully completed, I...

How do you obtain a Drawable object from a resource id in android package?

I need to get a Drawable object to display on an image button. Is there a way to use the code below (or something like it) to get an object from the android.R.drawable.* package? for example if drawableId was android.R.drawable.ic_delete mContext.g...

regular expression for Indian mobile numbers

I want regular expression for indian mobile numbers which consists of 10 digits. The numbers which should match start with 9 or 8 or 7. For example: 9882223456 8976785768 7986576783 It should not match the numbers starting with 1 to 6 or 0....

Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image?

Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image automatically? For example assume that I have a 512x512 image and I want to have different versions of this images for different screen resolutions support...

How to get row number in dataframe in Pandas?

How can I get the number of the row in a dataframe that contains a certain value in a certain column using Pandas? For example, I have the following dataframe: ClientID LastName 0 34 Johnson 1 67 Smith 2 53 Brows ...

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

m2e lifecycle-mapping not found

I am trying to use the solution described here to solve the annoying "Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source (execution: default, phase: generate-sources)" when I place the ...

Spring MVC: Error 400 The request sent by the client was syntactically incorrect

This seems to be a common issue. I have gone all the answers given in SO but could not make it work.I am trying to integrate Spring MVC+Freemarker in already existing web application. It works fine for the GET request and Freemarker Template reads ja...

Why am I getting "Unable to find manifest signing certificate in the certificate store" in my Excel Addin?

I've got an Excel add-in project that was created a couple years back in Visual Studio 2008. It's got some changes to be made so I've upgraded to Visual Studio 2010 (the only IDE I am able to use). Not sure if this is causing the problem but it's bac...

Creating files and directories via Python

I'm having trouble creating a directory and then opening/creating/writing into a file in the specified directory. The reason seems unclear to me. I'm using os.mkdir() and path=chap_name print "Path : "+chap_path #For debugging...

Using python map and other functional tools

This is quite n00bish, but I'm trying to learn/understand functional programming in python. The following code: foos = [1.0,2.0,3.0,4.0,5.0] bars = [1,2,3] def maptest(foo, bar): print foo, bar map(maptest, foos, bars) produces: 1.0 1 2.0 2...

global variable for all controller and views

In Laravel I have a table settings and i have fetched complete data from the table in the BaseController, as following public function __construct() { // Fetch the Site Settings object $site_settings = Setting::all(); View::share('site...

Variable length (Dynamic) Arrays in Java

I was wondering how to initialise an integer array such that it's size and values change through out the execution of my program, any suggestions?...

How to use a global array in C#?

I am making an text-based adventure game for my first little project in C#. In order for my vision to work I need a few arrays that can be accessed in any of the functions. The game will only consist of a single class. And the arrays will need to be ...

jquery ajax function not working

my html goes like this , <form name="postcontent" id="postcontent"> <input name="postsubmit" type="submit" id="postsubmit" value="POST"/> <textarea id="postdata" name="postdata" placeholder="What's Up ?"></textarea> &...

HTML input textbox with a width of 100% overflows table cells

Does anyone know why the input elements with a width of 100% go over the table's cells border. In the simple example below input box go over the table's cells border, the result is horrible. This was tested and it happens in the same way on: Firefox...

Eclipse error: R cannot be resolved to a variable

I am getting this classic error in Eclipse IDE. I am bored of Eclipse's bugs. They driving me mad. I almost tried everything which suggested as solution (by Googling). None of them worked. My project was working normally but not code changes. I se...

Python: How exactly can you take a string, split it, reverse it and join it back together again?

How exactly can you take a string, split it, reverse it and join it back together again without the brackets, commas, etc. using python?...

Multi-select dropdown list in ASP.NET

Do any good multi-select dropdownlist with checkboxes (webcontrol) exist for asp.net? Thanks a lot...

Automatic creation date for Django model form objects?

What's the best way to set a creation date for an object automatically, and also a field that will record when the object was last updated? models.py: created_at = models.DateTimeField(False, True, editable=False) updated_at = models.DateTimeField(...

View google chrome's cached pictures

How can I view the pictures that Google Chrome cached on websites?...

Convert hex string to int in Python

How do I convert a hex string to an int in Python? I may have it as "0xffff" or just "ffff"....

How to get the IP address of the docker host from inside a docker container

As the title says. I need to be able to retrieve the IP address the docker hosts and the portmaps from the host to the container, and doing that inside of the container. ...

How do I remove time part from JavaScript date?

I have a date '12/12/1955 12:00:00 AM' stored in a hidden column. I want to display the date without the time. How do I do this?...

Pandas DataFrame: replace all values in a column, based on condition

I have a simple DataFrame like the following: I want to select all values from the 'First Season' column and replace those that are over 1990 by 1. In this example, only Baltimore Ravens would have the 1996 replaced by 1 (keeping the rest of the d...

How to split a dataframe string column into two columns?

I have a data frame with one (string) column and I'd like to split it into two (string) columns, with one column header as 'fips' and the other 'row' My dataframe df looks like this: row 0 00000 UNITED STATES 1 01000 ALABAMA 2 0100...

How do I round a double to two decimal places in Java?

This is what I did to round a double to 2 decimal places: amount = roundTwoDecimals(amount); public double roundTwoDecimals(double d) { DecimalFormat twoDForm = new DecimalFormat("#.##"); return Double.valueOf(twoDForm.format(d)); } This ...

How to use a jQuery plugin inside Vue

I'm building a web application inside VueJS but I encounter a problem. I want to use a jQuery extension (cropit to be specific) but I don't know how to instantiate/require/import it the right way without getting errors. I'm using de official CLI too...

How do I turn off Oracle password expiration?

I'm using Oracle for development. The password for a bootstrap account that I always use to rebuild my database has expired. How do I turn off password expiration for this user (and all other users) permanently? I'm using Oracle 11g, which has pas...

Call to getLayoutInflater() in places not in activity

What does need to be imported or how can I call the Layout inflater in places other than activity? public static void method(Context context){ //this doesn't work the getLayoutInflater method could not be found LayoutInflater inflater = getL...

How to install lxml on Ubuntu

I'm having difficulty installing lxml with easy_install on Ubuntu 11. When I type $ easy_install lxml I get: Searching for lxml Reading http://pypi.python.org/simple/lxml/ Reading http://codespeak.net/lxml Best match: lxml 2.3 Downloading http://lx...

How to use private Github repo as npm dependency

How do I list a private Github repo as a "dependency" in package.json? I tried npm's Github URLs syntaxes like ryanve/example, but doing npm install in the package folder gives "could not install" errors for the private dependencies. Is there a speci...

How to do perspective fixing?

I'm searching for a fast way to fix perspective of a picture given in java or any language.And currently i really don't have any idea how to do it, nor find anything useful in Google. Input: Point[4] , Color[][] Output: Perspective-Fixed Color[][] ...

CreateProcess: No such file or directory

I am getting this error whenever I try to run GCC outside of its installation directory (E:\MinGW\bin). So, let's say I am in E:\code and have a file called one.c. Running: gcc one.c -o one.exe will give me this error: gcc: CreateProcess: No such ...

How can I profile C++ code running on Linux?

I have a C++ application, running on Linux, which I'm in the process of optimizing. How can I pinpoint which areas of my code are running slowly?...

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

I'm working on getting my database to talk to my Java programs. Can someone give me a quick and dirty sample program using the JDBC? I'm getting a rather stupendous error: Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsEx...

Angular: conditional class with *ngClass

What is wrong with my Angular code? I am getting: Cannot read property 'remove' of undefined at BrowserDomAdapter.removeClass ... <ol class="breadcrumb"> <li *ngClass="{active: step==='step1'}" (click)="step='ste...

How to use DbContext.Database.SqlQuery<TElement>(sql, params) with stored procedure? EF Code First CTP5

I have a stored procedure that has three parameters and I've been trying to use the following to return the results: context.Database.SqlQuery<myEntityType>("mySpName", param1, param2, param3); At first I tried using SqlParameter objects as ...

Typescript: TS7006: Parameter 'xxx' implicitly has an 'any' type

In testing my UserRouter, I am using a json file data.json [ { "id": 1, "name": "Luke Cage", "aliases": ["Carl Lucas", "Power Man", "Mr. Bulletproof", "Hero for Hire"], "occupation": "bartender", "gender": "male", "height"...

Dictionaries and default values

Assuming connectionDetails is a Python dictionary, what's the best, most elegant, most "pythonic" way of refactoring code like this? if "host" in connectionDetails: host = connectionDetails["host"] else: host = someDefaultValue ...

Replace CRLF using powershell

Editor's note: Judging by later comments by the OP, the gist of this question is: How can you convert a file with CRLF (Windows-style) line endings to a LF-only (Unix-style) file in PowerShell? Here is my powershell script: $original_file ='C:\Use...

Check if element is visible in DOM

Is there any way that I can check if an element is visible in pure JS (no jQuery) ? So, for example, in this page: Performance Bikes, if you hover over Deals (on the top menu), a window of deals appear, but at the beginning it was not shown. It is i...

SQL query to make all data in a column UPPER CASE?

I need a SQL query to make all data in a column UPPER CASE? Any ideas?...

function to return a string in java

I wrote the following function to convert a time in milliseconds to a string of the format mins:seconds. Being a former C programmer I assumed that "ans" would have to be static in order to work properly, but putting static before String appears to n...

Where can I download JSTL jar

Does anyone know because all the places I've tried seem to timeout!...

Package name does not correspond to the file path - IntelliJ

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

setTimeout or setInterval?

As far as I can tell, these two pieces of javascript behave the same way: Option A: function myTimeoutFunction() { doStuff(); setTimeout(myTimeoutFunction, 1000); } myTimeoutFunction(); Option B: function myTimeoutFunction() { doStu...

Getting a union of two arrays in JavaScript

Say I have an array of [34, 35, 45, 48, 49] and another array of [48, 55]. How can I get a resulting array of [34, 35, 45, 48, 49, 55]?...

Check input value length

I have a problem with input checking. I don't want to send the request if the input length is less than 3. My form: <form method='post' action=''> Albuma nosaukums: # # this is the input --><input id='titleeee' type='text' name'albu...

Empty ArrayList equals null

Is an empty Arraylist (with nulls as its items) be considered as null? So, essentially would the below statement be true: if (arrayList != null) thanks...

Get selected text from a drop-down list (select box) using jQuery

How can I get the selected text (not the selected value) from a drop-down list in jQuery?...

Changing background color of ListView items on Android

How can I change background color of ListView items on a per-item basis. When I use android:backgroundColor in the ListView item layout I can achieve this, however the list selector is no longer visible. I can make the selector visible again by setti...

How can I pass POST parameters in a URL?

Basically, I think that I can't, but I would be very happy to be proven wrong. I am generating an HTML menu dynamically in PHP, adding one item for each current user, so that I get something like <a href="process_user.php?user=<user>>...

How do I find out if first character of a string is a number?

In Java is there a way to find out if first character of a string is a number? One way is string.startsWith("1") and do the above all the way till 9, but that seems very inefficient. ...

How to achieve ripple animation using support library?

I am trying to add a ripple animation on button click. I did like below but it requires minSdKVersion to 21. ripple.xml <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> ...

Checking from shell script if a directory contains files

From a shell script, how do I check if a directory contains files? Something similar to this if [ -e /some/dir/* ]; then echo "huzzah"; fi; but which works if the directory contains one or several files (the above one only works with exactly 0 or...

How to return a 200 HTTP Status Code from ASP.NET MVC 3 controller

I am writing an application that is accepting POST data from a third party service. When this data is POSTed I must return a 200 HTTP Status Code. How can I do this from my controller?...

SQL Query to fetch data from the last 30 days?

Hi I am new to Oracle. How do I do a simple statement, for example get product id from the last 30, or 20 days purchase date? SELECT productid FROM product WHERE purchase_date ? ...

Alternative Windows shells, besides CMD.EXE?

I don't like CMD.EXE, the built-in Windows terminal. Among its problems: Hard to copy and paste. Hard to resize the window. Hard to open another window (no menu options do this). Seems to always start in C:\Windows\System32, which is super useless....

Mobile website "WhatsApp" button to send message to a specific number

A mobile website can be customized to allow users to share a pre-filled message in WhatsApp to a manually chosen contact. As given here it is done using Custom URL Scheme. An example: <a href="whatsapp://send?text=Hello%20World!">Hello, world!...

XAMPP Apache Webserver localhost not working on MAC OS

I install XAMPP server on MAC OS 10.6 it was working fine. After a lot of days I checked it, but not working this time, localhost not opening this time. after some R&D I reinstall XAMPP server after uninstall When I start the apache after reins...

Setting focus to iframe contents

I have a page with a document.onkeydown event handler, and I'm loading it inside an iframe in another page. I have to click inside the iframe to get the content page to start "listening". Is there some way I can use JavaScript in the outer page to ...

Python Hexadecimal

How to convert decimal to hex in the following format (at least two digits, zero-padded, without an 0x prefix)? Input: 255 Output:ff Input: 2 Output: 02 I tried hex(int)[2:] but it seems that it displays the first example but not the sec...

Get exit code for command in bash/ksh

I want to write code like this: command="some command" safeRunCommand $command safeRunCommand() { cmnd=$1 $($cmnd) if [ $? != 0 ]; then printf "Error when executing command: '$command'" exit $ERROR_CODE fi } But this co...

Number of elements in a javascript object

Is there a way to get (from somewhere) the number of elements in a javascript object?? (i.e. constant-time complexity). I cant find a property or method that retrieve that information. So far I can only think of doing an iteration through the whole ...

Updating a date in Oracle SQL table

I am trying to update a date in a SQL table. I am using Peoplesoft Oracle. When I run this query: Select ASOFDATE from PASOFDATE; I get 4/16/2012 I tried running this query UPDATE PASOFDATE SET ASOFDATE = '11/21/2012'; but it is not working....

Getting Class type from String

I have a String which has a name of a class say "Ex" (no .class extension). I want to assign it to a Class variable, like this: Class cls = (string).class How can i do that?...

Change the row color in DataGridView based on the quantity of a cell value

I need to change the color of a row in datagridview but my code is not working for me. I always get a error that says "Column named Quantity: cannot be found. Parameter name: columnName" Here is my code: Private Sub DataGridView1_CellFormatting(By...

How to add column if not exists on PostgreSQL?

Question is simple. How to add column x to table y, but only when x column doesn't exist ? I found only solution here how to check if column exists. SELECT column_name FROM information_schema.columns WHERE table_name='x' and column_name='y'; ...

How to check Oracle patches are installed?

How do I check that all services and patches are installed in Oracle? I have an Oracle 10.2.0.2.0 db version and want to install patches. Also I want to get a list with all services and patches....

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

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

How to revert to origin's master branch's version of file

I'm in my local computer's master branch of a cloned master-branch of a repo from a remote server. I updated a file, and I want to revert back to the original version from the remote master branch. How can I do this?...

Error handling in C code

What do you consider "best practice" when it comes to error handling errors in a consistent way in a C library. There are two ways I've been thinking of: Always return error code. A typical function would look like this: MYAPI_ERROR getObjectSize(...

Testing pointers for validity (C/C++)

Is there any way to determine (programatically, of course) if a given pointer is "valid"? Checking for NULL is easy, but what about things like 0x00001234? When trying to dereference this kind of pointer an exception/crash occurs. A cross-platform m...

How do I sort a table in Excel if it has cell references in it?

I have a table of data in excel in sheet 1 which references various different cells in many other sheets. When I try to sort or filter the sheet, the references change when the cell moves. However, I don't want to manually go into each cell and inser...

Can I give the col-md-1.5 in bootstrap?

I want to adjust the columns in Twitter Bo?tstrap. I know in bootstrap there are 12 columns grid. Is there any way to manipulate the grids to have 1.5 3.5 3.5 3.5 instead of 3 3 3 3?...

What does <meta http-equiv="X-UA-Compatible" content="IE=edge"> do?

What's the difference if one web page starts with <!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> and If page starts with <!DOCTYPE html> <html> <head> ...

What does the 'Z' mean in Unix timestamp '120314170138Z'?

I have an X.509 certificate which has the following 2 timestamps: ['validFrom'] = String(13) "120314165227Z" ['validTo'] = String(13) "130314165227Z" What does the postfix character 'Z' mean. Does it specify the timezone?...

How to deal with SQL column names that look like SQL keywords?

One of my columns is called from. I can't change the name because I didn't make it. Am I allowed to do something like SELECT from FROM TableName or is there a special syntax to avoid the SQL Server being confused?...

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

PHP how to get local IP of system

I need to get local IP of computer like 192.*.... Is this possible with PHP? I need IP address of system running the script, but I do not need the external IP, I need his local network card address....

How to get the number of days of difference between two dates on mysql?

I need to get the number of days contained within a couple of dates on MySQL. For example: Check in date is 12-04-2010 Check out date 15-04-2010 The day difference would be 3 ...

Referenced Project gets "lost" at Compile Time

I have a C# solution with two projects: a service (the main project) and a logger. The service uses classes from the logger. I've added a Reference to the logger project within the service project. At design time, autocomplete works fine: the logger'...

How to sort a file, based on its numerical values for a field?

Example file.txt: 100 foo 2 bar 300 tuu When using sort -k 1,1 file.txt, the order of lines will not change, though we are expecting : 2 bar 100 foo 300 tuu How to sort a field consisting of numbers based on the absolute numerical v...

Creating a Plot Window of a Particular Size

How can I create a new on-screen R plot window with a particular width and height (in pixels, etc.)?...

Determine if Python is running inside virtualenv

Is it possible to determine if the current script is running inside a virtualenv environment?...

jQuery: Get height of hidden element in jQuery

I need to get height of an element that is within a div that is hidden. Right now I show the div, get the height, and hide the parent div. This seems a bit silly. Is there a better way? I'm using jQuery 1.4.2: $select.show(); optionHeight = $firstO...

SQL Server 2008 - Help writing simple INSERT Trigger

This is with Microsoft SQL Server 2008. I've got 2 tables, Employee and EmployeeResult and I'm trying to write a simple INSERT trigger on EmployeeResult that does this - each time an INSERT is done into EmployeeResult such as: (Jack, 200, Sales) (J...

What's the difference between Instant and LocalDateTime?

I know that: Instant is rather a "technical" timestamp representation (nanoseconds) for computing. LocalDateTime is rather date/clock representation including time-zones for humans. Still in the end IMO both can be taken as type for most applicat...

Java - Reading XML file

I am trying to read in some data from an XML file and having some trouble, the XML I have is as follows: <xml version="1.0" encoding="UTF-8"?> <EmailSettings> <recipient>[email protected]</recipient> <sender>test2@...

AngularJS - Multiple ng-view in single template

I am building a dynamic web app by using AngularJS. Is it possible to have multiple ng-view on a single template?...

Can you autoplay HTML5 videos on the iPad?

The <video> tags autoplay="autoplay" attribute works fine in Safari. When testing on an iPad, the video must be activated manually. I thought it was a loading issue, so I ran a loop checking for the status of the media: videoPlay: function()...

Methods vs Constructors in Java

I have just started programming with Java. The text we use is lacking when talking about methods and constructors. I'm not sure what a method or a constructor is exactly and what makes each unique. Can someone please help me define them and different...

Setting JDK in Eclipse

I have two JDKs, for Java 6 and 7. I want to build my project using both. Initially we only built against 1.6. I see in my project setting I can select 1.5, 1.6 1.7 as the compiler level. How are these options added to the IDE? I never installed Ja...

How can I parse a YAML file from a Linux shell script?

I wish to provide a structured configuration file which is as easy as possible for a non-technical user to edit (unfortunately it has to be a file) and so I wanted to use YAML. I can't find any way of parsing this from a Unix shell script however. ...

convert php date to mysql format

I have a date field in php which is using this code: $date = mysql_real_escape_string($_POST['intake_date']); How do I convert this to MySql format 0000-00-00 for inclusion in db. Is it along the lines of: date('Y-m-d' strtotime($date);. The reas...

Node.js: How to send headers with form data using request module?

I have code like the following: var req = require('request'); req.post('someUrl', { form: { username: 'user', password: '', opaque: 'someValue', logintype: '1'}, }, function (e, r, body) { console.log(body); }); How can I set headers ...

How to create exe of a console application

How can we create the exe for a console forms application ?...

Laravel migration table field's type change

Following is my file 2015_09_14_051851_create_orders_table.php. And I want to change $table->integer('category_id'); as a string with new migration. <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration;...

How can I pass a list as a command-line argument with argparse?

I am trying to pass a list as an argument to a command line program. Is there an argparse option to pass a list as option? parser.add_argument('-l', '--list', type=list, action='store', dest='list', ...

What is tail recursion?

Whilst starting to learn lisp, I've come across the term tail-recursive. What does it mean exactly?...

How to tell git to use the correct identity (name and email) for a given project?

I use my personal laptop for both work and personal projects and I would like to use my work email address for my commits at work (gitolite) and my personal email address for the rest (github). I read about the following solutions which are all eith...

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, 17:03:30) [MSC v.1900 64 bit (AMD64)] on win32 ...

Print all properties of a Python Class

I have a class Animal with several properties like: class Animal(object): def __init__(self): self.legs = 2 self.name = 'Dog' self.color= 'Spotted' self.smell= 'Alot' self.age = 10 self.kids = 0 ...

Multiple scenarios @RequestMapping produces JSON/XML together with Accept or ResponseEntity

I am working with Spring 4.0.7 About Spring MVC, for research purposes, I have the following: @RequestMapping(value="/getjsonperson", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public @Re...

iPhone/iPad browser simulator?

I need to see how my webpages are looking on an iPhone and iPad on my windows desktop. Is this possible? A quick search yielded some iPhone testing sites, which seemed like what I wanted. However, they are wildly inaccurate when I compared against m...

How to undo a successful "git cherry-pick"?

On a local repo, I've just executed git cherry-pick SHA without any conflicts or problems. I then realized I didn't want to do what I just did. I have not pushed this anywhere. How can I remove just this cherry pick? I'd like to know if there's a w...

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

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

Python for and if on one line

I have a issue with python. I make a simple list: >>> my_list = ["one","two","three"] I want create a "single line code" for find a string. for example, I have this code: >>> [(i) for i in my_list if i=="two"] ['two'] But wh...

Running Java gives "Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg'"

After years of working OK, I'm suddenly getting this message when trying to start the JVM: Error: could not open `C:\Program Files\Java\jre6\lib\amd64\jvm.cfg' I tried uninstalling, and got a message saying a DLL was missing (unspecified) Tried re...

Combining C++ and C - how does #ifdef __cplusplus work?

I'm working on a project that has a lot of legacy C code. We've started writing in C++, with the intent to eventually convert the legacy code, as well. I'm a little confused about how the C and C++ interact. I understand that by wrapping the C cod...

Meaning of ${project.basedir} in pom.xml

What is the meaning of <directory>${project.basedir}</directory> and ${project.build.directory} in pom.xml...

Counting Number of Letters in a string variable

I'm trying to count the number of letters in a string variable. I want to make a Hangman game, and I need to know how many letters are needed to match the amount in the word....

delete_all vs destroy_all?

I am looking for the best approach to delete records from a table. For instance, I have a user whose user ID is across many tables. I want to delete this user and every record that has his ID in all tables. u = User.find_by_name('JohnBoy') u.usage_i...

How to specify in crontab by what user to run script?

I have few crontab jobs that run under root, but that gives me some problems. For example all folders created in process of that cron job are under user root and group root. How can i make it to run under user www-data and group www-data so when i r...

Docker: Copying files from Docker container to host

I'm thinking of using Docker to build my dependencies on a Continuous Integration (CI) server, so that I don't have to install all the runtimes and libraries on the agents themselves. To achieve this I would need to copy the build artifacts that ar...

Changing WPF title bar background color

I have a WPF Windows application. I need to change the background color of the title bar. How can I do that?...

Download files in laravel using Response::download

In Laravel application I'm trying to achieve a button inside view that can allow user to download file without navigating to any other view or route Now I have two issues: (1) below function throwing The file "/public/download/info.pdf" does not e...

Fastest way to check if a string matches a regexp in ruby?

What is the fastest way to check if a string matches a regular expression in Ruby? My problem is that I have to "egrep" through a huge list of strings to find which are the ones that match a regexp that is given at runtime. I only care about whether...

How to get a single value from FormGroup

I am aware I can get the values of a form using JSON.stringify(this.formName.value) however, I want to get a single value from the form. How do I go about doing that?...

Excel VBA - How to Redim a 2D array?

In Excel via Visual Basic, I am iterating through a CSV file of invoices that is loaded into Excel. The invoices are in a determinable pattern by client. I am reading them into a dynamic 2D array, then writing them to another worksheet with older in...

Bind TextBox on Enter-key press

The default databinding on TextBox is TwoWay and it commits the text to the property only when TextBox lost its focus. Is there any easy XAML way to make the databinding happen when I press the Enter key on the TextBox?. I know it is pretty easy to ...

Aren't promises just callbacks?

I've been developing JavaScript for a few years and I don't understand the fuss about promises at all. It seems like all I do is change: api(function(result){ api2(function(result2){ api3(function(result3){ // do work ...

delete image from folder PHP

I have a folder where I keep my images, named img/. I have a table with all of my images: <table border="3"> <tr> <td> <?php $files = glob("img/*"); foreach ($files as $file) {...

Get IPv4 addresses from Dns.GetHostEntry()

I've got some code here that works great on IPv4 machines, but on our build server (an IPv6) it fails. In a nutshell: IPHostEntry ipHostEntry = Dns.GetHostEntry(string.Empty); The documentation for GetHostEntry says that passing in string.Empty w...

Issue with background color in JavaFX 8

Looks like there is an issue with setting background colors for panels in JavaFX 8. I had been trying the below, but none of them set the appropriate background colors. VBox panel = new VBox(); panel.setAlignment(Pos.TOP_LEFT); // None of the belo...

Python time measure function

I want to create a python function to test the time spent in each function and print its name with its time, how i can print the function name and if there is another way to do so please tell me def measureTime(a): start = time.clock() a() ...

How to send authorization header with axios

How can I send an authentication header with a token via axios.js? I have tried a few things without success, for example: const header = `Authorization: Bearer ${token}`; return axios.get(URLConstants.USER_URL, { headers: { header } }); Gives me...

Subprocess check_output returned non-zero exit status 1

This is my python code: import subprocess subprocess.check_output("ls",shell=True,stderr=subprocess.STDOUT) import subprocess subprocess.check_output("yum",shell=True,stderr=subprocess.STDOUT) The first .check_output() works well, but the second ...

Escaping backslash in string - javascript

I need to show the name of the currently selected file (in <input type="file"> element). Everything is fine, the only problem is I'm getting this kind of string "C:\fakepath \typog_rules.pdf" (browset automatically puts this as value for the ...

Jackson enum Serializing and DeSerializer

I'm using JAVA 1.6 and Jackson 1.9.9 I've got an enum public enum Event { FORGOT_PASSWORD("forgot password"); private final String value; private Event(final String description) { this.value = description; } @JsonValue...

Is the MIME type 'image/jpg' the same as 'image/jpeg'?

Pretty simple question but can't seem to find it anywhere online. I'm trying to make a program that depending on the file type will give me the extension....

Java NIO: What does IOException: Broken pipe mean?

For some of my Java NIO connections, when I have a SocketChannel.write(ByteBuffer) call, it throws an IOException: "Broken pipe". What causes a "broken pipe", and, more importantly, is it possible to recover from that state? If it cannot be recovere...

Recursively look for files with a specific extension

I'm trying to find all files with a specific extension in a directory and its subdirectories with my bash (Latest Ubuntu LTS Release). This is what's written in a script file: #!/bin/bash directory="/home/flip/Desktop" suffix="in" browsefolders (...

How do I use Safe Area Layout programmatically?

Since I don't use storyboards to create my views, I was wondering if there's the "Use Safe Area Guides" option programmatically or something like that. I've tried to anchor my views to view.safeAreaLayoutGuide but they keep overlapping the top n...

Automate scp file transfer using a shell script

I have some n number of files in a directory on my unix system. Is there a way to write a shellscript that will transfer all those files via scp to a specified remote system. I'll specify the password within the script, so that I don't have to enter ...

Merge/flatten an array of arrays

I have a JavaScript array like: [["$6"], ["$12"], ["$25"], ["$25"], ["$18"], ["$22"], ["$10"]] How would I go about merging the separate inner arrays into one like: ["$6", "$12", "$25", ...] ...

How to run a task when variable is undefined in ansible?

I am looking for a way to perform a task when ansible variable is not registers /undefined e.g -- name: some task command: sed -n '5p' "{{app.dirs.includes}}/BUILD.info" | awk '{print $2}' when: (! deployed_revision) AND ( !deployed_revisio...

Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()'

Update: same for mvc 4 to mvc 5. I started a new mvc 4 project and migrated an mvc 3 project in it (controllers/models/scripts etc). While everything compiles now i get the following error: Attempt by security transparent method 'WebMatrix.WebDa...

How can I limit possible inputs in a HTML5 "number" element?

For <input type="number"> element, maxlength is not working. How can I restrict the maxlength for that number element?...

Why should you use strncpy instead of strcpy?

Edit: I've added the source for the example. I came across this example: char source[MAX] = "123456789"; char source1[MAX] = "123456789"; char destination[MAX] = "abcdefg"; char destination1[MAX] = "abcdefg"; char *return_string; int index = 5; /*...

Set max-height on inner div so scroll bars appear, but not on parent div

I have my HTML, CSS set up as per the code below. I have also added a JSFiddle link since it will be far more convenient to see the code in action. The problem I'm having is that when there is a lot of text in the #inner-right div within the #right-...

Generating Random Passwords

When a user on our site loses his password and heads off to the Lost Password page we need to give him a new temporary password. I don't really mind how random this is, or if it matches all the "needed" strong password rules, all I want to do is give...

How to Get XML Node from XDocument

How to Get an XML Element from XDocument using LINQ ? Suppose I have an XDocument Named XMLDoc which is shown below: <Contacts> <Node> <ID>123</ID> <Name>ABC</Name> </Node&g...

Axios get access to response header fields

I'm building a frontend app with React and Redux and I'm using axios to perform my requests. I would like to get access to all the fields in the header of the response. In my browser I can inspect the header and I can see that all the fields that I n...

Char to int conversion in C

If I want to convert a single numeric char to it's numeric value, for example, if: char c = '5'; and I want c to hold 5 instead of '5', is it 100% portable doing it like this? c = c - '0'; I heard that all character sets store the numbers in co...

makefiles - compile all c files at once

I want to experiment with GCC whole program optimizations. To do so I have to pass all C-files at once to the compiler frontend. However, I use makefiles to automate my build process, and I'm not an expert when it comes to makefile magic. How should...

Limit the size of a file upload (html input element)

I would like to simply limit the size of a file that a user can upload. I thought maxlength = 20000 = 20k but that doesn't seem to work at all. I am running on Rails, not PHP, but was thinking it'd be much simpler to do it client side in the HTML...

How can I make a div stick to the top of the screen once it's been scrolled to?

I would like to create a div, that is situated beneath a block of content but that once the page has been scrolled enough to contact its top boundary, becomes fixed in place and scrolls with the page....

CSS3 selector :first-of-type with class name?

Is it possible to use the CSS3 selector :first-of-type to select the first element with a given class name? I haven't been successful with my test so I'm thinking it's not? The Code (http://jsfiddle.net/YWY4L/): _x000D_ _x000D_ p:first-of-type {col...

How can I make a CSS glass/blur effect work for an overlay?

I am having trouble applying a blur effect on a semi-transparent overlay div. I'd like everything behind the div the be blurred, like this: Here is a jsfiddle which doesn't work: http://jsfiddle.net/u2y2091z/ Any ideas how to make this work? I'd ...

How do I hide an element on a click event anywhere outside of the element?

I would like to know whether this is the correct way of hiding visible elements when clicked anywhere on the page. $(document).click(function (event) { $('#myDIV:visible').hide(); }); The element (div, span, etc.) shouldn't disapp...

Which websocket library to use with Node.js?

Currently there is a plethora of websocket libraries for node.js, the most popular seem to be: https://github.com/Worlize/WebSocket-Node https://github.com/einaros/ws https://github.com/LearnBoost/engine.io https://github.com/learnboost/socket.io h...

Extract a substring using PowerShell

How can I extract a substring using PowerShell? I have this string ... "-----start-------Hello World------end-------" I have to extract ... Hello World What is the best way to do that?...

What is IPV6 for localhost and 0.0.0.0?

As we all know the IPv4 address for localhost is 127.0.0.1 (loopback address). What is the IPv6 address for localhost and for 0.0.0.0 as I need to block some ad hosts....

Prevent Caching in ASP.NET MVC for specific actions using an attribute

I have an ASP.NET MVC 3 application. This application requests records through jQuery. jQuery calls back to a controller action that returns results in JSON format. I have not been able to prove this, but I'm concerned that my data may be getting cac...

Handling InterruptedException in Java

What is the difference between the following ways of handling InterruptedException? What is the best way to do it? try{ //... } catch(InterruptedException e) { Thread.currentThread().interrupt(); } OR try{ //... } catch(InterruptedExceptio...

SQL Server IN vs. EXISTS Performance

I'm curious which of the following below would be more efficient? I've always been a bit cautious about using IN because I believe SQL Server turns the result set into a big IF statement. For a large result set, this could result in poor performance...

check for null date in CASE statement, where have I gone wrong?

My source table looks like this Id StartDate 1 (null) 2 12/12/2009 3 10/10/2009 I want to create a select statement, that selects the above, but also has an additional column to display a varchar if the date is not null such as ...

Strings and character with printf

I was confused with usage of %c and %s in the following C program #include <stdio.h> void main() { char name[]="siva"; printf("%s\n",name); printf("%c\n",*name); } Output is siva s Why we need to...

Laravel-5 how to populate select box from database with id value and name value

I want to create a select box like the one below using illuminate\html : <select> <option value="$item->id">$item->name</option> <option value="$item->id">$item->name</option> </select> In my...

How can I check if a scrollbar is visible?

Is it possible to check the overflow:auto of a div? For example: HTML <div id="my_div" style="width: 100px; height:100px; overflow:auto;" class="my_class"> * content </div> JQUERY $('.my_class').live('hover', function (event) { ...

JavaScript ES6 promise for loop

for (let i = 0; i < 10; i++) { const promise = new Promise((resolve, reject) => { const timeout = Math.random() * 1000; setTimeout(() => { console.log(i); }, timeout); }); // TODO: Chain this ...

powershell - list local users and their groups

I'd like to have a report with all the local users and their relative groups (users, power users, administrators and so on. I get the users in this way: $adsi = [ADSI]"WinNT://." $adsi.psbase.children | where {$_.psbase.schemaClassName -match "user...

Switch: Multiple values in one case?

I have the following piece of code, but yet when I enter "12" I still get "You an old person". Isn't 9 - 15 the numbers 9 UNTIL 15? How else do I handle multiple values with one case? int age = Convert.ToInt32(txtBoxAge.Text); switch (age) ...

How can I recognize touch events using jQuery in Safari for iPad? Is it possible?

Is it possible to recognize touch events on the iPad's Safari browser using jQuery? I used mouseOver and mouseOut events in a web application. Are there any similar events for the iPad's Safari browser since there are no events like mouseOut and mo...

using "if" and "else" Stored Procedures MySQL

I'm having some difficulties when trying to create this stored procedure, any kind of help is welcome: create procedure checando(in nombrecillo varchar(30), in contrilla varchar(30), out resultado int) begin if exists (select * from compas where ...

OSX -bash: composer: command not found

If i type "composer" i get the above error message. I did on my macbook: curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer to install Composer globally. I had to manually create the /local/bin/compose...

access key and value of object using *ngFor

I am a bit confused about how to get the key and value of an object in angular2 while using *ngFor for iterating over the object. I know in angular 1.x there is a syntax like ng-repeat="(key, value) in demo" but I don't know how to do the same in...

LaTeX Optional Arguments

How do you create a command with optional arguments in LaTeX? Something like: \newcommand{\sec}[2][]{ \section*{#1 \ifsecondargument and #2 \fi} } } Then, I can call it like \sec{Hello} %Output: Hello \sec{Hell...

Make an image follow mouse pointer

I need a rocket to follow the movements of the mouse pointer on my website. This means it should rotate to face the direction of motion, and if possible, accelerate depending on the distance it has to cover. Is this even possible ? jquery perhaps ?...

Disable scrolling in all mobile devices

This sounds like there should be a solution for it all over the internet, but I am not sure why I cannot find it. I want to disable Horizontal scrolling on mobile devices. Basically trying to achieve this: body{ overflow-x:hidden // disable hori...

How to assign a NULL value to a pointer in python?

I am C programmer. I am new to python. In C , when we define the structure of a binary tree node we assign NULL to it's right and left child as : struct node { int val; struct node *right ; struct node *left ; }; And when i...

jQuery: Get selected element tag name

Is there an easy way to get a tag name? For example, if I am given $('a') into a function, I want to get 'a'....

How do I get the number of days between two dates in JavaScript?

How do I get the number of days between two dates in JavaScript? For example, given two dates in input boxes: <input id="first" value="1/1/2000"/> <input id="second" value="1/1/2001"/> <script> alert(datediff("day", first, secon...

Remove 'b' character do in front of a string literal in Python 3

I am new in python programming and i am a bit confused. I try to get the bytes from a string to hash and encrypt but i got b'...' b character in front of string just like the below example. Is any way avoid this?.Can anyone give a solution? Sorry...

Does java have a int.tryparse that doesn't throw an exception for bad data?

Possible Duplicate: Java: Good way to encapsulate Integer.parseInt() how to convert a string to float and avoid using try/catch in java? C# has Int.TryParse: Int32.TryParse Method (String, Int32%) The great thing with this method is tha...

How to Implement DOM Data Binding in JavaScript

Please treat this question as strictly educational. I'm still interested in hearing new answers and ideas to implement this tl;dr How would I implement bi-directional data-binding with JavaScript? Data Binding to the DOM By data binding to the DO...

Compare dates with javascript

I have two dates in javascript: var first = '2012-11-21'; var second = '2012-11-03'; i would like make: if(first > second){ //... } how is the best way for this, without external library?...

How to query a MS-Access Table from MS-Excel (2010) using VBA

I am trying to write some vba code in Excel to query a table in Access. I have tried multiple code samples for this such as the added links and they all seem to fail at the "Open connection" part. I have tried using different references but I'm not s...

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

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

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

Node version is v0.11.13 Memory usage during crash according to sudo top not raises over 3% Code that reproduces this error: var request = require('request') var nodedump = require('nodedump') request.get("http://pubapi.cryptsy.com/api.php?method...

How to return a result from a VBA function

How do I return a result from a function? For example: Public Function test() As Integer return 1 End Function This gives a compile error. How do I make this function return an integer?...

Converting java.sql.Date to java.util.Date

What's the simplest way to convert a java.sql.Date object to a java.util.Date while retaining the timestamp? I tried: java.util.Date newDate = new Date(result.getDate("VALUEDATE").getTime()); with no luck. It's still only storing the date portion...

How to get annotations of a member variable?

I want to know a class's some member variable's annotations , I use BeanInfo beanInfo = Introspector.getBeanInfo(User.class) to introspect a class , and use BeanInfo.getPropertyDescriptors() , to find specific property , and use Class type = property...

How do I download a file with Angular2 or greater

I have a WebApi / MVC app for which I am developing an angular2 client (to replace MVC). I am having some troubles understanding how Angular saves a file. The request is ok (works fine with MVC, and we can log the data received) but I can't figure o...

gitx How do I get my 'Detached HEAD' commits back into master

Using Git X and must have fumbled royally on something. Looks like a few days ago I created a branch called detached HEAD and have been committing to it. My normal process is to commit to master and then push that to origin. But I can't push detac...

How can I disable the default console handler, while using the java logging API?

Hi I am trying to implement the java logging in my application. I want to use two handlers. A file handler and my own console handler. Both of my handlers work fine. My logging is send to a file and to the console . My logging is also sent to the de...

Handling warning for possible multiple enumeration of IEnumerable

In my code in need to use an IEnumerable<> several times thus get the Resharper error of "Possible multiple enumeration of IEnumerable". Sample code: public List<object> Foo(IEnumerable<object> objects) { if (objects == null |...

How to initialize log4j properly?

After adding log4j to my application I get the following output every time I execute my application: log4j:WARN No appenders could be found for logger (slideselector.facedata.FaceDataParser). log4j:WARN Please initialize the log4j system properly. ...

Why can't DateTime.Parse parse UTC date

Why can't it parse this: DateTime.Parse("Tue, 1 Jan 2008 00:00:00 UTC") ...

What do the return values of Comparable.compareTo mean in Java?

What is the difference between returning 0, returning 1 and returning -1 in compareTo() in Java?...

Using Font Awesome icon for bullet points, with a single list item element

We'd like to be able to use a Font Awesome ( http://fortawesome.github.com/Font-Awesome/ ) icon as a bullet point for unordered lists in a CMS. The text editor on the CMS only outputs raw HTML so additional elements/ classes cannot be added. This m...

How to create a global variable?

I have a global variable that needs to be shared among my ViewControllers. In Objective-C, I can define a static variable, but I can't find a way to define a global variable in Swift. Do you know of a way to do it?...

Merge 2 DataTables and store in a new one

If I have 2 DataTables (dtOne and dtTwo) and I want to merge them and put them in another DataTable (dtAll). How can I do this in C#? I tried the Merge statement on the datatable, but this returns void. Does Merge preserve the data? For example, ...

Order of items in classes: Fields, Properties, Constructors, Methods

Is there an official C# guideline for the order of items in terms of class structure? Does it go: Public Fields Private Fields Properties Constructors Methods ? I'm curious if there is a hard and fast rule about the order of items? I'm kind of a...

ImageView - have height match width?

I have an imageview. I want its width to be fill_parent. I want its height to be whatever the width ends up being. For example: <ImageView android:layout_width="fill_parent" android:layout_height="whatever the width ends up being" /> Is ...

Git - What is the difference between push.default "matching" and "simple"

I have been using git for a while now, but I have never had to set up a new remote repo myself and I have been curious on doing so. I have been reading tutorials and I am confused on how to get "git push" to work. If I simply use git push it asks m...

Debugging doesn't start

When I hit F5 (debugging mode) nothing happens. Building works correctly, exe file I can launch properly, but can't start debug. Why?...

SQL MERGE statement to update data

I've got a table with data named energydata it has just three columns (webmeterID, DateTime, kWh) I have a new set of updated data in a table temp_energydata. The DateTime and the webmeterID stay the same. But the kWh values need updating from t...

Table Height 100% inside Div element

Hi I want to set table height 100% to its parent div without define height in div. My code is not working. I dont know what I am missing. Fiddle link <div style="overflow:hidden"> <div style="float:left">a<br />b</div> <ta...

Regex date format validation on Java

I'm just wondering if there is a way (maybe with regex) to validate that an input on a Java desktop app is exactly an string formated as: "YYYY-MM-DD". I've searched but with no success. Thank you...

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

How to parse JSON to receive a Date object in JavaScript?

I have a following piece of JSON: \/Date(1293034567877)\/ which is a result of this .NET code: var obj = DateTime.Now; var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); serializer.Serialize(obj).Dump(); Now the prob...

CSS background image in :after element

I'm trying to create a CSS button and add an icon to it using :after, but the image never shows up. If I replace the 'background' property with 'background-color:red' then a red box appears so I'm not sure what's wrong here. HTML: <a class="butt...

Why I get 'list' object has no attribute 'items'?

Using Python 2.7, I have this list: qs = [{u'a': 15L, u'b': 9L, u'a': 16L}] I'd like to extract values out of it. i.e. [15, 9, 16] So I tried: result_list = [int(v) for k,v in qs.items()] But instead, I get this error: Traceback (most recen...

Copy-item Files in Folders and subfolders in the same directory structure of source server using PowerShell

I am struggling really hard to get this below script worked to copy the files in folders and sub folders in the proper structure (As the source server). Lets say, there are folders mentioned below: Main Folder: File aaa, File bbb Sub Folder a: Fil...

How can I determine whether a 2D Point is within a Polygon?

I'm trying to create a fast 2D point inside polygon algorithm, for use in hit-testing (e.g. Polygon.contains(p:Point)). Suggestions for effective techniques would be appreciated....

How does a hash table work?

I'm looking for an explanation of how a hash table works - in plain English for a simpleton like me! For example, I know it takes the key, calculates the hash (I am looking for an explanation how) and then performs some kind of modulo to work out w...

How to perform OR condition in django queryset?

I want to write a Django query equivalent to this SQL query: SELECT * from user where income >= 5000 or income is NULL. How to construct the Django queryset filter? User.objects.filter(income__gte=5000, income=0) This doesn't work, because i...

SQL select max(date) and corresponding value

Possible Duplicate: How to get the record of a table who contains the maximum value? I've got an aggregate query like the following: SELECT TrainingID, Max(CompletedDate) as CompletedDate, Max(Notes) as Notes --This will only return t...

Conditionally displaying JSF components

First, I am new to Java EE, came from a strong ASP .NET development background. I have gone through the net, and I might miss this but it seems like there is no simple and straight-to-the-point tutorials on how I could connect backing bean class to a...

Find Locked Table in SQL Server

How can we find which table is locked in the database? Please, suggest....

How to change a PG column to NULLABLE TRUE?

How can I accomplish this using Postgres? I've tried the code below but it doesn't work: ALTER TABLE mytable ALTER COLUMN mycolumn BIGINT NULL; ...

Invalid default value for 'dateAdded'

I got a stupid problem with SQL that I can't fix. ALTER TABLE `news` ADD `dateAdded` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AUTO_INCREMENT , ADD PRIMARY KEY ( `dateAdded` ) Error: (#1067)Invalid default value for 'dateAdded' Can som...

Get all photos from Instagram which have a specific hashtag with PHP

I need to get some pictures which have a specific hashtag using PHP ? Any help will be awesome, or hint ?...

The mysqli extension is missing. Please check your PHP configuration

I have looked through all of the forums that I could find relevant to this question and my problem yet nothing works. I have apache2.2 with php5, phpMyAdmin, and MySQL. I have uncommented the extension, I have checked my phpinfo() and mysqli does not...

Responsive css styles on mobile devices ONLY

I'm trying to make my responsive CSS styles work only on tablets and smartphones. Basically I have a style for desktop, a style for mobile: portrait and a style for mobile: landscape. I don't want the mobile styles interfering with the desktop presen...

Setting environment variables for accessing in PHP when using Apache

I have a Linux environment and I have a PHP Web Application that conditionally runs based on environment variables using getenv in PHP. I need to know how these environment variables need to be set for the application to work correctly. I am not sure...

How to connect to a remote MySQL database with Java?

I am trying to create a JSF application using the Eclipse IDE. I am using a remote mySQL server as my database. How do I connect to this remote database for creating tables and accessing them?...

How large is a DWORD with 32- and 64-bit code?

In Visual C++ a DWORD is just an unsigned long that is machine, platform, and SDK dependent. However, since DWORD is a double word (that is 2 * 16), is a DWORD still 32-bit on 64-bit architectures?...

Select single item from a list

Using LINQ what is the best way to select a single item from a list if the item may not exists in the list? I have come up with two solutions, neither of which I like. I use a where clause to select the list of items (which I know will only be one)...

How to commit changes to a new branch

I just made changes to a branch. How can I commit the changes to the other branch? I am trying to use: git checkout "the commmit to the changed branch" -b "the other branch" However, I don't think this is the right thing to do, because in this ca...

String.Format for Hex

With below code, the colorsting always gives #DDDD. Green, Red and Space values int he How to fix this? string colorstring; int Blue = 13; int Green = 0; int Red = 0; int Space = 14; colorstring = String.Format("#{0:X}{0:X}{0:X}{0:X}", Blue, Green, ...

How to check the version of GitLab?

How to check which version of GitLab is installed on the server? I am about version specified in GitLab changelog: https://gitlab.com/gitlab-org/gitlab-foss/blob/master/CHANGELOG.md For example: "6.5.0", "6.4.3", etc. ?an this be done only thro...

How to calculate the 95% confidence interval for the slope in a linear regression model in R

Here is an exercise from Introductory Statistics with R: With the rmr data set, plot metabolic rate versus body weight. Fit a linear regression model to the relation. According to the fitted model, what is the predicted metabolic rate for a body wei...

Add support library to Android Studio project

I just installed the new Android Studio and I'm looking for a way to import the support library for Android. Where is the option for that? In Eclipse that are just two clicks. I googled for it but found nothing. Surely it is too new....

How to solve '...is a 'type', which is not valid in the given context'? (C#)

The following code produces the error: Error : 'CERas.CERAS' is a 'type', which is not valid in the given context Why does this error occur? using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace W...

Keep SSH session alive

I use ssh -p8520 username@remote_host to login remote server. Issue: It is always connected and works properly when I am in the work place. Unfortunately, terminal freezes in 10 - 15 minutes after I connected with the remote server from home. The...

How to change port number in vue-cli project

How to change Port number in Vue-cli project so that it run's on another port instead of 8080....

How to save an HTML5 Canvas as an image on a server?

I'm working on a generative art project where I would like to allow users to save the resulting images from an algorithm. The general idea is: Create an image on an HTML5 Canvas using a generative algorithm When the image is completed, allow users ...

How to import or copy images to the "res" folder in Android Studio?

I can save all my images directly in the res/drawable-xxx folder. But how can I import/copy images to my project from Android Studio? If I drag an drop my images from the Finder (MacOS), the files only move to the res folder. At in the context-me...

What is git tag, How to create tags & How to checkout git remote tag(s)

when I checkout remote git tag use command like this: git checkout -b local_branch_name origin/remote_tag_name I got error like this: error: pathspec `origin/remote_tag_name` did not match any file(s) known to git. I can find remote_tag_name wh...

How to label scatterplot points by name?

I am trying to figure out how to get labels to show on either Google sheets, Excel, or Numbers. I have information that looks like this name|x_val|y_val ---------------- a | 1| 1 b | 2| 4 c | 1| 2 Then I would want my fina...

Java - Check if JTextField is empty or not

So I got know this is a popular question and already found the solution. But when I try this it doesn't work properly. My JTextField is empty and the button isn't enabled. When I write something in my textfield the button doesn't get enabled. So m...

Using Spring RestTemplate in generic method with generic parameter

To use generic types with Spring RestTemplate we need to use ParameterizedTypeReference (Unable to get a generic ResponseEntity<T> where T is a generic class "SomeClass<SomeGenericType>") Suppose I have some class public class...

Why won't bundler install JSON gem?

I get the following error when attempting to run cap production deploy. DEBUG [dc362284] Bundler::GemNotFound: Could not find json-1.8.1.gem for installation DEBUG [dc362284] An error occurred while installing json (1.8.1), and Bundler cannot...

FileProvider - IllegalArgumentException: Failed to find configured root

I'm trying to take a picture with camera, but I'm getting the following error: FATAL EXCEPTION: main Process: com.example.marek.myapplication, PID: 6747 java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulat...

How/when to generate Gradle wrapper files?

I am trying to understand how the Gradle Wrapper works. In many source repos, I see the following structure: projectRoot/ src/ build.gradle gradle.properties settings.gradle gradlew gradlew.bat gradle/ wrapper/ ...

How to destroy a DOM element with jQuery?

Suppose the jQuery object is $target....

rbind error: "names do not match previous names"

As part of a larger problem (adding a ,makeUniqueIDs argument to rbind.SpatialPolygonsDataFrame for situations when the polygon IDs are identical), I'm running into this weird message from rbind: > do.call("rbind",xd.small) Error in match.names(c...

Resize Cross Domain Iframe Height

I'm trying to change the iframe height parameter to the same px of the page being loaded within the iframe. The page that's being loaded in the iframe is coming from another domain. Different pages will be loaded up inside of the iframe causing the ...

boto3 client NoRegionError: You must specify a region error only sometimes

I have a boto3 client : boto3.client('kms') But it happens on new machines, They open and close dynamically. if endpoint is None: if region_name is None: # Raise a more specific error message that will give # ...

How to suspend/resume a process in Windows?

In Unix we can suspend a process execution temporarily and resume it with signals SIGSTOP and SIGCONT. How can I suspend a single-threaded process in Windows without programming ? ...

Cannot connect to Database server (mysql workbench)

Could you help me solve this problem ? When I try to click "query database" under database menu in Mysql workbench. it gives me an error: Cannot Connect to Database Server Your connection attempt failed for user 'root' from your host to server at ...

What is the best way to compare 2 folder trees on windows?

I'm moving a repository from sourcesafe to subversion and I need to ensure that vital points are equal. Is it any existing command / tool for windows that allows me to compare two folder trees that they are equal (has equal folder structure and files...

What is /dev/null 2>&1?

I found this piece of code in /etc/cron.daily/apf #!/bin/bash /etc/apf/apf -f >> /dev/null 2>&1 /etc/apf/apf -s >> /dev/null 2>&1 It's flushing and reloading the firewall. I don't understand the >> /dev/nu...

Is there a RegExp.escape function in JavaScript?

I just want to create a regular expression out of any possible string. var usersString = "Hello?!*`~World()[]"; var expression = new RegExp(RegExp.escape(usersString)) var matches = "Hello".match(expression); Is there a built-in ...

When do I need a fb:app_id or fb:admins?

The doc for the facebook like button says , "When your Web page represents a real-world entity, things like movies, sports teams, celebrities, and restaurants, use the Open Graph protocol to specify information about the entity." I'm adding like but...

Execute command on all files in a directory

Could somebody please provide the code to do the following: Assume there is a directory of files, all of which need to be run through a program. The program outputs the results to standard out. I need a script that will go into a directory, execute t...

Error 1046 No database Selected, how to resolve?

Error SQL query: -- -- Database: `work` -- -- -------------------------------------------------------- -- -- Table structure for table `administrators` -- CREATE TABLE IF NOT EXISTS `administrators` ( `user_id` varchar( 30 ) NOT NULL , `password` ...

wget: unable to resolve host address `http'

I am getting this strange thing on my Ubuntu 12.04 64-bit machine when I do a wget $ wget google.com --2014-07-18 14:44:32-- http://google.com/ Resolving http (http)... failed: Name or service not known. wget: unable to resolve host address `htt...

Adding blur effect to background in swift

I am setting a background image to view controller. But also i want to add blur effect to this background. How can I do this? I am setting background with following code: self.view.backgroundColor = UIColor(patternImage: UIImage(named: "testBg")!) ...

Check if registry key exists using VBScript

I thought this would be easy, but apparently nobody does it... I'm trying to see if a registry key exists. I don't care if there are any values inside of it such as (Default). This is what I've been trying. Set objRegistry = GetObject("winmgmts:\\....

Custom Listview Adapter with filter Android

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

How to increase space between dotted border dots

I am using dotted style border in my box like .box { width: 300px; height: 200px; border: dotted 1px #f00; float: left; } I want to the increase the space between each dot of the border....

Cast Int to enum in Java

What is the correct way to cast an Int to an enum in Java given the following enum? public enum MyEnum { EnumValue1, EnumValue2 } MyEnum enumValue = (MyEnum) x; //Doesn't work??? ...

How to convert a string with Unicode encoding to a string of letters

I have a string with escaped Unicode characters, \uXXXX, and I want to convert it to regular Unicode letters. For example: "\u0048\u0065\u006C\u006C\u006F World" should become "Hello World" I know that when I print the first string it already s...

Reverse Contents in Array

I have an array of numbers that I am trying to reverse. I believe the function in my code is correct, but I cannot get the proper output. The output reads: 10 9 8 7 6. Why can't I get the other half of the numbers? When I remove the "/2" from count,...

Best practice to validate null and empty collection in Java

I want to verify whether a collection is empty and null. Could anyone please let me know the best practice. Currently, I am checking as below: if (null == sampleMap || sampleMap.isEmpty()) { // do something } else { // do something else } ...

Convert date time string to epoch in Bash

The date time string is in the following format: 06/12/2012 07:21:22. How can I convert it to UNIX timestamp or epoch?...

Can I load a UIImage from a URL?

I have a URL for an image (got it from UIImagePickerController) but I no longer have the image in memory (the URL was saved from a previous run of the app). Can I reload the UIImage from the URL again? I see that UIImage has a imageWithContentsOf...

Count unique values in a column in Excel

I have an .xls file with a column with some data. How do I count how many unique values contains this column? I have googled many options, but the formulas they give there always give me errors. For example, =INDEX(List, MATCH(MIN(IF(COUNTIF($B$1:...

How can I create and style a div using JavaScript?

How can I use JavaScript to create and style (and append to the page) a div, with content? I know it's possible, but how?...

Reason: no suitable image found

dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /var/mobile/Containers/Bundle/Application/3FC2DC5C-A908-42C4-8508-1320E01E0D5B/Stylist.app/Stylist Reason: no suitable image found. Did find: /private/var/mobile/Containers...

How to set 24-hours format for date on java?

I have been developing Android application where I use this code: Date d=new Date(new Date().getTime()+28800000); String s=new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(d); I need to get date after 8 hours from current moment, and I want that...

How do you underline a text in Android XML?

How do you underline a text in an XML file? I can't find an option in textStyle....

How can I count the occurrences of a list item?

Given an item, how can I count its occurrences in a list in Python?...

Are PostgreSQL column names case-sensitive?

I have a db table say, persons in Postgres handed down by another team that has a column name say, "first_Name". Now am trying to use PG commander to query this table on this column-name. select * from persons where first_Name="xyz"; And it just r...

javax.naming.NameNotFoundException: Name is not bound in this Context. Unable to find

I'm trying to find out why my web application throws a javax.naming.NameNotFoundException: Name [flexeraDS] is not bound in this Context. Unable to find [flexeraDS]. when a sister one from which I'm copying the configuration quietly runs. I have...

Why use Redux over Facebook Flux?

I've read this answer, reducing boilerplate, looked at few GitHub examples and even tried redux a little bit (todo apps). As I understand, official redux doc motivations provide pros comparing to traditional MVC architectures. BUT it doesn't provid...

How to set custom JsonSerializerSettings for Json.NET in ASP.NET Web API?

I understand that ASP.NET Web API natively uses Json.NET for (de)serializing objects, but is there a way to specify a JsonSerializerSettings object that you want for it to use? For example, what if I wanted to include type information into the seri...

Reading file contents on the client-side in javascript in various browsers

I'm attempting to provide a script-only solution for reading the contents of a file on a client machine through a browser. I have a solution that works with Firefox and Internet Explorer. It's not pretty, but I'm only trying things at the moment: ...

TypeError: worker() takes 0 positional arguments but 1 was given

I'm trying to implement a subclass and it throws the error: TypeError: worker() takes 0 positional arguments but 1 was given class KeyStatisticCollection(DataDownloadUtilities.DataDownloadCollection): def GenerateAddressStrings(self): ...

How to get a URL parameter in Express?

I am facing an issue on getting the value of tagid from my URL: localhost:8888/p?tagid=1234. Help me out to correct my controller code. I am not able to get the tagid value. My code is as follows: app.js: var express = require('express'), http ...

Find out whether radio button is checked with JQuery?

I can set a radio button to checked fine, but what I want to do is setup a sort of 'listener' that activates when a certain radio button is checked. Take, for example the following code: $("#element").click(function() { $('#radio_button').at...

Disable building workspace process in Eclipse

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

what is the difference between GROUP BY and ORDER BY in sql

When do you use which in general? Examples are highly encouraged! I am referring so MySql, but can't imagine the concept being different on another DBMS...

unix sort descending order

I want to sort a tab limited file in descending order according to the 5th field of the records. I tried sort -r -k5n filename But it didn't work....

How can I schedule a daily backup with SQL Server Express?

I'm running a small web application with SQL server express (2005) as backend. I can create a backup with a SQL script, however, I'd like to schedule this on a daily basis. As extra option (should-have) I'd like to keep only the last X backups (for ...

SQL Server: Filter output of sp_who2

Under SQL Server, is there an easy way to filter the output of sp_who2? Say I wanted to just show rows for a certain database, for example....

Convert DateTime to String PHP

I have already researched a lot of site on how can I convert PHP DateTime object to String. I always see "String to DateTime" and not "DateTime to String" PHP DateTime can be echoed, but what i want to process my DateTime with PHP string functions....

Where is nodejs log file?

I can't find a place where nodejs log file is stored. Because in my node server I have "Segmentation fault", I want to look at log file for additional info......

Calculate distance in meters when you know longitude and latitude in java

Possible Duplicate: Working with latitude/longitude values in Java Duplicate: Working with latitude/longitude values in Java How do I calculate distance between two latitude longitude points? I need to calculate the distance between two points g...

Removing space from dataframe columns in pandas

I am trying to remove spaces from a dataframe I have. The columns names look like below. I am trying to get the spaces between name out and replace it with "_" wherever present. ['join_date' 'fiscal_quarter' 'fiscal_year' 'primary_channel' 'seconda...

Why Java Calendar set(int year, int month, int date) not returning correct date?

According to doc, calendar set() is: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html#set%28int,%20int,%20int%29 set(int year, int month, int date) Sets the values for the calendar fields YEAR, MONTH, and DAY_OF_MONTH. code: ...

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'

Suddenly when Syncing Gradle, I get this error: WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'. It will be removed at the end of 2019. For more information, see http...

How to Delete a topic in apache kafka

I need to delete a topic in kafka-0.8.2.2.3. I have used the below command for deleting the topic: bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic DummyTopic The command executed successfully but when I run a command to list the to...

Get the decimal part from a double

I want to receive the number after the decimal dot in the form of an integer. For example, only 05 from 1.05 or from 2.50 only 50 not 0.50...

Windows cannot find 'http:/.127.0.0.1:%HTTPPORT%/apex/f?p=4950'. Make sure you typed the name correctly, and then try again

I am trying to install Oracle Express 11g, after I download the zip file OracleXE112_Win64 - I unzip it, and open Disk 1 then setup. I go through the entire installation process without any problems. However when I go to open "Get Started" I come acr...

What is the purpose of nameof?

Version 6.0 got a new feature of nameof, but I can't understand the purpose of it, as it just takes the variable name and changes it to a string on compilation. I thought it might have some purpose when using <T> but when I try to nameof(T) it...

Moment JS - check if a date is today or in the future

I am trying to use momentjs to check if a given date is today or in the future. This is what I have so far: <script type="text/javascript" src="http://momentjs.com/downloads/moment.min.js"></script> <script type="text/javascript">...

Generating a WSDL from an XSD file

I need to generate a WSDL file given an XSD file. How do I do this? Can I do this in VS2005? What is the simplest way to do this?...

How do I get the Session Object in Spring?

I am relatively new to Spring and Spring security. I was attempting to write a program where I needed to authenticate a user at the server end using Spring security, I came up with the following: public class CustomAuthenticationProvider extends A...

How to find the duration of difference between two dates in java?

I have two objects of DateTime, which need to find the duration of their difference, I have the following code but not sure how to continue it to get to the expected results as following: Example: 11/03/14 09:30:58 11/03/14 09:33:43 ...

Gaussian filter in MATLAB

Does the 'gaussian' filter in MATLAB convolve the image with the Gaussian kernel? Also, how do you choose the parameters hsize (size of filter) and sigma? What do you base it on?...

Binding value to input in Angular JS

I have input like this <input type="text" name="widget.title" ng-model="widget.title" value="{{widget.title}}"/> I want to change input value dynamically so i use that but it doesn't change the value: $scope.widget.title = 'a'; ...

What is the best way to create a string array in python?

I'm relatively new to Python and it's libraries and I was wondering how I might create a string array with a preset size. It's easy in java but I was wondering how I might do this in python. So far all I can think of is strs = ['']*size And som...

How to export and import environment variables in windows?

I found it is hard to keep my environment variables sync on different machines. I just want to export the settings from one computer and import to other ones. I think it should be possible, but don't know how to do it. Can anyone help me? Thanks. ...

How to configure socket connect timeout

When the Client tries to connect to a disconnected IP address, there is a long timeout over 15 seconds... How can we reduce this timeout? What is the method to configure it? The code I'm using to set up a socket connection is as following: try { ...

How to Call a JS function using OnClick event

I am trying to call my JS function that I added in the header. Please find below code that shows my problem scenario. Note: I don't have access to the body in my application. Everytime I click on the element with id="Save" it only calls f1() but n...

Replacing a character from a certain index

How can I replace a character in a string from a certain index? For example, I want to get the middle character from a string, like abc, and if the character is not equal to the character the user specifies, then I want to replace it. Something like...

Putting an if-elif-else statement on one line?

I have read the links below, but it doesn't address my question. Does Python have a ternary conditional operator? (the question is about condensing if-else statement to one line) Is there an easier way of writing an if-elif-else statement so it fit...

convert xml to java object using jaxb (unmarshal)

I have the following XML and I need to convert it into a java object. <tests> <test-data> <title>BookTitle</title> <book>BookName</book> <count>64018</count> ...

Is it possible to auto-format your code in Dreamweaver?

Is it possible to auto-format your code in Dreamweaver like in Visual Studio (ctrl+k+d)...

How can I check if given int exists in array?

For example, I have this array: int myArray[] = { 3, 6, 8, 33 }; How to check if given variable x is in it? Do I have to write my own function and loop the array, or is there in modern c++ equivalent to in_array in PHP?...

How to force Chrome's script debugger to reload javascript?

I really like the ability to edit javascript in the chrome debugger however, I find that it can be really problematic getting the debugger to re-fetch the JavaScript from the server. Sometimes I have to go as far just closing the debugger and reload...

CSS: Position loading indicator in the center of the screen

How can I position my loading indicator in the center of the screen. Currently I'm using a little placeholder and it seems to work fine. However, when I scroll down, the loading indicator stays right in that predefined position. How can I make it fol...

How to solve could not create the virtual machine error of Java Virtual Machine Launcher?

I am working on java wicket framework and Apache tomcat. Here I have Problem when i tried to start tomcat it shows Java Virtual Machine Launcher pop window "Could not create the Java Virtual Machine". After clicking on "OK" button on Pop window it sh...

Maven: Command to update repository after adding dependency to POM

I've added a new dependency to my POM. Is there a simple command I can run to download this dependency to my repository?...

How to change the height of a div dynamically based on another div using css?

Here is my code. HTML: <div class="div1"> <div class="div2"> Div2 starts <br /><br /><br /><br /><br /><br /><br /> Div2 ends </div> <div class="div3&qu...

How can I copy network files using Robocopy?

How can I copy network files using Robocopy?...

Open a URL without using a browser from a batch file

I want to open a particular URL without directly opening the browser using only a batch file. I know I can use something like: START www.google.com But I want to open a URL without using a browser. Is this possible? The reason is that I have to o...

Text in a flex container doesn't wrap in IE11

Consider the following snippet: _x000D_ _x000D_ .parent {_x000D_ display: flex;_x000D_ flex-direction: column;_x000D_ width: 400px;_x000D_ border: 1px solid red;_x000D_ align-items: center;_x000D_ }_x000D_ .child {_x000D_ border: 1px sol...

Center image in div horizontally

I have an img in a div (class="top_image") and I want this image to be exactly in the middle of the div but nothing I try works... Thanks for any help!...

'sudo gem install' or 'gem install' and gem locations

Running 'sudo gem list --local' and 'gem list --local' give me differing results. My gem path is set to my home folder and only contains the gems from 'gem list --local'. It's probably not good to have gems installed in different directories on my c...

Using std::max_element on a vector<double>

I'm trying to use std::min_element and std::max_element to return the min and max elements in a vector of doubles. My compiler doesn't like how I'm currently trying to use them, and I don't understand the error message. I could of course write my o...

JavaScript global event mechanism

I would like to catch every undefined function error thrown. Is there a global error handling facility in JavaScript? The use case is catching function calls from flash that are not defined....

@font-face not working

Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face { font-family: Gotham; src: url(../fonts/gothammedium.eot); src: local('Gotham-Medium'), url(../fonts/Gotham-Medium.ttf) format('truetype'); }...

AJAX POST and Plus Sign ( + ) -- How to Encode?

I'm POSTing the contents of a form field via AJAX to a PHP script and using JavaScript to escape(field_contents). The problem is that any plus signs are being stripped out and replaced by spaces. How can I safely 'encode' the plus sign and then app...

jquery smooth scroll to an anchor?

Is there a way to scroll down to an anchor link using jQuery? Like: $(document).ready(function(){ $("#gotomyanchor").click(function(){ $.scrollSmoothTo($("#myanchor")); }); }); ?...

Outputting data from unit test in Python

If I'm writing unit tests in python (using the unittest module), is it possible to output data from a failed test, so I can examine it to help deduce what caused the error? I am aware of the ability to create a customized message, which can carry som...

Getting hold of the outer class object from the inner class object

I have the following code. I want to get hold of the outer class object using which I created the inner class object inner. How can I do it? public class OuterClass { public class InnerClass { private String name = "Peakit"; } ...

How can I check if an array contains a specific value in php?

I have a PHP variable of type Array and I would like find out if it contains a specific value and let the user know that it is there. This is my array: Array ( [0] => kitchen [1] => bedroom [2] => living_room [3] => dining_room) and I...

Join/Where with LINQ and Lambda

I'm having trouble with a query written in LINQ and Lambda. So far, I'm getting a lot of errors here's my code: int id = 1; var query = database.Posts.Join(database.Post_Metas, post => database.Posts.Where(x => ...

Using find command in bash script

I just start to use bash script and i need to use find command with more than one file type. list=$(find /home/user/Desktop -name '*.pdf') this code work for pdf type but i want to search more than one file type like .txt or .bmp together.Have yo...

how to get current datetime in SQL?

Want to get current datetime to insert into lastModifiedTime column. I am using MySQL database. My questions are: is there a function available in SQL? or it is implementation depended so each database has its own function for this? what is the fu...

CSS two div width 50% in one line with line break in file

I try to build fluid layout using percentages as widths. Do do so i tried this: <div style="width:50%; display:inline-table;">A</div> <div style="width:50%; display:inline-table;">B</div> In that case they wont stand in one...

Change Screen Orientation programmatically using a Button

I think this is implementable since screen rotation behaviour can go up to the application level....

Using node.js as a simple web server

I want to run a very simple HTTP server. Every GET request to example.com should get index.html served to it but as a regular HTML page (i.e., same experience as when you read normal web pages). Using the code below, I can read the content of index....

foreach vs someList.ForEach(){}

There are apparently many ways to iterate over a collection. Curious if there are any differences, or why you'd use one way over the other. First type: List<string> someList = <some way to init> foreach(string s in someList) { <pr...

How to search for a string in text files?

I want to check if a string is in a text file. If it is, do X. If it's not, do Y. However, this code always returns True for some reason. Can anyone see what is wrong? def check(): datafile = file('example.txt') found = False for line in...

Manually raising (throwing) an exception in Python

How can I raise an exception in Python so that it can later be caught via an except block?...

How to putAll on Java hashMap contents of one to another, but not replace existing keys and values?

I need to copy all keys and values from one A HashMap onto another one B, but not to replace existing keys and values. Whats the best way to do that? I was thinking instead iterating the keySet and checkig if it exist or not, I would Map temp = ne...

RecyclerView and java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder in Samsung devices

I have a recycler view that works perfectly on all devices except Samsung. On Samsung, I'm get java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder when I'm going back to the fragment with ...

Differences between strong and weak in Objective-C

I'm new to Obj-C, so my first question is: What are the differences between strong and weak in @property declarations of pointers to objects? Also, what does nonatomic mean?...

Which is the preferred way to concatenate a string in Python?

Since Python's string can't be changed, I was wondering how to concatenate a string more efficiently? I can write like it: s += stringfromelsewhere or like this: s = [] s.append(somestring) later s = ''.join(s) While writing this question, I...

JUnit test for System.out.println()

I need to write JUnit tests for an old application that's poorly designed and is writing a lot of error messages to standard output. When the getResponse(String request) method behaves correctly it returns a XML response: @BeforeClass public static ...

private final static attribute vs private final attribute

In Java, what's the difference between: private final static int NUMBER = 10; and private final int NUMBER = 10; Both are private and final, the difference is the static attribute. What's better? And why?...

Microsoft Web API: How do you do a Server.MapPath?

Since Microsoft Web API isn't MVC, you cannot do something like this: var a = Request.MapPath("~"); nor this var b = Server.MapPath("~"); because these are under the System.Web namespace, not the System.Web.Http namespace. So how do you figur...

String to HtmlDocument

I'm fetching the html document by URL using WebClient.DownloadString(url) but then its very hard to find the element content that I'm looking for. Whilst reading around I've spotted HtmlDocument and that it has neat things like GetElementById. How ca...

Multiple modals overlay

I need that the overlay shows above the first modal, not in the back. _x000D_ _x000D_ $('#openBtn').click(function(){_x000D_ $('#myModal').modal({show:true})_x000D_ });_x000D_ <a data-toggle="modal" href="#myModal" class="btn btn-primary">L...