Questions Tagged with #Wmd

Can't get private key with openssl (no start line:pem_lib.c:703:Expecting: ANY PRIVATE KEY)

I have a .key file, when I do openssl rsa -text -in file.key I get unable to load Private Key 140000419358368:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: ANY PRI..

Saving binary data as file using JavaScript from a browser

I am working on a business application using angularJS. One of my service method returning me a byte[] (inclding PDF file content) now i need to download this file as PDF to client machine using JavaS..

Determine which element the mouse pointer is on top of in JavaScript

I want a function that tells me which element the mouse cursor is over. So, for example, if the user's mouse is over this textarea (with id wmd-input), calling window.which_element_is_the_mouse_on() w..

Python base64 data decode

I have the following piece of base64 encoded data, and I want to use python base64 module to extract information from it. It seems that module does not work. Can anyone tell me how? Q5YACgAAAABDlgA..

Where should I put the file?

I wrote a web service project using netbeans 6.7.1 with glassfish v2.1, put to the root dir of project and use: static Logger logger = Logger.getLogger(MyClass.class); in Construct..

Markdown and image alignment

I am making a site that publishes articles in issues each month. It is straightforward, and I think using a Markdown editor (like the WMD one here in Stack Overflow) would be perfect. However, t..

jQuery.inArray(), how to use it right?

First time I work with jQuery.inArray() and it acts kinda strange. If the object is in the array, it will return 0, but 0 is false in Javascript. So the following will output: "is NOT in array" var ..

Most popular screen sizes/resolutions on Android phones

I understand that Android's developer site provides information on this topic. I have already read the following three pages: Supporting Multiple Screens Screen Sizes and Densites Icon Design Guidel..

DISTINCT for only one column

Let's say I have the following query. SELECT ID, Email, ProductName, ProductModel FROM Products How can I modify it so that it returns no duplicate Emails? In other words, when several rows contai..

How to fix org.hibernate.LazyInitializationException - could not initialize proxy - no Session

I get the following exception: Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initial..

Cannot refer to a non-final variable inside an inner class defined in a different method

Edited: I need to change the values of several variables as they run several times thorugh a timer. I need to keep updating the values with every iteration through the timer. I cannot set the values t..

What are the differences between a program and an application?

What are the differences between a program and an application? I am trying to understand this to form a concept in ontology. Can anyone explain?..

Is it possible to interactively delete matching search pattern in Vim?

There is a phrase that I want to look for in Vim. When found, I want to delete that occurrence of the phrase. What is the easiest way to cycle through all the occurrences (via n), and delete a match..

Use CSS to remove the space between images

Given: <img src="..."/> <img src="..."/> The result is two images with a single space between them. It seems that the normal behavior is to show any number of spaces, newlines, and tabs..

Refused to load the font 'data:font/woff.....'it violates the following Content Security Policy directive: "default-src 'self'". Note that 'font-src'

My react webApp give this Error in Browser Console Refused to load the font 'data:font/woff;base64,d09........' because it` `violates the following Content Security Policy directive: "default-src` `..

How to set background color in jquery

How to set background color of td in jQuery? e.g $(this).css({**BackgroundColor:Red**}) Thanks..

'python' is not recognized as an internal or external command

So I have recently installed Python Version 2.7.5 and I have made a little loop thing with it but the problem is, when I go to cmd and type python I get the error: 'python' is not rec..

How to check if a table is locked in sql server

I have a large report I am running on sql server. It takes several minutes to run. I don't want users clicking run twice. Since i wrap the whole procedure in a transaction, how do I check to see if th..

How do I make a <div> move up and down when I'm scrolling the page?

How can I make a div element move up and down the page when the user is scrolling the page? (where that element is always visible)..

C++ auto keyword. Why is it magic?

From all the material I used to learn C++, auto has always been a weird storage duration specifier that didn't serve any purpose. But just recently, I encountered code that used it as a type name in ..

Create a button programmatically and set a background image

When I try creating a button and setting a background image in Swift: let button = UIButton.buttonWithType(UIButtonType.System) as UIButton button.frame = CGRectMake(100, 100, 100, 100) but..

onclick open window and specific size

I have a link like this: <a href="/index2.php?option=com_jumi&amp;fileid=3&amp;Itemid=11" onclick=",'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollb..

laravel Unable to prepare route ... for serialization. Uses Closure

When I clear caches in my Laravel 5.2 project, I see this error message: [LogicException] Unable to prepare route [panel] for serialization. Uses Closure. I think that it's related with a route ..

C++ string to double conversion

Usually when I write anything in C++ and I need to convert a char into an int I simply make a new int equal to the char. I used the code(snippet) string word; openfile >> word; double l..

How do I access Configuration in any class in ASP.NET Core?

I have gone through configuration documentation on ASP.NET core. Documentation says you can access configuration from anywhere in the application. Below is Startup.cs created by template public clas..

Find Facebook user (url to profile page) by known email address

I have an email address and want to find out if there is a Facebook user linked to this address. If there is, then I want to retrieve the url to this users profile page and save it somewhere. I do not..

How to read data from java properties file using Spring Boot

I have a spring boot application and I want to read some variable from my file. In fact below codes do that. But I think there is a good method for this alternative. Properties..

How to render a PDF file in Android

Android does not have PDF support in its libraries. Is there any way to render PDF files in the Android applications?..

How to use patterns in a case statement?

The man page says that case statements use "filename expansion pattern matching". I usually want to have short names for some parameters, so I go: case $1 in req|reqs|requirements) TASK="Function..

Android Studio - Device is connected but 'offline'

This is quite a common question, but none of the solutions appear to work for me. First time asker, so apologies if I get the conventions wrong. I am trying to connect my Galaxy S5 to my computer run..

Javascript get object key name

How would I get the key name for the follow? E.g I want "button1" and "button2"? var buttons = { button1: { text: 'Close', onclick: function(){ } }, button2: { ..

How do you run a command for each line of a file?

For example, right now I'm using the following to change a couple of files whose Unix paths I wrote to a file: cat file.txt | while read in; do chmod 755 "$in"; done Is there a more elegant, safer ..

Function return value in PowerShell

I have developed a PowerShell function that performs a number of actions involving provisioning SharePoint Team sites. Ultimately, I want the function to return the URL of the provisioned site as a St..

How to call javascript function from button click event

How do I call the showDialog from a button click event. My page is a contentpage that has a masterpage associated with it. I have tried the following <asp:Button ID="ButtonAdd" runat="s..

How to set JAVA_HOME for multiple Tomcat instances?

I have 2 Java Web Projects. One runs on JDK 1.5 and the other runs on JDK 1.6. I want to run both of them on the same computer, but the JAVA_HOME environment variable can only have one value. I want t..

Does the join order matter in SQL?

Disregarding performance, will I get the same result from query A and B below? How about C and D? -- A select * from a left join b on <blahblah> left join c on &l..

How to wait until an element is present in Selenium?

I'm trying to make Selenium wait for an element that is dynamically added to the DOM after page load. Tried this: fluentWait.until(ExpectedConditions.presenceOfElement("elementId")); In case ..

8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE

I have strange thing when I try to modify Spring project inside my Spring Tool Suite. On the first load (deploy) everything is fine, application compiles and runs on localhost:8080 When I change som..

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

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

How to compare two tags with git?

I would like to do a diff between two tags and committed changes between those two tags. Could you please tell me the command?..

What is an idiomatic way of representing enums in Go?

I'm trying to represent a simplified chromosome, which consists of N bases, each of which can only be one of {A, C, T, G}. I'd like to formalize the constraints with an enum, but I'm wondering what t..

How to write :hover using inline style?

<a href="#">Alink</a> All i need is while i hover the color should change for the link, But it should be completely using only inline CSS *No Scripting or external CSS Please he..

Adding a simple UIAlertView

What is some starter code I could use to make a simple UIAlertView with one "OK" button on it?..

Twitter Bootstrap Button Text Word Wrap

For the life of me I am unable to get these twitter bootstrap buttons to text wrap onto multiple lines, they appearing like so. I cannot post images, so this is what it is doing... [This is the bu] ..

How to group pandas DataFrame entries by date in a non-unique column

A Pandas DataFrame contains column named "date" that contains non-unique datetime values. I can group the lines in this frame using: data.groupby(data['date']) However, this splits the data by the..

Difference between clustered and nonclustered index

I need to add proper index to my tables and need some help. I'm confused and need to clarify a few points: Should I use index for non-int columns? Why/why not I've read a lot about clustered and no..

How to call a VbScript from a Batch File without opening an additional command prompt

I have a VBScript file which I am trying to call from a Batch file. The following code I coped to a notepad and saved as MyScript.vbs (

How to set my phpmyadmin user session to not time out so quickly?

I work on my wamp for localhost backend development everyday. I feel annoyed by phpmyadmin auto log out out quickly. Is there any way I could get rid of this or extend the timeout? Where can I set..

Find the IP address of the client in an SSH session

I have a script that is to be run by a person that logs in to the server with SSH. Is there a way to find out automatically what IP address the user is connecting from? Of course, I could ask the us..

What is the "realm" in basic authentication

I'm setting up basic authentication on a php site and found this page on the php manual showing the set up. What does "realm" mean here in the header? header('WWW-Authenticate: Basic realm="My Real..

Include PHP file into HTML file

I'm working on a project that may have to change the same content on all html pages. So I figured I would create a php file and only have to change that so it changes on all pages over the web. The f..

how to fix groovy.lang.MissingMethodException: No signature of method:

I am trying to use this method without a closure def copyAndReplaceText(source, dest, targetText, replaceText){ dest.write(source.text.replaceAll(targetText, replaceText)) } def source = new Fi..

bower proxy configuration

is there a way to configure bower not only to use a proxy but ignore the proxy configuration for some domains? I have the problem, that I will run an internal bower registry for our own developed com..

How to create a horizontal loading progress bar?

When uninstalling an android application, or do some configuration, there will show such a horizontal progress bar, like following picture: It's not the same style like @android:style/Widget.Progre..

MVC 3 file upload and model binding

I have a form upload that works but I would like to pass model information for my database to save the file with a different name of course. Here is my Razor view: @model CertispecWeb.Models.Contain..

How to send and receive JSON data from a restful webservice using Jersey API

@Path("/hello") public class Hello { @POST @Path("{id}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public JSONObject sayPlainTextHello(@PathParam..

Mysql 1050 Error "Table already exists" when in fact, it does not

I'm adding this table: CREATE TABLE contenttype ( contenttypeid INT UNSIGNED NOT NULL AUTO_INCREMENT, class VARBINARY(50) NOT NULL, packageid INT UNSIGNED NOT NULL, ca..

How to install php-curl in Ubuntu 16.04

Upgraded to Ubuntu 16.04 and facing problem after installing PHP5. Installed PHP-5 with following: sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get upgrade sudo apt-get instal..

Remove columns from dataframe where ALL values are NA

I'm having trouble with a data frame and couldn't really resolve that issue myself: The dataframe has arbitrary properties as columns and each row represents one data set. The question is: How to get ..

Backup/Restore a dockerized PostgreSQL database

I'm trying to backup/restore a PostgreSQL database as is explained on the Docker website, but the data is not restored. The volumes used by the database image are: VOLUME ["/etc/postgresql", "/var/..

Exact difference between CharSequence and String in java

I read this previous post. Can any one say what the exact difference between CharSequence and String is, other than the fact that String implements CharSequence and that String is a sequence of charac..

How to clear jQuery validation error messages?

I am using the jQuery validation plugin for client side validation. Function editUser() is called on click of 'Edit User' button, which displays error messages. But I want to clear error messages on ..

Difference between application/x-javascript and text/javascript content types

What is the difference between these headers? Content-Type: application/javascript Content-Type: application/x-javascript Content-Type: text/javascript Which one is best and why? Please do not say..

jquery's append not working with svg element?

Assuming this: <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("svg").append(..

How to Auto resize HTML table cell to fit the text size

I have a table with 2 rows and variable columns. I tried width = 100% for the column. So the first content in the view will fit. But suppose if i am changing the contents dynamically then it is not dy..

Calculate rolling / moving average in C++

I know this is achievable with boost as per: Using boost::accumulators, how can I reset a rolling window size, does it keep extra history? But I really would like to avoid using boost. I have google..

What is a daemon thread in Java?

Can anybody tell me what daemon threads are in Java?..

CSS flexbox not working in IE10

In IE10, this code isn't working correctly: .flexbox form { display: -webkit-flex; display: -moz-flex; display: -ms-flex; display: -o-flex; display: flex; -webkit-flex-directi..

Insert json file into mongodb

I am new to MongoDB. After installing MongoDB in Windows I am trying to insert a simple json file using the following command: C:\>mongodb\bin\mongoimport --db test --collection docs < example2..

Changing image size in Markdown

I just got started with Markdown. I love it, but there is one thing bugging me: How can I change the size of an image using Markdown? The documentation only gives the following suggestion for an imag..

Use of 'prototype' vs. 'this' in JavaScript?

What's the difference between var A = function () { this.x = function () { //do something }; }; and var A = function () { }; A.prototype.x = function () { //do something }; ..

Parse v. TryParse

What is the difference between Parse() and TryParse()? int number = int.Parse(textBoxNumber.Text); // The Try-Parse Method int.TryParse(textBoxNumber.Text, out number); Is there some form of error..

Get selected option from select element

I am trying to get the selected option from a dropdown and populate another item with that text, as follows. IE is barking up a storm and it doesn't work in Firefox: $('#ddlCodes').change(function() ..

What is the location of mysql client ".my.cnf" in XAMPP for Windows?

What is the location of mysql client .my.cnf using XAMPP in Windows? Clarification: This file does not exist by default, so when you create it, where should you place it, in order for the command lin..

How can I access the MySQL command line with XAMPP for Windows?

How can I access the MySQL command line with XAMPP for Windows?..

Simple Deadlock Examples

I would like to explain threading deadlocks to newbies. I have seen many examples for deadlocks in the past, some using code and some using illustrations (like the famous 4 cars). There are also class..

How to replace comma (,) with a dot (.) using java

I am having a String str = 12,12 I want to replace the ,(comma) with .(Dot) for decimal number calculation, Currently i am trying this : if( str.indexOf(",") != -1 ) { str.replaceAll(",","\\..

svn cleanup: sqlite: database disk image is malformed

I was trying to do a svn cleanup because I can't commit the changes in my working copy, and I got the following error: sqllite: database disk image is malformed What can I do right now?..

Use PHP to convert PNG to JPG with compression?

I have a bunch of high quality PNG files. I want to use PHP to convert them to JPG because of it's smaller file sizes while maintaining quality. I want to display the JPG files on the web. Does PHP..

How to copy marked text in notepad++

I have a part of HTML source file that contains strings that I want to select and copy at once, using the regex functionality of Notepad++. Here is a part of the text source: <option value="Perfo..

Using pip behind a proxy with CNTLM

I am trying to use pip behind a proxy at work. One of the answers from this post suggested using CNTLM. I installed and configured it per this other post, but running cntlm.exe -c cntlm.ini -I -M htt..

How to specify HTTP error code?

I have tried: app.get('/', function(req, res, next) { var e = new Error('error message'); e.status = 400; next(e); }); and: app.get('/', function(req, res, next) { res.statusCode =..

How to fix the Hibernate "object references an unsaved transient instance - save the transient instance before flushing" error

I receive following error when I save the object using Hibernate object references an unsaved transient instance - save the transient instance before flushing ..

If statement within Where clause

I am working with a query which contains "IF" statements within a "WHERE" clause. But PL\SQL Developer is giving some errors while executing it. Can anyone please help me with the correct query? Here ..

What is the difference between a process and a thread?

What is the technical difference between a process and a thread? I get the feeling a word like 'process' is overused and there are also hardware and software threads. How about light-weight processes..

How to count no of lines in text file and store the value into a variable using batch script?

I want to count the no of lines in a text file and then the value has to be stored into a environment variable. The command to count the no of lines is findstr /R /N "^" file.txt | find /C ":" I r..

Group by with union mysql select query

(SELECT COUNT(motorbike.`owner_id`) as count,owner.`name`,transport.`type` FROM transport,owner,motorbike WHERE transport.type='motobike' AND owner.`owner_id`=motorbike.`owner_id` AND transport.`type_..

User Control - Custom Properties

I have developed a User Control in Visual Studio (WinForms C#) and have a question. I need the user of my User Control to be able to change certain string values and I would like them to be able to a..

Safest way to run BAT file from Powershell script

I can not get a powershell script to execute a bat file directly. For example, this works on the command line: .\\my-app\my-fle.bat When I add this command to a script, it outputs: The term '.\\my..

How do I sort a VARCHAR column in SQL server that contains numbers?

I have a VARCHAR column in a SQL Server 2000 database that can contain either letters or numbers. It depends on how the application is configured on the front-end for the customer. When it does cont..

Stack Memory vs Heap Memory

Possible Duplicate: What and where are the stack and heap I am programming in C++ and I am always wondering what exactly is stack memory vs heap memory. All I know is when I call new, I wou..

Restore LogCat window within Android Studio

I have recently started to use Android Studio v0.1.1, And i can't seem to find LogCat... Is it gone? Or if not, how can I enable it? If it is gone, is there any way to enable something similar to log..

calling a function from class in python - different way

EDIT2: Thank you all for your help! EDIT: on adding @staticmethod, it works. However I am still wondering why i am getting a type error here. I have just started OOPS and am completely new to it. I ..

Redirection of standard and error output appending to the same log file

I need to collect the standard output and error log from several processes into one single log file. So every output must append to this log file. I want to call all the jobs with lines like this: ..

Handling the TAB character in Java

I'm going through a configuration file with a RandomAccessFile reader. I have a configuration option which is one (1) tab away from the start of the line. When my reader gets this line, would I be abl..

Using external images for CSS custom cursors

Is it possible to use external image URLs for CSS custom cursors? The following example doesn't work: HTML: <div class="test">TEST</div> CSS: .test { background:gray; width:200px;..

Get bottom and right position of an element

I'm trying to get the position of an element within the window like so: var link = $(element); var offset = link.offset(); var top =; var left = offset.left; var bottom = $(window).height..

memory error in python

Traceback (most recent call last): File "/run-1341144766-1067082874/", line 27, in main() File "/run-1341144766-1067082874/", line 11, in main if len(s[i:j+1]) > 0: MemoryErr..

Converting dictionary to JSON

r = {'is_claimed': 'True', 'rating': 3.5} r = json.dumps(r) file.write(str(r['rating'])) I am not able to access my data in the JSON. What am I doing wrong? TypeError: string indices must be intege..

macOS on VMware doesn't recognize iOS device

I am using Mac OS in VMWare for iOS app development. After updating the OS and Xcode, the iOS device isn't available so I cannot test it. When the device is plugged in to the PC, the device appears ..

What's the difference between primitive and reference types?

This is a past exam question and I was wondering what a primitive type and reference type are first off? With an array I know the a reference type is where the array is composed of objects or variable..

Hibernate HQL Query : How to set a Collection as a named parameter of a Query?

Given the following HQL Query: FROM Foo WHERE Id = :id AND Bar IN (:barList) I set :id using the Query object's setInteger() method. I would like to set :barList using a List of objec..

Convert hexadecimal string (hex) to a binary string

I found the following way hex to binary conversion: String binAddr = Integer.toBinaryString(Integer.parseInt(hexAddr, 16)); While this approach works for small hex numbers, a hex number such as th..

How to refresh table contents in div using jquery/ajax

I need your help in order to refresh a div id="mytable" in my html once the function is called from a method. Currently, I am loading the full page once it is called using the below lines. In my java..

how to convert rgb color to int in java

Paint.setColor is expecting an integer. But what I have is a Color object. I don't see a color.getIntValue() in Java? So how do I do that? What I want is something like public Something myMethod(Colo..

How to get response as String using retrofit without using GSON or any other library in android

I am trying to get response from the following Api : But I don't know how to get response as String so that I can use the String to parse and get the JSONObject..

Python IndentationError unindent does not match any outer indentation level

I'm a beginner in python, I have this error : Error : def on_data(self,data): ^ IdentationError : unindent does not match any outer indentation level I code with notepad++ ..

Changing background color of text box input not working when empty

I am having a tough time with this javascript code to change the background color of a text input if the input is empty. Here is the code: function checkFilled() { var inputVal = document.getEle..

How do you use String.substringWithRange? (or, how do Ranges work in Swift?)

I have not yet been able to figure out how to get a substring of a String in Swift: var str = “Hello, playground” func test(str: String) -> String { return str.substringWithRange( /* What goe..

Changing line colors with ggplot()

I don't use ggplot2 that much, but today I thought I'd give it a go on some graphs. But I can't figure out how to manually control colors in geom_line() I'm sure I'm overlooking something simple, but..

Why does flexbox stretch my image rather than retaining aspect ratio?

Flexbox has this behaviour where it stretches images to their natural height. In other words, if I have a flexbox container with a child image, and I resize the width of that image, the height doesn't..

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

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

Ubuntu: Using curl to download an image

I want to download an image accessible from this link: into my local system. Now, I'm aware that the curl command can be used to ..

/etc/apt/sources.list" E212: Can't open file for writing

I am trying to edit sources.list using vi editor but getting the following error while saving the file: /etc/apt/sources.list" E212: Can't open file for writing ..

Pass connection string to code-first DbContext

How do I pass a connection string to entity framework's code-first DbContext? My database generation works correctly when both DbContext and the connection string in web.config is in the same project ..

Inserting one list into another list in java?

I have below java code. List<SomePojo> list = new ArrayList<SomePojo>(); //add 100 SomePojo objects to list. Now list has 100 objects. If i create one more instance as below: List<Some..

Print text in Oracle SQL Developer SQL Worksheet window

I am using Oracle SQL (in SQLDeveloper, using the SQL Worksheet). I would like to print a statement before my select, such as PRINT 'Querying Table1'; SELECT * from Table1; What do I use to Print ..

What is the worst programming language you ever worked with?

If you have an interesting story to share, please post an answer, but do not abuse this question for bashing a language. We are programmers, and our primary tool is the programming langua..

CSS3 transform not working

I am trying to transform my menu items by rotating them 10 degrees. My CSS works in Firefox but I've failed to replicate the effect in Chrome and Safari. I know IE doesn't support this CSS3 property s..

How can I get date and time formats based on Culture Info?

What I want is.. If culture is en-US then string dateFormat="MM/dd/yyyy"; string timeFormat="24.00 hrs"; If culture is en-GB then string dateFormat="dd/mmyyyy"; string timeFormat="24.00 hrs"; ..

Oracle 10g: Extract data (select) from XML (CLOB Type)

I'm new in Oracle and I've - maybe trivial - a problem in a select. (I'm using Oracle 10g Express Edition). I've a DB with a field CLOB: mytab.xml This column have an XML like this: <?xml version..

Which passwordchar shows a black dot (•) in a winforms textbox?

Short question here: In .Net 4.0 Winforms, how do I use the PasswordChar property of a Textbox to show a common black dot as a character? Is there perhaps some font I can use that has this as a chara..

How to make a great R reproducible example

When discussing performance with colleagues, teaching, sending a bug report or searching for guidance on mailing lists and here on Stack Overflow, a reproducible example is often asked and always..

How to declare a vector of zeros in R

I suppose this is trivial, but I can't find how to declare a vector of zeros in R. For example, in Matlab, I would write: X = zeros(1,3); ..

How to write Unicode characters to the console?

I was wondering if it was possible, in a console application, to write characters like ? using .NET. When I try to write this character, the console outputs a question mark...

Why do I get an UnsupportedOperationException when trying to remove an element from a List?

I have this code: public static String SelectRandomFromTemplate(String template,int count) { String[] split = template.split("|"); List<String> list=Arrays.asList(split); Random r = ne..

React Native - Image Require Module using Dynamic Names

I'm currently building a test app using React Native. The Image module, thus far has been working fine. For example, if I had an image named avatar, the below code snippet works fine. <Image sour..

Handle Guzzle exception and get HTTP body

I would like to handle errors from Guzzle when the server returns 4xx and 5xx status codes. I make a request like this: $client = $this->getGuzzleClient(); $request = $client->post($url, $heade..

how to select first N rows from a table in T-SQL?

Is there any way to select, for example, first 10 rows of a table in T-SQL (working MSSQL)? I think I saw something in Oracle defined as rownum meta variable, used in a following way select * from Us..

How do I call a SQL Server stored procedure from PowerShell?

I have a large CSV file and I want to execute a stored procedure for each line. What is the best way to execute a stored procedure from PowerShell?..

In php, is 0 treated as empty?

Code will explain more: $var = 0; if (!empty($var)){ echo "Its not empty"; } else { echo "Its empty"; } The result returns "Its empty". I thought empty() will check if I already set the variable a..

Capture the Screen into a Bitmap

I want to capture the screen in my code to get an image - like using the 'print screen' button on the keyboard . Does anyone have an idea how to do this? I have no starting point...

Enable Hibernate logging

I'm trying to create a log of hibernate statements. I perform my sql statements using JPA where Hibernate 2.0 is the persistence provider (my application server is JBoss AS 6.0). I call my CRUD method..

What is the difference between "Rollback..." and "Back Out Submitted Changelist #####" in Perforce P4V

I want to reverse the changes from one of my checkins. In the right-click context menu of the particular changelist, there are these two options: Rollback... Back Out Submitted Changelist What is..

Getting Index of an item in an arraylist;

I have a Class called AuctionItem. The AuctionItem Class has a method called getName() that returns a String. If I have an ArrayList of type AuctionItem, what is the best way to return the index of an..

How do I get an empty array of any size in python?

I basically want a python equivalent of this in C: int a[x]; but in python I declare an array like: a = [] and the problem is I want to assign random slots with values like: a[4] = 1 but I ca..

string.IsNullOrEmpty(string) vs. string.IsNullOrWhiteSpace(string)

Is use of string.IsNullOrEmpty(string) when checking a string considered as bad practice when there is string.IsNullOrWhiteSpace(string) in .NET 4.0 and above?..

Regex to Match Symbols: !$%^&*()_+|~-=`{}[]:";'<>?,./

I'm trying to create a Regex test in JavaScript that will test a string to contain any of these characters: !$%^&*()_+|~-=`{}[]:";'<>?,./ More Info If You're Interested :) It's for a pre..

jQuery multiple events to trigger the same function

Is there a way to have keyup, keypress, blur, and change events call the same function in one line or do I have to do them separately? The problem I have is that I need to validate some data with a d..

Call php function from JavaScript

Is there a way I can run a php function through a JS function? something like this: <script type="text/javascript"> function test(){ document.getElementById("php_code").innerHTML="<?php qu..

Is there a JSON equivalent of XQuery/XPath?

When searching for items in complex JSON arrays and hashes, like: [ { "id": 1, "name": "One", "objects": [ { "id": 1, "name": "Response 1", "objects": [ // etc. }] ..

Detect Click into Iframe using JavaScript

I understand that it is not possible to tell what the user is doing inside an iframe if it is cross domain. What I would like to do is track if the user clicked at all in the iframe. I imagine a sce..

Android: install .apk programmatically

I made this with help from Android download binary file problems and Install Application programmatically on Android. I want to make auto-update and auto-install at once. It is local so it's non-ma..

Sorting object property by values

If I have a JavaScript object such as: var list = { "you": 100, "me": 75, "foo": 116, "bar": 15 }; Is there a way to sort the properties based on value? So that I end up with list = { ..

Cycles in an Undirected Graph

Given an undirected graph G=(V, E) with n vertices (|V| = n), how do you find if it contains a cycle in O(n)?..

SQL Error: ORA-00933: SQL command not properly ended

I am trying to update a record in oracle SQL developer by using Joins. Following is my query- UPDATE system_info set field_value = 'NewValue' FROM system_users users JOIN system_info info ON users...

Struct with template variables in C++

I'm playing around with templates. I'm not trying to reinvent the std::vector, I'm trying to get a grasp of templateting in C++. Can I do the following? template <typename T> typedef struct{ ..

How does Python manage int and long?

Does anybody know how Python manage internally int and long types? Does it choose the right type dynamically? What is the limit for an int? I am using Python 2.6, Is is different with previous ver..

Dealing with "java.lang.OutOfMemoryError: PermGen space" error

Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparentl..

How to make a <div> always full screen?

No matter how its content is like. Is it possible to do this?..

Threading pool similar to the multiprocessing Pool?

Is there a Pool class for worker threads, similar to the multiprocessing module's Pool class? I like for example the easy way to parallelize a map function def long_running_func(p): c_func_no_gi..

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

How to read embedded resource text file

How do I read an embedded resource (text file) using StreamReader and return it as a string? My current script uses a Windows form and textbox that allows the user to find and replace text in a text ..

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

Where is localhost folder located in Mac or Mac OS X?

I just started developing PHP projects on my mac (using PDT) and was wondering where localhost is located? How does Mac OS X serve websites, I haven't changed any settings during the installation of P..

Upload DOC or PDF using PHP

I'm able to upload images fine, but when when I change the types from image/jpg, image/gif to application/msword and application/pdf, it doesn't work. Here's my code. The exact same code works for ima..

open the file upload dialogue box onclick the image

I want to open the image upload file dialogue box if i click the button it possible.if so how can i do it in php while{ echo "<td><button><img src='".$cfet['productimage']...

How ViewBag in ASP.NET MVC works

How does the ASP.NET MVC's ViewBag work? MSDN says it is just an Object, which intrigues me, how does "Magic" properties such as ViewBag.Foo and magic strings ViewBag["Hello"] actually work? Also, ho..

PHP filesize MB/KB conversion

How can I convert the output of PHP's filesize() function to a nice format with MegaBytes, KiloBytes etc? like: if the size is less than 1 MB, show the size in KB if it's between 1 MB - 1 GB show i..

MySQL JOIN the most recent row only?

I have a table customer that stores a customer_id, email and reference. There is an additional table customer_data that stores a historical record of the changes made to the customer, i.e. when there'..

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

multiple axis in matplotlib with different scales

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

How do I see what character set a MySQL database / table / column is?

What is the (default) charset for: MySQL database MySQL table MySQL column ..

img src SVG changing the styles with CSS

html <img src="logo.svg" alt="Logo" class="logo-img"> css .logo-img path { fill: #000; } The above svg loads and is natively fill: #fff but when I use the above css to try change it to b..

How to change background color of cell in table using java script

I need to change background color of single cell in table using java script. During document i need style of all cell should be same ( so used style sheet to add this. ) , but on button click i need..

Can't fix Unsupported major.minor version 52.0 even after fixing compatibility

When I try running my java .jar on another machine I get the error Unsupported major.minor version 52.0 I compiled my program using the jdk 1.6 and my machine (separate one) has java 7 installed..

SQLite3 database or disk is full / the database disk image is malformed

My database is about 25 MB, and I've verified that the username accessing it, as well as the file permissions haven't changed in months. I'm having a problem where queries are failing due to a "databa..

How to get the currently logged in user's user id in Django?

How to get the currently logged-in user's id? in class Game(models.model): name = models.CharField(max_length=255) owner = models.ForeignKey(User, related_name='game_user', verbos..

.gitignore after commit

I have a git repository hosted on Github. After committing many files, I am realizing that I need to create .gitignore and exclude .exe, .obj files. However, will it automatically remove these commit..

Angular - How to apply [ngStyle] conditions

I have a div that I want to style based on a condition. If styleOne is true I want a background colour of red. If StyleTwo is true, I want the background colour to be blue. I've got half of it working..

How Exactly Does @param Work - Java

How does the annotation @param work? If I had something like this: /* *@param testNumber; */ int testNumber = 5; if (testNumber < 6) { //Something } How would the @param affect the testNum..

Best way to represent a fraction in Java?

I'm trying to work with fractions in Java. I want to implement arithmetic functions. For this, I will first require a way to normalize the functions. I know I can't add 1/6 and 1/2 until I have a ..

How to calculate the width of a text string of a specific font and font-size?

I have a UILabel that displays some chars. Like "x", "y" or "rpm". How can I calculate the width of the text in the label (it does not ues the whole available space)? This is for automatic layouting, ..

Using ffmpeg to encode a high quality video

I have a set of video frames saved as images in a directory, and I'm trying to encode these to a good quality video, however every setting and every format I try produces very noticeable artifacts. T..

How to check whether a given string is valid JSON in Java

How do I validate a JSON string in Java? Or could I parse it using regular expressions?..

java how to use classes in other package?

can I import,use class from other package? In Eclipse I made 2 packages one is main other is second main -main (class) second -second (class) and I wanted the main function of main class to call..

How do I connect to an MDF database file?

I'm experimenting in connecting a C# app to an MDF database for the first time, and I need a little help .. I made a small MDF database file in Visual Studio 2010, then created another project and im..

How to change UIPickerView height

Is it possible to change the height of UIPickerView? Some applications seem to have shorter PickerViews but setting a smaller frame doesn't seem to work and the frame is locked in Interface Builder...

Reason: no suitable image found

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

How to clear all inputs, selects and also hidden fields in a form using jQuery?

I would like to clear all inputs, selects and also all hidden fields in a form. Using jQuery is an option if best suited. What is the easiest way to do this... I mean easy to understand and maintain...

Laravel 5 call a model function in a blade view

I want to build a blade view from 3 tables: "inputs_details" - fields: article_type (values: 'p' for product,'s' for service), article_id, .... "products" - fields: id, name "services" - fields: id,..

How to crop a CvMat in OpenCV?

I have an image converted in a CvMat Matrix say CVMat source. Once I get a region of interest from source I want the rest of the algorithm to be applied to that region of interest only. For that I thi..

How to access POST form fields

Here is my simple form: <form id="loginformA" action="userlogin" method="post"> <div> <label for="email">Email: </label> <input type="text" id="email" n..

Open the terminal in visual studio?

How to open terminal for executing shell commands in Visual Studio(Community Version)?..

How to restart service using command prompt?

I want to restart Windows service using command prompt in [Icons] section using Inno Setup. Please help me to solve the problem...

Div side by side without float

How can I make div 'left' and 'right' look like columns side by side? I know I can use float:left on them and that will work... but on step 5 and 6 in here

IIS error, Unable to start debugging on the webserver

I want to run my application from IIS on my local machine. I created the virtual directory and added the application to it and in the properties folder of the application I checked the radio button 'U..

What does it mean to inflate a view from an xml file?

I am new to android development and keep coming across references to Inflating views from a layout xml file. I googled and searched the development guide but still wasn't able to pick up a sense for ..

ShowAllData method of Worksheet class failed

I notice my VBA script doesn't work when there's an autofilter already on. Any idea why this is? wbk.Activate Set Criteria = Sheets("Sheet1").Cells(i, 1) Set rng = Sheets("Sheet1").Range..

Converting between datetime and Pandas Timestamp objects

I have the following: > date1 Timestamp('2014-01-23 00:00:00', tz=None) > date2, 3, 26) and I read on this answer that I could use pandas.to_datetime() to convert from Tim..

java.util.Date vs java.sql.Date

java.util.Date vs java.sql.Date: when to use which and why?..

Printing a java map Map<String, Object> - How?

How to I print information from a map that has the object as the value? I have created the following map: Map<String, Object> objectSet = new HashMap<>(); The object has its own class ..

Send mail via Gmail with PowerShell V2's Send-MailMessage

I'm trying to figure out how to use PowerShell V2's Send-MailMessage with Gmail. Here's what I have so far. $ss = New-Object Security.SecureString foreach ($ch in "password".ToCharArray()) { $ss..

How do I sort arrays using vbscript?

I'm scanning through a file looking for lines that match a certain regex pattern, and then I want to print out the lines that match but in alphabetical order. I'm sure this is trivial but vbscript isn..

How to post raw body data with curl?

Before you post this as a duplicate; I've tried many of the suggestions I found around SO. So far I've been using postman to post data to a Java web service. That works great as follows: I now wan..

Browser/HTML Force download of image from src="data:image/jpeg;base64..."

I am generating a image on client side and I display it with HTML like this: <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgM...."/> I want to offer the possibilit..

How can I get device ID for Admob

I'm using Eclipse to develop applications for android, and I want to integrate Admob to make money. The tutorial says I should watch the LogCat to find ID, but where is it? When I run in either the ..

How to check if array is empty or does not exist?

What's the best way to check if an array is empty or does not exist? Something like this? if(array.length < 1 || array == undefined){ //empty } ..

How can I auto hide alert box after it showing it?

All I want to do is, how can I auto hide alert box within specific seconds after showing it? All I know is, setTimeout(function() { alert('close'); }, 5000); // This will appear alert afte..

@RequestParam vs @PathVariable

What is the difference between @RequestParam and @PathVariable while handling special characters? + was accepted by @RequestParam as space. In the case of @PathVariable, + was accepted as +...

How to pass an ArrayList to a varargs method parameter?

Basically I have an ArrayList of locations: ArrayList<WorldLocation> locations = new ArrayList<WorldLocation>(); below this I call the following method: .getMap(); the parameters in ..

Codeigniter how to create PDF

I'm going to create an invoice system, I am preparing for that now. I'm gonna use Codeigniter. The thing is that I want to create invoice in PDF so I can send it through email. What is your guys advi..

Best way to format integer as string with leading zeros?

I need to add leading zeros to integer to make a string with defined quantity of digits ($cnt). What the best way to translate this simple function from PHP to Python: function add_nulls($int, $cnt=2..

Reorder / reset auto increment primary key

I have a MySQL table with an auto increment primary key. I deleted some rows in the middle of the table. Now I have, for example, something like this in the ID column: 12, 13, 14, 19, 20. I deleted th..

Vertical divider CSS

I am creating a vertical divider, that works fine. But the CSS is cumbersome. The CSS is: .headerDivider1 { border-left:1px solid #38546d;height:80px;position:absolute;right:250px;top:10px; } .head..

LINQ syntax where string value is not null or empty

I'm trying to do a query like so... query.Where(x => !string.IsNullOrEmpty(x.PropertyName)); but it fails... so for now I have implemented the following, which works... query.Where(x => (x...