Questions Tagged with #Perl critic

Perl::Critic is an extensible framework for creating and applying coding standards to Perl source code. Essentially, it is a static source code analysis engine. Perl::Critic is distributed with a number of Perl::Critic::Policy modules that attempt to enforce various coding guidelines.

Check if an object belongs to a class in Java

Is there an easy way to verify that an object belongs to a given class? For example, I could do if(a.getClass() = (new MyClass()).getClass()) { //do something } but this requires instantiating ..

Tuning nginx worker_process to obtain 100k hits per min

We have a server that is serving one html file. Right now the server has 2 CPUs and 2GB of ram. From, we are getting about 12k connections per minute and anywhere from 200 timeouts in that 6..

Smooth scroll without the use of jQuery

I'm coding up a page where I only want to use raw JavaScript code for UI without any interference of plugins or frameworks. And now I'm struggling with finding a way to scroll over the page smoothly ..

Javascript Drag and drop for touch devices

I am looking for a drag & DROP plugin that works on touch devices. I would like similar functionality to the jQuery UI plugin which allows "droppable" elements. The jqtouch plugin supports dragg..

Selecting multiple classes with jQuery

I’ve had a good look and can’t seem to find out how to select all elements matching certain classes in one jQuery selector statement such as this: $('.myClass', '.myOtherClass').removeClass('thec..

Setting public class variables

How do I set a public variable. Is this correct?: class Testclass { public $testvar = "default value"; function dosomething() { echo $this->testvar; } } $Testclass = new Testclass();..

Checkout old commit and make it a new commit

On Git, say I mess up my commits, and I want to make the version 3 commits ago as the new version. If I do git checkout xxxx, it creates a new branch and it seems like I can only merge it? Could I mak..

How to jump to a particular line in a huge text file?

Are there any alternatives to the code below: startFromLine = 141978 # or whatever line I need to jump to urlsfile = open(filename, "rb", 0) linesCounter = 1 for line in urlsfile: if linesCoun..

Magento Product Attribute Get Value

How to get specific product attribute value if i know product ID without loading whole product?..

Xpath: select div that contains class AND whose specific child element contains text

With the help of this SO question I have an almost working xpath: //div[contains(@class, 'measure-tab') and contains(., 'someText')] However this gets two divs: in one it's the child td that has so..

How to print something to the console in Xcode?

How do you print something to the console of Xcode, and is it possible to view the Xcode console from the app itself? Thanks!..

How do I make this executable via double click?

First off I'm using Mac. Next, I need to execute this "" we will call it. Everytime I need to execute it I have to open Terminal and type: cd /Users/Jacob/Documents/folderWithFileInIt bash fi..

Angular 2 TypeScript how to find element in Array

I have a Component and a Service: Component: _x000D_ _x000D_ export class WebUserProfileViewComponent {_x000D_ persons: Person [];_x000D_ personId: number;_x000D_ constructor( params: Rou..

Single quotes vs. double quotes in C or C++

When should I use single quotes and double quotes in C or C++ programming?..

How to use a Java8 lambda to sort a stream in reverse order?

I'm using java lambda to sort a list. how can I sort it in a reverse way? I saw this post, but I want to use java 8 lambda. Here is my code (I used * -1) as a hack Arrays.asList(files).stream() ..

Why does Google prepend while(1); to their JSON responses?

Why does Google prepend while(1); to their (private) JSON responses? For example, here's a response while turning a calendar on and off in Google Calendar: while (1); [ ['u', [ ['smsSentFlag',..

Callback after all asynchronous forEach callbacks are completed

As the title suggests. How do I do this? I want to call whenAllDone() after the forEach-loop has gone through each element and done some asynchronous processing. [1, 2, 3].forEach( function(item,..

ssh: Could not resolve hostname Name or service not known; fatal: The remote end hung up unexpectedly

The process of setting up a GitHub account works just fine but it doesn't work when I try pushing my repository to GitHub. The error message it shows is as follows: ssh: Could not resolve hostname gi..

PostgreSQL database service

I downloaded PostgreSQL from their site - However, I can't create a database from pgAdmin and get a message: could not connect to server: Connection r..

How can I make directory writable?

How can I make a directory writable, from the OS X terminal?..

Passing parameter to controller from route in laravel

THIS IS A QUESTION FOR LARAVEL 3 Given the following route Route::get('groups/(:any)', array('as' => 'group', 'uses' => 'groups@show')); And the URL I would like to use, http://www.example... Invalid postback or callback argument

I am getting this error: Server Error in '/' Application. Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or &l..

Best way to get child nodes

I was wondering, JavaScript offers a variety of methods to get the first child element from any element, but which is the best? By best, I mean: most cross-browser compatible, fastest, most comprehens..

How to handle invalid SSL certificates with Apache HttpClient?

I know, there are many different questions and so many answers about this problem... But I can't understand... I have: ubuntu-9.10-desktop-amd64 + NetBeans6.7.1 installed "as is" from off. rep. I nee..

Redirecting a request using servlets and the "setHeader" method not working

I am new to servlet development, and I was reading an ebook, and found that I can redirect to a different web page using setHeader("Location", "") But this is not working, as ..

Eclipse Bug: Unhandled event loop exception No more handles

I've built a GUI using Swing and the MigLayout. I am using Eclipse 4.2.2 (64-bit) on Windows 7 Ultimate. Every time I click back into the window to edit my code, a popup comes up, then I'm prompted t..

Creating composite primary key in SQL Server

How to add composite primary keys in SQL Server 2008? I have a table as follows. testRequest (wardNo nchar(5) , BHTNo nchar(5) , testID nchar(5) , reqDateTime dat..

How do you create an asynchronous HTTP request in JAVA?

I'm fairly new to Java, so this may seem obvious to some. I've worked a lot with ActionScript, which is very much event based and I love that. I recently tried to write a small bit of Java code that d..

Rails 3: I want to list all paths defined in my rails application

I want to list all defined helper path functions (that are created from routes) in my rails 3 application, if that is possible. Thanks,..

Windows batch files: .bat vs .cmd?

As I understand it, .bat is the old 16-bit naming convention, and .cmd is for 32-bit Windows, i.e., starting with NT. But I continue to see .bat files everywhere, and they seem to work exactly the sam..

Scroll Position of div with "overflow: auto"

Given this HTML snippet: <div id="box" style="overflow:auto; width:200px; height:200px; border:1px solid black;"> 1<br>2<br>3<br>4<br>5<br>6<br>7<br>8&..

How to get DropDownList SelectedValue in Controller in MVC

I have dropdownlist, which I have filled from database. Now I need to get the selected value in Controller do some manipulation. But not getting the idea. Code which I have tried. Model public class..

Can you write nested functions in JavaScript?

I am wondering if JavaScript supports writing a function within another function, or nested functions (I read it in a blog). Is this really possible?. In fact, I have used these but am unsure of this ..

How can I determine if a date is between two dates in Java?

How can I check if a date is between two other dates, in the case where all three dates are represented by instances of java.util.Date?..

How do I make a text input non-editable?

So I have a text input <input type="text" value="3" class="field left"> Here is my CSS for it background:url("images/number-bg.png") no-repeat scroll 0 0 transparent; border:0 none; color:#F..

Multiple arguments to function called by pthread_create()?

I need to pass multiple arguments to a function that I would like to call on a separate thread. I've read that the typical way to do this is to define a struct, pass the function a pointer to that, an..

How to check if a double value has no decimal part

I have a double value which I have to display at my UI. Now the condition is that the decimal value of double = 0 eg. - 14.0 In that case I have to show only 14 on my UI. Also, the max limit for chara..

Why does printf not flush after the call unless a newline is in the format string?

Why does printf not flush after the call unless a newline is in the format string? Is this POSIX behavior? How might I have printf immediately flush every time?..

How can I display a list view in an Android Alert Dialog?

In an Android application, I want to display a custom list view in an AlertDialog. How can I do this?..

Count number of occurences for each unique value

Let's say I have: v = rep(c(1,2, 2, 2), 25) Now, I want to count the number of times each unique value appears. unique(v) returns what the unique values are, but not how many they are. > uniq..

jquery $(window).width() and $(window).height() return different values when viewport has not been resized

I am writing a site using jquery that repeatedly calls $(window).width() and $(window).height() to position and size elements based on the viewport size. In troubleshooting I discovered that I am get..

Chart creating dynamically. in .net, c#

Does anybody have some experience working with charts in .NET? Specially I want to create them programmatically. using System; using System.Collections.Generic; using System.ComponentModel; using Sys..

Set value of hidden field in a form using jQuery's ".val()" doesn't work

I've been trying to set the value of a hidden field in a form using jQuery, but without success. Here is a sample code that explains the problem. If I keep the input type to "text", it works without..

URL to compose a message in Gmail (with full Gmail interface and specified to, bcc, subject, etc.)

I found a post that provides an example for a link which opens just a compose message window. However, I would like it to open a window with the full Gmail interface but ready to compose a new message..

How to get all child inputs of a div element (jQuery)

HTML: <div id="panel"> <table> <tr> <td><input id="Search_NazovProjektu" type="text" value="" /></td> </tr> <tr> <td>..

How to get a function name as a string?

In Python, how do I get a function name as a string, without calling the function? def my_function(): pass print get_function_name_as_string(my_function) # my_function is not in quotes should ..

Get the last non-empty cell in a column in Google Sheets

I use the following function =DAYS360(A2, A35) to calculate the difference between two dates in my column. However, the column is ever expanding and I currently have to manually change 'A35' as I ..

How to get the difference between two dictionaries in Python?

I have two dictionaries. I need to find the difference between the two which should give me both key and value. I have searched and found some addons/packages like datadiff, dictdiff-master but when ..

Regex to match any character including new lines

Is there a regex to match "all characters including newlines"? For example, in the regex below, there is no output from $2 because (.+?) doesn't include new lines when matching. $string = "START Cu..

Run exe file with parameters in a batch file

Please have a look at my batch file. echo off start "c:\program files\php\php.exe D:\mydocs\mp\index.php param1 param2" but it isn't working. Any ideas how do I get it working?..

Javascript: Easier way to format numbers?

I'm trying to format various numbers on my page. These numbers either represent a price, a change in price, or a percentage. I know Javascript has functions to limit the number of decimal places, bu..

How do I get a Cron like scheduler in Python?

I'm looking for a library in Python which will provide at and cron like functionality. I'd quite like have a pure Python solution, rather than relying on tools installed on the box; this way I run on..

Oracle PL/SQL - How to create a simple array variable?

I'd like to create an in-memory array variable that can be used in my PL/SQL code. I can't find any collections in Oracle PL/SQL that uses pure memory, they all seem to be associated with tables. I'..

How to find if a native DLL file is compiled as x64 or x86?

I want to determine if a native assembly is complied as x64 or x86 from a managed code application (C#). I think it must be somewhere in the PE header since the OS loader needs to know this informati..

Reversing a String with Recursion in Java

Here is some Java code to reverse a string recursively. Could someone provide an explanation of how it works? public static String reverse(String str) { if ((null == str) || (str.length() <..

XPath using starts-with function

I'm writing Java on Android to retrieve data from XML file, but I've got a problem. Consider this XML: <ITEM> <REVENUE_YEAR>2554-02</REVENUE_YEAR> <REGION>Central</R..

What is the best way to seed a database in Rails?

I have a rake task that populates some initial data in my rails app. For example, countries, states, mobile carriers, etc. The way I have it set up now, is I have a bunch of create statements in fil..

MVC Return Partial View as JSON

Is there a way to return an HTML string from rendering a partial as part of a JSON response from MVC? public ActionResult ReturnSpecialJsonIfInvalid(AwesomenessModel model) { if (Mode..

Where is GACUTIL for .net Framework 4.0 in windows 7?

i've made an assembly in the .net framework that I intend to publish to the GAC but I can't find the gacutil utlity. I've been googling a while and I've found a lot of suggestions, but nothing works:..

selenium - chromedriver executable needs to be in PATH

Error message: 'chromedriver' executable needs to be in PATH I was trying to code a script using selenium in pycharm, however the error above occured. I have already linked my selenium to pycha..

Find Locked Table in SQL Server

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

Get the client IP address using PHP

I want to get the client IP address who uses my website. I am using the PHP $_SERVER superglobal: $_SERVER['REMOTE_ADDR']; But I see it can not give the correct IP address using this. I get my IP a..

Open Facebook page from Android app?

from my Android app, I would like to open a link to a Facebook profile in the official Facebook app (if the app is installed, of course). For iPhone, there exists the fb:// URL scheme, but trying the ..

Expand div to max width when float:left is set

I have something like that: <div style="width:100px;float:left">menu</div> <div style="float:left">content</div> both floats are neccesary. I want the content div to fill th..

Understanding Chrome network log "Stalled" state

I've a following network log in chrome: I don't understand one thing in it: what's the difference between filled gray bars and transparent gray bars...

Java output formatting for Strings

I was wondering if someone can show me how to use the format method for Java Strings. For instance If I want the width of all my output to be the same For instance, Suppose I always want my output to..

HTML5 Canvas background image

I'm trying to place a background image on the back of this canvas script I found. I know it's something to do with the context.fillstyle but not sure how to go about it. I'd like that line to read som..

Delete all Duplicate Rows except for One in MySQL?

How would I delete all duplicate data from a MySQL Table? For example, with the following data: SELECT * FROM names; +----+--------+ | id | name | +----+--------+ | 1 | google | | 2 | yahoo | ..

Understanding the Rails Authenticity Token

I am running into some issues regarding the Authenticity Token in Rails, as I have many times now. But I really don't want to just solve this problem and go on. I would really like to understand the ..

Remove element of a regular array

I have an array of Foo objects. How do I remove the second element of the array? I need something similar to RemoveAt() but for a regular array...

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 use nan and inf in C?

I have a numerical method that could return nan or inf if there was an error, and for testing purposed I'd like to temporarily force it to return nan or inf to ensure the situation is being handled co..

Make a dictionary in Python from input values

Seems simple, yet elusive, want to build a dict from input of [key,value] pairs separated by a space using just one Python statement. This is what I have so far: d={} n = 3 d = [ map(str,raw_input()..

Android – Listen For Incoming SMS Messages

I am trying to create an application for monitoring incoming SMS messages, and launch a program via incoming SMS, also it should read the content from the SMS. Workflow: SMS sent to Android device ..

remove attribute display:none; so the item will be visible

The element is: span { position:absolute; float:left; height:80px; width:150px; top:210px; left:320px; background-color:yellow; display:none; //No..

Programmatically change input type of the EditText from PASSWORD to NORMAL & vice versa

In my application, I have an EditText whose default input type is set to android:inputType="textPassword" by default. It has a CheckBox to its right, which is when checked, changes the input..

RecyclerView - Get view at particular position

I have an activity with a RecyclerView and an ImageView. I am using the RecyclerView to show a list of images horizontally. When I click on an image in the RecyclerView the ImageView in the activity s..

How to reverse MD5 to get the original string?

Possible Duplicate: Is it possible to decrypt md5 hashes? Is it possible to get a string from MD5 in Java? Firstly a string is converted to MD5 checksum, is it possible to get this MD5 che..

In Node.js, how do I "include" functions from my other files?

Let's say I have a file called app.js. Pretty simple: var express = require('express'); var app = express.createServer(); app.set('views', __dirname + '/views'); app.set('view engine', 'ejs');

Using classes with the Arduino

I'm trying to use class objects with the Arduino, but I keep running into problems. All I want to do is declare a class and create an object of that class. What would an example be?..

ImageView in android XML layout with layout_height="wrap_content" has padding top & bottom

I have a vertical LinearLayout containing an ImageView and a few other layouts and views. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="

Display/Print one column from a DataFrame of Series in Pandas

I created the following Series and DataFrame: import pandas as pd Series_1 = pd.Series({'Name': 'Adam','Item': 'Sweet','Cost': 1}) Series_2 = pd.Series({'Name': 'Bob','Item': 'Candy','Cost': 2}) Ser..

Python: BeautifulSoup - get an attribute value based on the name attribute

I want to print an attribute value based on its name, take for example <META NAME="City" content="Austin"> I want to do something like this soup = BeautifulSoup(f) //f is some HTML containin..

Access to the path 'c:\inetpub\wwwroot\myapp\App_Data' is denied

I just installed IIS on Windows XP. When I try to execute an app, I get an error: Access to the path 'c:\inetpub\wwwroot\myapp\App_Data' is denied. Description: An unhandled exception occurred ..

pop/remove items out of a python tuple

I am not sure if I can make myself clear but will try. I have a tuple in python which I go through as follows (see code below). While going through it, I maintain a counter (let's call it 'n') and 'p..

T-SQL string replace in Update

I need to update the values of a column, with a substring replace being done on the existing values. Example: Data contains abc@domain1, pqr@domain2 etc. I need to update the values such that @dom..

How to run Visual Studio post-build events for debug build only

How can I limit my post-build events to running only for one type of build? I'm using the events to copy DLL files to a local IIS virtual directory, but I don't want this happening on the build serve..

Excel: Can I create a Conditional Formula based on the Color of a Cell?

I'm a beginner and trying to create a formula that modifies the contents of Cell A1 based on the color of the cell in B2; If Cell B2 = [the color red] then display FQS. If Cell B2 = [the color yello..

Use Font Awesome Icon in Placeholder

Is it possible to use Font Awesome Icon in a Placeholder? I read that HTML isn't allowed in a placeholder. Is there a workaround? placeholder="<i class='icon-search'></i>" ..

Git clone without .git directory

Is there a flag to pass to git when doing a clone, say don't clone the .git directory? If not, how about a flag to delete the .git directory after the clone?..

How do I find what Java version Tomcat6 is using?

Is there a OS command to find what Java version Tomcat6 is using? I need to use a Perl (including system()) command. I using Linux. Ubuntu and CentOS Is there something like? tomcat6 version ..

SQL : BETWEEN vs <= and >=

In SQL Server 2000 and 2005: what is the difference between these two WHERE clauses? which one I should use on which scenarios? Query 1: SELECT EventId, EventName FROM EventMaster WHERE EventDate..

Angular 2: 404 error occur when I refresh through the browser

I'm new to Angular 2. I have stored my single-page application in my server within a folder named as "myapp". I have changed the URL in the base to`. My project has..

.Net HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is returned

I am in a situation where when I get an HTTP 400 code from the server, it is a completely legal way of the server telling me what was wrong with my request (using a message in the HTTP response conten..

Printing variables in Python 3.4

So the syntax seems to have changed from what I learned in Python 2... here is what I have so far for key in word: i = 1 if i < 6: print ( "%s. %s appears %s times.") % (s..

how to re-format datetime string in php?

I receive a datetime from a plugin. I put it into a variable: $datetime = "20130409163705"; That actually translates to yyyymmddHHmmss. I would need to display this to the user as a transaction t..

UICollectionView - Horizontal scroll, horizontal layout?

I have a UIScrollView that lays out a grid of icons. If you were to imagine the layout for the iOS Springboard, you'd be pretty close to correct. It has a horizontal, paged scroll (just like Springb..

How do I get the current Date/time in DD/MM/YYYY HH:MM format?

How can I get the current date and time in DD/MM/YYYY HH:MM format and also increment the month?..

res.sendFile absolute path

If I do a res.sendfile('public/index1.html'); then I get a server console warning express deprecated res.sendfile: Use res.sendFile instead but it works fine on the client side. But when ..

Python Socket Receive Large Amount of Data

When I try to receive larger amounts of data it gets cut off and I have to press enter to get the rest of the data. At first I was able to increase it a little bit but it still won't receive all of it..

How to install a Notepad++ plugin offline?

I am trying to install a Notepad++ plugin from Plugins -> Plugin Manager, but my office firewall is restricting its download. Is there any alternate way to download plugin offline?..

How to execute a JavaScript function when I have its name as a string

I have the name of a function in JavaScript as a string. How do I convert that into a function pointer so I can call it later? Depending on the circumstances, I may need to pass various arguments int..

IOError: [Errno 13] Permission denied

I have this piece of code to create a .json file to store python data. When i run it in my server i get this error: IOError: [Errno 13] Permission denied: 'juliodantas2015.json' at line with open(out..

How to check for null in Twig?

What construct should I use to check whether a value is NULL in a Twig template?..

How to process SIGTERM signal gracefully?

Let's assume we have such a trivial daemon written in python: def mainloop(): while True: # 1. do # 2. some # 3. important # 4. job # 5. sleep mainloop() ..

How to completely uninstall Android Studio from windows(v10)?

I have already seen this question. But that's for Mac OS. I am using windows. Every time I create a new project or try to build/rebuild the project it freezes!! I have installed the latest version(9..

How to enter command with password for git pull?

I want to do this command in one line: git pull && [my passphrase] How to do it?..

remove / reset inherited css from an element

I know this question was asked before, but before marking it as a duplicate, I want to tell you that my situation is a little different from what I found on the internet. I'm building and embedded sc..

How to disable margin-collapsing?

Is there a way to disable margin-collapsing altogether? The only solutions I've found (by the name of "uncollapsing") entail using a 1px border or 1px padding. I find this unacceptable: the extraneo..

Python error "ImportError: No module named"

Python is installed in a local directory. My directory tree looks like this: (local directory)/site-packages/toolkit/ My code is in here: (local directory)/site-packages/toolkit/exa..

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

Java check if boolean is null

How do you check if a boolean is null or not? So if I know "hideInNav" is null. How do I stop it from further executing? Something like the below doesn't seem to work but why? boolean hideInNav = p..

Can I access variables from another file?

Is it possible to use a variable in a file called first.js inside another file called second.js? first.js contains a variable called colorcodes...

VS 2012: Scroll Solution Explorer to current file

VS2010 had the feature that viewing a file would automatically cause Solution Explorer to scroll to that file. With VS2012, viewing different files from within the IDE no longer scrolls and select th..

How to increase the gap between text and underlining in CSS

Using CSS, when text has text-decoration:underline applied, is it possible to increase the distance between the text and the underline?..

Bootstrap css hides portion of container below navbar navbar-fixed-top

I am building a project with Bootstrap and im facing little issue .I have a container below the Nav-top.My issue is that some portion of my container is hidden below the nav-top header.I dont want to ..

Creating new table with SELECT INTO in SQL

Possible Duplicate: SELECT INTO using Oracle I have came across SQL SELECT INTO statement for creating new table and also dumping old table records into new table in single SQL statement as..

List file names based on a filename pattern and file content?

How can I use Grep command to search file name based on a wild card "LMN2011*" listing all files with this as beginning? I want to add another check on those file content. If file content has som..

Setting background-image using jQuery CSS property

I have an image URL in a imageUrl variable and I am trying to set it as CSS style, using jQuery: $('myObject').css('background-image', imageUrl); This seems to be not working, as: console.log($('m..

How to use timer in C?

What is the method to use a timer in C? I need to wait until 500 ms for a job. Please mention any good way to do this job. I used sleep(3); But this method does not do any work in that time duration. ..

Algorithm to find all Latitude Longitude locations within a certain distance from a given Lat Lng location

Given a database of places with Latitude + Longitude locations, such as 40.8120390, -73.4889650, how would I find all locations within a given distance of a specific location? It doesn't seem very ef..

Android - set TextView TextStyle programmatically?

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

How to display count of notifications in app launcher icon

samsung galaxy note 2 android version 4.1.2 I know that this question was asked before and the reply was not possible How to display balloon counter over application launcher icon on android ..

Typescript react - Could not find a declaration file for module ''react-materialize'. 'path/to/module-name.js' implicitly has an any type

I am trying to import components from react-materialize as - import {Navbar, NavItem} from 'react-materialize'; But when the webpack is compiling my .tsx it throws an error for the above as - ERROR i..

ThreadStart with parameters

How do you start a thread with parameters in C#?..

How to select a radio button by default?

I have some radio buttons and I want one of them to be set as selected by default when the page is loaded. How can I do that? <input type="radio" name="imgsel" value="" /> ..

Copying from one text file to another using Python

I would like to copy certain lines of text from one text file to another. In my current script when I search for a string it copies everything afterwards, how can I copy just a certain part of the tex..

What does Ruby have that Python doesn't, and vice versa?

There is a lot of discussions of Python vs Ruby, and I all find them completely unhelpful, because they all turn around why feature X sucks in language Y, or that claim language Y doesn't have X, alth..

Override default Spring-Boot settings in Junit Test

I have a Spring-Boot application where the default properties are set in an file in the classpath (src/main/resources/ I would like to override some def..

How to make a website secured with https

I have to build a small webapp for a company to maintain their business data... Only those within the company will be using it, but we are planning to host it in public domain, so that the employees ..

How to force keyboard with numbers in mobile website in Android

I have a mobile website and it has some HTML input elements in it, like this: <input type="text" name="txtAccessoryCost" size="6" /> I have embedded the site into a WebView for possible Andro..

Passive Link in Angular 2 - <a href=""> equivalent

In Angular 1.x I can do the following to create a link which does basically nothing: <a href="">My Link</a> But the same tag navigates to the app base in Angular 2. What is the equivale..

Move entire line up and down in Vim

In Notepad++, I can use Ctrl + Shift + Up / Down to move the current line up and down. Is there a similar command to this in Vim? I have looked through endless guides, but have found nothing. If the..

Selenium Webdriver submit() vs click()

Let's say I have an input in a form (looks like a button and interacts like a button) which generates some data (well, the server generates the data based on the form parameters, but for the user, the..

How to use the read command in Bash?

When I try to use the read command in Bash like this: echo hello | read str echo $str Nothing echoed, while I think str should contain the string hello. Can anybody please help me understand this b..

Removing pip's cache?

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

replacing NA's with 0's in R dataframe

I've been playing around with the airquality dataset in R and figuring out how to remove lines with missing values. I used the following command: complete.cases(airquality) AQ1<-airquality[comple..

How can I connect to Android with ADB over TCP?

I am attempting to debug an application on a Motorola Droid, but I am having some difficulty connecting to the device via USB. My development server is a Windows 7 64-bit VM running in Hyper-V, and so..

How to view file diff in git before commit

This often happens to me: I'm working on a couple related changes at the same time over the course of a day or two, and when it's time to commit, I end up forgetting what changed in a specific file...

BOOLEAN or TINYINT confusion

I was designing a database for a site where I need to use a boolean datetype to store only 2 states, true or false. I am using MySQL. While designing the database using phpMyAdmin, I found that I have..

Sending GET request with Authentication headers using restTemplate

I need to retrieve resources from my server by sending a GET request with some Authorization headers using RestTemplate. After going over the docs I noticed that none of the GET methods accepts header..

Htaccess: add/remove trailing slash from URL

My website runs a script called -> WSS wallpaper script My Problem -> I have been trying to force remove or add trailing slash to the end of my URL to prevent duplicated content and also to clean up ..

How to fix: /usr/lib/ version `GLIBCXX_3.4.15' not found

So I'm now desperate in finding a fix for this. I'm compiling a shared library .so in Ubuntu 32 bit (Have tried doing it under Debian and Ubuntu 64 bit, but none worked either) I keep getting: /usr/l..

Jackson serialization: ignore empty values (or null)

I'm currently using jackson 2.1.4 and I'm having some trouble ignoring fields when I'm converting an object to a JSON string. Here's my class which acts as the object to be converted: public class J..

Nginx: Job for nginx.service failed because the control process exited

I got a problem which I have been trying to fix for a few days now and I don't know what to do, have been looking for answers but all of those I found didn't help me. I am kinda new here and I really..

How do you get the selected value of a Spinner?

I am trying to get the selected items string out of a Spinner. So far I have gotten this: bundle.putString(ListDbAdapter.DB_PRI, v.getText().toString()); This does not work and gives a class castin..

How to deal with persistent storage (e.g. databases) in Docker

How do people deal with persistent storage for your Docker containers? I am currently using this approach: build the image, e.g. for PostgreSQL, and then start the container with docker run --volume..

Causes of getting a java.lang.VerifyError

I'm investigating the following java.lang.VerifyError java.lang.VerifyError: (class: be/post/ehr/wfm/application/serviceorganization/report/DisplayReportServlet, method: getMonthData signature: (IILj..

How to mark-up phone numbers?

I want to mark up a phone number as callable link in an HTML document. I have read the microformats approach, and I know, that the tel: scheme would be standard, but is quite literally nowhere impleme..

Is there an equivalent for var_dump (PHP) in Javascript?

We need to see what methods/fields an object has in Javascript...

to remove first and last element in array

How to remove first and last element in an array? For example: var fruits = ["Banana", "Orange", "Apple", "Mango"]; Expected output array: ["Orange", "Apple"] ..

Delete certain lines in a txt file via a batch file

I have a generated txt file. This file has certain lines that are superfluous, and need to be removed. Each line that requires removal has one of two string in the line; "ERROR" or "REFERENCE". The..

How can I select rows with most recent timestamp for each key value?

I have a table of sensor data. Each row has a sensor id, a timestamp, and other fields. I want to select a single row with latest timestamp for each sensor, including some of the other fields. I tho..

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I have been following a manual to install a software suite on Ubuntu. I have no knowledge of MySQL at all. I have done the following installations on my Ubuntu. sudo apt-get update sudo apt-get instal..

How can I serve static html from spring boot?

I ran the spring-boot-sample-web-static project from here, made this alteration to the pom <dependency> <groupId>org.springframework.boot</groupId> <artifactId>sprin..

RegEx - Match Numbers of Variable Length

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

Scheduling Python Script to run every hour accurately

Before I ask, Cron Jobs and Task Scheduler will be my last options, this script will be used across Windows and Linux and I'd prefer to have a coded out method of doing this than leaving this to the e..

Radio button checked event handling

In my application, I need a radio group, in which whenever a radio-button is checked, an alert occur so that I can post it's value to ajax post with jQuery. Can you help me please how i can do it in..

Install NuGet via PowerShell script

As far as I can tell, NuGet is meant to be installed as a Visual Studio extension: But what if I need NuGet on a machine that doesn't have VS..

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

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

Filtering lists using LINQ

I've got a list of People that are returned from an external app and I'm creating an exclusion list in my local app to give me the option of manually removing people from the list. I have a composi..

AngularJS UI Router - change url without reloading state

Currently our project is using default $routeProvider, and I am using this "hack", to change url without reloading page: services.service('$locationEx', ['$location', '$route', '$rootScope', function..

Converting from hex to string

I need to check for a string located inside a packet that I receive as byte array. If I use BitConverter.ToString(), I get the bytes as string with dashes (f.e.: 00-50-25-40-A5-FF). I tried most funct..

Using DISTINCT and COUNT together in a MySQL Query

Is something like this possible: SELECT DISTINCT COUNT(productId) WHERE keyword='$keyword' What I want is to get the number of unique product Ids which are associated with a keyword. The same produ..

How can I start and check my MySQL log?

I want to check the log in MySQL to see the queries that are being run by my application. How can I do this? I am using XAMPP and the directory to MySQL is C:\xampp\mysql. This is what I get when I d..

Storing a Key Value Array into a compact JSON string

I want to store an array of key value items, a common way to do this could be something like: // the JSON data may store several data types, not just key value lists, // but, must be able to identify..

Style jQuery autocomplete in a Bootstrap input field

I have implemented a jQuery autocomplete function to a Bootstrap input. The jQuery autocomplete is working fine but I want to see the results as a combo and I guess it's now happening because I'm usin..

Left join only selected columns in R with the merge() function

I am trying to LEFT Join 2 data frames but I do not want join all the variables from the second data set: As an example, I have dataset 1 (DF1): Cl Q Sales Date A 2 30 01/01/2014..

Android "elevation" not showing a shadow

I have a ListView, and with each list item I want it to show a shadow beneath it. I am using Android Lollipop's new elevation feature to set a Z on the View that I want to cast a shadow, and am alread..

Find out which remote branch a local branch is tracking

See also: How can I see which Git branches are tracking which remote / upstream branch? How can I find out which remote branch a local branch is tracking? Do I need to parse git config outp..

Does MySQL foreign_key_checks affect the entire database?

When I execute this command in MySQL: SET FOREIGN_KEY_CHECKS=0; Does it affect the whole engine or it is only my current transaction?..

Typescript - multidimensional array initialization

I'm playing with Typescript and I wonder, how to properly instantiate and declare multidimensional array. Here's my code: class Something { private things: Thing[][]; constructor() { ..

How to override the [] operator in Python?

What is the name of the method to override the [] operator (subscript notation) for a class in Python?..

Pure css close button

JSFiddle Is there any way to make something like the X on that link with pure css? ..

Bootstrap change div order with pull-right, pull-left on 3 columns

I’ve been working on this the whole day but don’t come up with a solution. I have 3 columns in one row in a container. 1: right content – pull-right 2: navigation – pull-left 3: main conten..

Count number of rows matching a criteria

I am looking for a command in R which is equivalent of this SQL statement. I want this to be a very simple basic solution without using complex functions OR dplyr type of packages. Select count(*) as..

How do I capture the output of a script if it is being ran by the task scheduler?

Using Windows Server 2008, how do I go about capturing the output of a script that is being ran with the windows task scheduler? I'm testing a rather long custom printing batch-script, and for debugg..

Pagination response payload from a RESTful API

I want to support pagination in my RESTful API. My API method should return a JSON list of product via /products/index. However, there are potentially thousands of products, and I want to page throug..

Play an audio file using jQuery when a button is clicked

I am trying to play an audio file when I click the button, but it's not working, my html code is: <html> <body> <div id="container"> <button id="play"..

Error installing mysql2: Failed to build gem native extension

I am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysql2 it gives me the following error: Error installing my..

Maven does not find JUnit tests to run

I have a maven program, it compiles fine. When I run mvn test it does not run any tests (under TESTs header says There are no tests to run.). I've recreated this problem with a super simple setup ..

Defining a HTML template to append using JQuery

I have got an array which I am looping through. Every time a condition is true, I want to append a copy of the HTML code below to a container element with some values. Where can I put this HTML to re..

What parameters should I use in a Google Maps URL to go to a lat-lon?

I would like to produce a url for Google Maps that goes to a specific latitude and longitude. Now, I generate a url such as this: 41.881N 152 31.324W..

Check if an element is a child of a parent

I have the following code. <html> <head> <script type="text/javascript" src=""></script> </head> <..

good example of Javadoc

is there a good example of a source file containing Javadoc? I can find lots of good examples of Javadoc on the internet, I would just like to find out the particular syntax used to create them, and..

C library function to perform sort

Is there any library function available in C standard library to do sort? ..

JBoss debugging in Eclipse

How do you configure JBoss to debug an application in Eclipse?..

How to set Sqlite3 to be case insensitive when string comparing?

I want to select records from sqlite3 database by string matching. But if I use '=' in the where clause, I found that sqlite3 is case sensitive. Can anyone tell me how to use string comparing case-ins..

How to Disable GUI Button in Java

so I have this small piece of code for my GUI: import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; import javax..

OSError: [Errno 2] No such file or directory while using python subprocess in Django

I am trying to run a program to make some system calls inside Python code using which throws the following error: Traceback (most recent call last): File "<console>", li..

Swift - iOS - Dates and times in different format

I am working for an application written in swift and i want to manipulate dates and times let timestamp = NSDateFormatter.localizedStringFromDate( NSDate(), dateStyle: .ShortStyle, timeSty..

Using Sockets to send and receive data

I am using sockets to connect my Android application (client) and a Java backend Server. From the client I would like to send two variables of data each time I communicate with the server. 1) Some ki..

How to use onSaveInstanceState() and onRestoreInstanceState()?

I am trying to save data across orientation changes. As demonstrated in the code below, I use onSaveInstanceState() and onRestoreInstanceState(). I try to get the saved value and I check if it is the ..

Go doing a GET request and building the Querystring

I am pretty new to Go and don't quite understand everything as yet. In many of the modern languages Node.js, Angular, jQuery, PHP you can do a GET request with additional query string parameters. Do..

How to list AD group membership for AD users using input list?

I'm fairly new PS user... Looking for some assistance with a powershell script to obtain list of security groups user is member of. To describe what I need: I have input list (txt file) with many u..

How to return a part of an array in Ruby?

With a list in Python I can return a part of it using the following code: foo = [1,2,3,4,5,6] bar = [10,20,30,40,50,60] half = len(foo) / 2 foobar = foo[:half] + bar[half:] Since Ruby does everythi..

install beautiful soup using pip

I am trying to install BeautifulSoup using pip in Python 2.7. I keep getting an error message, and can't understand why. I followed the instructions to install pip, which was installed to the followi..

How do I run Google Chrome as root?

I have installed Google Chrome in Ubuntu 10.10. When I try to use in normal user, it is working fine. Now if I want to use as a root it gives the following error: Google Chrome does not run as ro..

How to Set Opacity (Alpha) for View in Android

I have a button as in the following: <Button android:text="Submit" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content"> &l..

jQuery append and remove dynamic table row

I can add many rows for a table, but I can't remove many rows. I only can remove 1 row per sequential add. <script src="//"></script&g..