Questions Tagged with #Naked objects

An architectural pattern whereby an object-oriented user interface is created directly from the underlying domain object model using reflection.

What's the difference between VARCHAR and CHAR?

What's the difference between VARCHAR and CHAR in MySQL? I am trying to store MD5 hashes...

Laravel Eloquent "WHERE NOT IN"

I'm having trouble to write query in laravel eloquent ORM. my query is SELECT book_name,dt_of_pub,pub_lang,no_page,book_price FROM book_mast WHERE book_price NOT IN (100,200); Now I wa..

Get all inherited classes of an abstract class

I have an abstract class: abstract class AbstractDataExport { public string name; public abstract bool ExportData(); } I have classes which are derived from AbstractDataExport: cla..

How to change default install location for pip

I'm trying to install Pandas using pip, but I'm having a bit of trouble. I just ran sudo pip install pandas which successfully downloaded pandas. However, it did not get downloaded to the location t..

jQuery Ajax File Upload

Can I use the following jQuery code to perform file upload using POST method of an ajax request ? $.ajax({ type: "POST", timeout: 50000, url: url, data: dataString, success: funct..

Connecting PostgreSQL 9.2.1 with Hibernate

I have a blank Spring MVC project, and I've installed Hibernate and the PostgreSQL drivers using Maven. I'm running short on complete tutorials that show how to connect PostgreSQL with Hibernate. An..

Responsive css styles on mobile devices ONLY

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

Remove all special characters, punctuation and spaces from string

I need to remove all special characters, punctuation and spaces from a string so that I only have letters and numbers...

Difference between git pull and git pull --rebase

I started using git sometime back and do not fully understand the intricacies. My basic question here is to find out the difference between a git pull and git pull --rebase , since adding the --rebase..

syntax error, unexpected T_VARIABLE

I can't seem to find where my code has went wrong. Here is my full error: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\GigaLoad.com\register.php on line 102 But I've bee..

Windows Scipy Install: No Lapack/Blas Resources Found

I am trying to install python and a series of packages onto a 64bit windows 7 desktop. I have installed Python 3.4, have Microsoft Visual Studio C++ installed, and have successfully installed numpy, p..

load and execute order of scripts

There are so many different ways to include JavaScript in a html page. I know about the following options: inline code or loaded from external URI included in <head> or <body> tag [1,2] having..

Embed Google Map code in HTML with marker

I have several places with their latitude and longitude. I want to display them in google map. Thats ok, what i can't is to display the marker at the specific lat,long position. e.g. if i've the foll..

Run a Java Application as a Service on Linux

I have written a Java server application that runs on a standard virtual hosted Linux solution. The application runs all the time listening for socket connections and creating new handlers for them. ..

Why there is no ConcurrentHashSet against ConcurrentHashMap

HashSet is based on HashMap. If we look at HashSet<E> implementation, everything is been managed under HashMap<E,Object>. <E> is used as a key of HashMap. And we know that HashMap..

Why don't Java's +=, -=, *=, /= compound assignment operators require casting?

Until today, I thought that for example: i += j; Was just a shortcut for: i = i + j; But if we try this: int i = 5; long j = 8; Then i = i + j; will not compile but i += j; will compile fine...

Regular expression to match URLs in Java

I use RegexBuddy while working with regular expressions. From its library I copied the regular expression to match URLs. I tested successfully within RegexBuddy. However, when I copied it as Java Stri..

configure Git to accept a particular self-signed server certificate for a particular https remote

The sysadmin for a project I'm on has decided that SSH is "too much trouble"; instead, he has set up Git to be accessible via an https:// URL (and username/password authentication). The server for thi..

Adding Text to DataGridView Row Header

Does C# allow you to add a String to a RowHeader in a DataGridView? If so, how is it accomplished? I'm writing a Windows Form to displayed Customer Payment Data for the year so far. The ColumnHeader..

How do I setup the dotenv file in Node.js?

I am trying to use the dotenv NPM package and it is not working for me. I have a file config/config.js with the following content: 'use strict'; var dotenv = require('dotenv'); dotenv.load(); consol..

Is there a numpy builtin to reject outliers from a list

Is there a numpy builtin to do something like the following? That is, take a list d and return a list filtered_d with any outlying elements removed based on some assumed distribution of the points in ..

Where does this come from: -*- coding: utf-8 -*-

Python recognizes the following as instruction which defines file's encoding: # -*- coding: utf-8 -*- I definitely saw this kind of instructions before (-*- var: value -*-). Where does it come from..

How can I get href links from HTML using Python?

import urllib2 website = "WEBSITE" openwebsite = urllib2.urlopen(website) html = getwebsite.read() print html So far so good. But I want only href links from the plain text HTML. How can I solve..

Enable vertical scrolling on textarea

I have a textarea that I want to enable vertical scrolling. When I exceed the height of the textarea, it increases in size. The scroll bar does not appear. I want that a vertical scroll bar appears an..

Setting href attribute at runtime

What is the best way to set the href attribute of the <a> tag at run time using jQuery? Also, how do you get the value of the href attribute of the <a> tag using jQuery?..

Your content must have a ListView whose id attribute is 'android.R.id.list'

I have created an xml file like this: <?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" ..

Pandas read_sql with parameters

Are there any examples of how to pass parameters with an SQL query in Pandas? In particular I'm using an SQLAlchemy engine to connect to a PostgreSQL database. So far I've found that the following w..

Git: See my last commit

I just want to see the files that were committed in the last commit exactly as I saw the list when I did git commit. Unfortunately searching for git "last commit" log in Google gets me nowhere. And..

Check if event exists on element

Is there a way to check if an event exists in jQuery? I’m working on a plugin that uses custom namespaced events, and would like to be able to check if the event is bound to an element or not...

How can I change the width and height of slides on Slick Carousel?

http://kenwheeler.github.io/slick/ A friend suggested that I use Ken Wheeler's Slick carousel and I decided to give it a try. I am having a couple of problems with it. The first is that the slides ..

rbenv not changing ruby version

I installed rbenv according to the github directions. I am running OSX but I have tried this on a Ubuntu 12.04 VM and got the same results. The following is what i get in my terminal when I try to cha..

How do I clear a combobox?

I have some combo-boxes that are set up as drop down lists, and the user can pick a number in them. I also have a Clear button that should clear the text from the combo boxes but I can't seem to get i..

how to automatically scroll down a html page?

I'm trying to start each page after the homepage about 500px down, similar to this website: http://unionstationdenver.com/ You'll notice when viewing pages after the homepage, you're automatically s..

Difference between getContext() , getApplicationContext() , getBaseContext() and "this"

What is the difference between getContext() , getApplicationContext() , getBaseContext() , and "this"? Though this is simple question I am unable to understand the basic difference between them. Ple..

Check if a string contains a substring in SQL Server 2005, using a stored procedure

I've a string, @mainString = 'CATCH ME IF YOU CAN'. I want to check whether the word ME is inside @mainString. How do I check if a string has a specific substring in SQL?..

How can I reverse a list in Python?

How can I do the following in Python? array = [0, 10, 20, 40] for (i = array.length() - 1; i >= 0; i--) I need to have the elements of an array, but from the end to the beginning...

PHP order array by date?

Possible Duplicate: PHP Sort a multidimensional array by element containing date I have some data from XML or JSON in a PHP array that looks like this: [0]= array(2) { ["title"]= strin..

JFrame background image

I am creating a GUI, albeit a simple one, and I want to have a background image (2048 X 2048) fill up the whole window and a square to the left top corner where the occasional 64 X 64 image can be loa..

Best way to "negate" an instanceof

I was thinking if there exists a better/nicer way to negate an instanceof in Java. Actually, I'm doing something like: if(!(str instanceof String)) { /* do Something */ } But I think that a "beauti..

Tomcat in Intellij Idea Community Edition

Is it possible to run a web application using Tomcat Server in Intellij Idea Community Edition? I tried to find some information about it but haven't achived any success...

Calculating frames per second in a game

What's a good algorithm for calculating frames per second in a game? I want to show it as a number in the corner of the screen. If I just look at how long it took to render the last frame the number c..

How to programmatically add controls to a form in VB.NET

I am working on an inventory in Visual Basic 2010 Express Edition. I don't know the number of fields that will be necessary for the inventory. My hope was that I could add textboxes/checkboxes/buttons..

Exit a Script On Error

I'm building a Shell Script that has a if function like this one: if jarsigner -verbose -keystore $keyst -keystore $pass $jar_file $kalias then echo $jar_file signed sucessfully else echo ERR..

MySQL error: key specification without a key length

I have a table with a primary key that is a varchar(255). Some cases have arisen where 255 characters isn't enough. I tried changing the field to a text, but I get the following error: BLOB/TEXT colu..

How to run a hello.js file in Node.js on windows?

I am trying to run a hello world program written in javascript in a separate file named hello.js Currently running windows version of node.js. The code runs perfectly in console window but how do I ..

What is the best way to test for an empty string in Go?

Which method is best (more idomatic) for testing non-empty strings (in Go)? if len(mystring) > 0 { } Or: if mystring != "" { } Or something else?..

Export query result to .csv file in SQL Server 2008

How can I export a query result to a .csv file in SQL Server 2008?..

How to detect a textbox's content has changed

I want to detect whenever a textbox's content has changed. I can use the keyup method, but that will also detect keystrokes which do not generate letters, like the arrow keys. I thought of two methods..

A potentially dangerous Request.Path value was detected from the client (*)

I am receiving the rather self explanatory error: A potentially dangerous Request.Path value was detected from the client (*). The issue is due to * in the request URL: https://stackoverflow.co..

npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY

I am trying all the ways of creating react application. I have tried with maven and now i am trying with crate-react-app build system from Facebook Incubators. When i tried to run the command create-..

Hibernate openSession() vs getCurrentSession()

I have some questions about using Hibernate in JSP web application. What should be the value for hibernate.current_session_context_class? Then, which of the following statements should be used? And ..

Difference between subprocess.Popen and os.system

What is the difference between subprocess.Popen() and os.system()?..

Convert UTF-8 with BOM to UTF-8 with no BOM in Python

Two questions here. I have a set of files which are usually UTF-8 with BOM. I'd like to convert them (ideally in place) to UTF-8 with no BOM. It seems like codecs.StreamRecoder(stream, encode, decode,..

How to customize an end time for a YouTube video?

I'm trying to figure out how I can specify a custom end time for an embedded YouTube video. I know that I can customize the start time by adding &start=30, but I haven't seen anything relating to ..

How can git be installed on CENTOS 5.5?

How can I install git on CENTOS 5.5 machine? I tried to install it from yum but got following msg. root@host [~]# sudo yum install git Loaded plugins: fastestmirror Loading mirror speeds from cached ..

What is the meaning of the term "thread-safe"?

Does it mean that two threads can't change the underlying data simultaneously? Or does it mean that the given code segment will run with predictable results when multiple threads are executing that co..

Setting ANDROID_HOME enviromental variable on Mac OS X

Could anybody post a working solution for setting ANDROID_HOME via the terminal? My path to the Android-SDK is /Applications/ADT/sdk...

How do you append rows to a table using jQuery?

Hi I was trying to add a row to a table using jQuery, but it is not working. What might be the reason? And, can I put in some value to the newly added row..? Here is the code: <html> <head..

How to include scripts located inside the node_modules folder?

I have a question concerning best practice for including node_modules into a HTML website. Imagine I have Bootstrap inside my node_modules folder. Now for the production version of the website, how w..

Convert dictionary values into array

What is the most efficient way of turning the list of values of a dictionary into an array? For example, if I have a Dictionary where Key is String and Value is Foo, I want to get Foo[] I am using V..

Can I use complex HTML with Twitter Bootstrap's Tooltip?

If I check official documentation, I can see a property called HTML: Name | Type | default | Description ---------------------------------------------------------------------------..

How to convert object array to string array in Java

I use the following code to convert an Object array to a String array : Object Object_Array[]=new Object[100]; // ... get values in the Object_Array String String_Array[]=new String[Object_Array.len..

HTML IF Statement

I just wanna know how to do an if-statement in simple HTML. Like the [if IE6] thingy I'd like to do something like this [IF 5>6] How's the syntax? I can't seem to find anything but [If!IE6] and..

jQuery autohide element after 5 seconds

Is it possible to automatically hide an element in a web page 5 seconds after the form loads using jQuery? Basically, I've got <div id="successMessage">Project saved successfully!</div> ..

Can you test google analytics on a localhost address?

I have to test out my new GA account on my local machine. Will this work just by copying the standard snippet supplied by Google onto the page ? I don't want to spend 24 hours waiting to see if it..

Duplicate line in Visual Studio Code

I am trying to find the shortcut for duplicating a line in Visual Studio Code (I am using 1.3.1) I tried the obvious CTRL + D but that doesn't seem to work. ..

RegEx for Javascript to allow only alphanumeric

I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just want one what would allow ei..

php/mySQL on XAMPP: password for phpMyAdmin and mysql_connect different?

I am running phpMyAdmin and MySQL on XAMPP for Windows. I am accessing the MySQL database in two ways. First, via localhost/phpmyadmin, and second, via a connection.php file (with mysql_connect('loc..

Focus Next Element In Tab Index

I am trying to move the focus to the next element in the tab sequence based upon the current element which has focus. Thus far I have not turned up anything in my searches. function OnFocusOut() { ..

How to make remote REST call inside Node.js? any CURL?

In Node.js, other than using child process to make CURL call, is there a way to make CURL call to remote server REST API and get the return data? I also need to set up the request header to the remot..

Find by key deep in a nested array

Let's say I have an object: [ { 'title': "some title" 'channel_id':'123we' 'options': [ { 'channel_id':'abc' 'image':'h..

getResources().getColor() is deprecated

Using: buildToolsVersion "22.0.1" , targetSdkVersion 22 in my gradle file. I found that the useful getResources().getColor(R.color.color_name) is deprecated. What should I use instead?..

Is there a template engine for Node.js?

I'm experimenting with building an entire web application using Node.js. Is there a template engine similar to (for example) the Django template engine or the like that at least allows you to extend b..

adding multiple event listeners to one element

So my dilemma is that I don't want to write the same code twice. Once for the click event and another for the touchstart event. Here is the original code: document.getElementById('first').addEventLi..

How to Debug Variables in Smarty like in PHP var_dump()

I have some variables inside a template and I don't know where I assigned them. I need to know what is inside a particular variable; for instance, say I have a variable in smarty called member. I trie..

How can I convert a timestamp from yyyy-MM-ddThh:mm:ss:SSSZ format to MM/dd/yyyy hh:mm:ss.SSS format? From ISO8601 to UTC

I want to convert the timestamp 2011-03-10T11:54:30.207Z to 10/03/2011 11:54:30.207. How can I do this? I want to convert ISO8601 format to UTC and then that UTC should be location aware. Please help ..

How to get Django and ReactJS to work together?

New to Django and even newer to ReactJS. I have been looking into AngularJS and ReactJS, but decided on ReactJS. It seemed like it was edging out AngularJS as far as popularity despite AngularJS havin..

How to set Field value using id in javascript?

I want to set an HTML field's value using JavaScript when onclick event is raised by clicking a button/hyperlink.. I Googled and found many articles using the name attribute, but I want to set the val..

What is the T-SQL syntax to connect to another SQL Server?

If I need to copy a stored procedure (SP) from one SQL Server to another I right click on the SP in SSMS and select Script Stored Procedure as > CREATE to > New Query Editor Window. I then change the ..

REST API - why use PUT DELETE POST GET?

So, I was looking through some articles on creating REST API's. And some of them suggest using all types of HTTP requests: like PUT DELETE POST GET. We would create for example index.php and write API..

How to display databases in Oracle 11g using SQL*Plus

With help of this command show databases; I can see databases in MySQL. How to show the available databases in Oracle?..

SQL Last 6 Months

I have table containing one datetime column. I need to return rows for only last 6 months. This can be done by where datetime_column > DATEADD(m, -6, current_timestamp) But how to extend this o..

FFmpeg: How to split video efficiently?

I wish to split a large avi video into two smaller consecutive videos. I am using ffmpeg. One way is to run ffmpeg two times: ffmpeg -i input.avi -vcodec copy -acodec copy -ss 00:00:00 -t 00:30:00 o..

How to build a JSON array from mysql database

Okay I have been racking my brain trying to build a JSON array from mysql. The array MUST be in the following format. I am using fullcalendar and want to make the events on the calendar dynamic. Below..

FileSystemWatcher Changed event is raised twice

I have an application where I am looking for a text file and if there are any changes made to the file I am using the OnChanged eventhandler to handle the event. I am using the NotifyFilters.LastWrite..

Android: Center an image

I've got a linear layout and an image... <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" andro..

Android Horizontal RecyclerView scroll Direction

I made a Horizontal RecyclerView and it works fine(thanks to this) but the direction of scroll and data are expand from left to right; then How can I change the RecyclerView scroll direction like in t..

How to install mongoDB on windows?

I am trying to test out mongoDB and see if it is anything for me. I downloaded the 32bit windows version, but have no idea on how to continue from now on. I normally use the WAMP services for develop..

Create instance of generic type in Java?

Is it possible to create an instance of a generic type in Java? I'm thinking based on what I've seen that the answer is no (due to type erasure), but I'd be interested if anyone can see something I'm ..

JQuery: dynamic height() with window resize()

I'm having an issue identical to this poster: Jquery problem with height() and resize() But the solution doesn't fix my issue. I have three stacked divs, and I want to use JQuery to make the middle o..

Iterating through all the cells in Excel VBA or VSTO 2005

I need to simply go through all the cells in a Excel Spreadsheet and check the values in the cells. The cells may contain text, numbers or be blank. I am not very familiar / comfortable working with..

process.env.NODE_ENV is undefined

I'm trying to follow a tutorial on NodeJs. I don't think I missed anything but whenever I call the process.env.NODE_ENV the only value I get back is undefined. According to my research the default va..

How to get the URL without any parameters in JavaScript?

If I use: alert(window.location.href); I get everything including query strings. Is there a way to just get the main url part, for example: http://mysite.com/somedir/somefile/ instead of http:..

Export data from R to Excel

I am writing codes to export database from R into Excel, I have been trying others codes including: write.table(ALBERTA1, "D:/ALBERTA1.txt", sep="\t") write.csv(ALBERTA1,":\ALBERTA1.csv") your_filena..

Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK - Android

I know there are lots of questions similiar to this one, but i couldn't find a solution for my problem in any of those. Besides, I'll provide details for my specific case. I coded an Ionic project in..

Get json value from response

{"id":"2231f87c-a62c-4c2c-8f5d-b76d11942301"} If I alert the response data I see the above, how do I access the id value? My controller returns like this: return Json( new { id = indic..

Generate random numbers uniformly over an entire range

I need to generate random numbers within a specified interval, [max;min]. Also, the random numbers should be uniformly distributed over the interval, not located to a particular point. Currenly I am..

How to assign name for a screen?

I'm using the screen multiplexer tool on the command shell and open a lot of screens. I then forget which process ID associates with which task. I would like to set a name for a screen but can't find..

How to read from input until newline is found using scanf()?

I was asked to do a work in C when I'm supposed to read from input until there's a space and then until the user presses enter. If I do this: scanf("%2000s %2000s", a, b); It will follow the 1st ru..

Multiprocessing vs Threading Python

I am trying to understand the advantages of multiprocessing over threading. I know that multiprocessing gets around the Global Interpreter Lock, but what other advantages are there, and can threading ..

How can I get all sequences in an Oracle database?

Is there any command that I can run so that I can get all the sequences? I am using Oracle 11g. I am using Toad for Oracle to connect to it. I can visually see the sequences in Toad, but I like to kn..

Trying to add adb to PATH variable OSX

I am trying to develop for android and I want to add the adb to my PATH so that I can launch it really easily. I have added directories before by for some reason adb does not want to be found. This is..

CSS-Only Scrollable Table with fixed headers

I have a solution by which I can create scrollable tables w/fixed header/footer using minor jQuery and CSS - but I am looking for a way to make this a CSS-only solution that is cross-browser compliant..

Parsing CSV files in C#, with header

Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser. Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a ..

How to import and use image in a Vue single file component?

I think this should be simple, but I am facing some trouble on how to import and use an image in Vue single file component. Can someone help me how to do this? Here is my code snippet: <template la..

std::wstring VS std::string

I am not able to understand the differences between std::string and std::wstring. I know wstring supports wide characters such as Unicode characters. I have got the following questions: When should ..

PHP: How do I display the contents of a textfile on my page?

I have a .txt file on my web server (locally) and wish to display the contents within a page (stored on the same server) via PHP echo. The .txt file contains a number that is updated by another scrip..

How do I pipe or redirect the output of curl -v?

For some reason the output always gets printed to the terminal, regardless of whether I redirect it via 2> or > or |. Is there a way to get around this? Why is this happening?..

Entity Framework - Generating Classes

I have an existing database. I was hoping there was a way to generate class files from this database. However, I seem to see a lot of generating the database from the class files. Is there a way to g..

Dart: mapping a list (list.map)

I have a list of Strings, e.g., var moviesTitles = ['Inception', 'Heat', 'Spider Man']; and wanted to use moviesTitles.map to convert them to a list of Tab Widgets in Flutter...

Python foreach equivalent

I am diving into Python and I have a question about foreach iteration. I am new to Python and I have some experience in C#. So I am wondering, if there is some equivalent function in Python for iterat..

How to join on multiple columns in Pyspark?

I am using Spark 1.3 and would like to join on multiple columns using python interface (SparkSQL) The following works: I first register them as temp tables. numeric.registerTempTable("numeric") Ref..

Pass PDO prepared statement to variables

I am using a prepared statement to upload submitted information into a MYSQL database. I would like to know how to pass my prepared statements to a separate variable so I can post a summary of what wa..

What is an MvcHtmlString and when should I use it?

The documentation for MvcHtmlString is not terribly enlightening: Represents an HTML-encoded string that should not be encoded again. It's not clear to me what exactly the implications of this a..

Using both Python 2.x and Python 3.x in IPython Notebook

I use IPython notebooks and would like to be able to select to create a 2.x or 3.x python notebook in IPython. I initially had Anaconda. With Anaconda a global environment variable had to be changed..

Removing character in list of strings

If I have a list of strings such as: [("aaaa8"),("bb8"),("ccc8"),("dddddd8")...] What should I do in order to get rid of all the 8s in each string? I tried using strip or replace in a for loop but ..

How do I change the background color of a plot made with ggplot2

By default, ggplot2 produces plots with a grey background. How do I change the color of the background of the plot? For example, a plot produced by the following code: library(ggplot2) myplot<-g..

SQL RANK() over PARTITION on joined tables

I have two tables RSLTS and CONTACTS: RSLTS QRY_ID | RES_ID | SCORE ----------------------------- A | 1 | 15 A | 2 | 32 A | 3 | 29 C | ..

Is it a bad practice to use an if-statement without curly braces?

I've seen code like this: if(statement) do this; else do this; However, I think this is more readable: if(statement){ do this; }else{ do this; } Since both methods work, is this ..

How to find the nearest parent of a Git branch?

Let's say I have the following local repository with a commit tree like this: master --> a \ \ develop c --> d \ \ feature..

How to convert a factor to integer\numeric without loss of information?

When I convert a factor to a numeric or integer, I get the underlying level codes, not the values as numbers. f <- factor(sample(runif(5), 20, replace = TRUE)) ## [1] 0.0248644019011408 0.0248644..

Copying text outside of Vim with set mouse=a enabled

After enabling set mouse=a, text copied inside of Vim will not paste outside of Vim. Does anybody know of a way to fix this? Here, selecting text with the mouse turns on visual mode and disables the ..

How to read/write arbitrary bits in C/C++

Assuming I have a byte b with the binary value of 11111111 How do I for example read a 3 bit integer value starting at the second bit or write a four bit integer value starting at the fifth bit?..

How can Bash execute a command in a different directory context?

I have a common command that gets called from within very specific directories. There is only one executable sitting in /bin for this program, and the current working directory is very important for r..

shell script to remove a file if it already exist

I am working on some stuff where I am storing data in a file. But each time I run the script it gets appended to the previous file. I want help on how I can remove the file if it already exists...

Error in installation a R package

Please help me, I cannot install "MASS" package. > library(MASS) Error in library(MASS) : there is no package called ‘MASS’ I tried to install MASS package from local: > utils:::menuInst..

How should I escape strings in JSON?

When creating JSON data manually, how should I escape string fields? Should I use something like Apache Commons Lang's StringEscapeUtilities.escapeHtml, StringEscapeUtilities.escapeXml, or should I us..

How to put a component inside another component in Angular2?

I'm new at Angular and I'm still trying to understand it. I've followed the course on the Microsoft Virtual Academy and it was great, but I found a little discrepancy between what they said and how my..

Jquery select change not firing

I need to capture when a select box changes, should be simple! $('#multiid').change(function(){ alert('Change Happened'); }); But it does not work, I suspected the problem is that the selec..

How to center the content inside a linear layout?

I'm trying to center an ImageView inside a LinearLayout horizontally and vertically, but I just can't do it. The main reason why I'm not using a RelativeLayout for that is because I need the layout_we..

How to get list of dates between two dates in mysql select query

I want list of dates lies between two dates by select query. For example: If i give '2012-02-10' and '2012-02-15' I need the result. date ---------- 2012-02-10 2012-02-11 2012-02-12 2012-02-1..

Decompile .smali files on an APK

I downloaded APK Manager that lets me unpack APK files. But it only unpacks it and doesn't decompile the .smali file to .java. Is it possible to decompile the .smali to .java?..

Where is Python language used?

I am a web developer and usually use PHP, JavaScript or MySQL. I have heard lot about Python. But I have no idea where it is used and why it is used. Just like PHP, ASP, ColdFusion, .NET are used to..

How can I convert a file pointer ( FILE* fp ) to a file descriptor (int fd)?

I have a FILE *, returned by a call to fopen(). I need to get a file descriptor from it, to make calls like fsync(fd) on it. What's the function to get a file descriptor from a file pointer?..

How to reset or change the passphrase for a GitHub SSH key?

I have forgoten my passphrase in Git. How do I reset it? I found two solutions on Stack Overflow, but I want to know what process to follow to reset it or to get it...

What is the role of the package-lock.json?

npm@5 has been published, it has a new feature package-lock.json file (after npm install) which confuses me. I want to know, what is the effect of this file?..

How to write to file in Ruby?

I need to read the data out of database and then save it in a text file. How can I do that in Ruby? Is there any file management system in Ruby?..

org.xml.sax.SAXParseException: Content is not allowed in prolog

I have a Java based web service client connected to Java web service (implemented on the Axis1 framework). I am getting following exception in my log file: Caused by: org.xml.sax.SAXParseException:..

Resetting a form in Angular 2 after submit

I am aware that Angular 2 currently lacks a way to easily reset a form to a pristine state. Poking around I have found a solution like the one below that resets the form fields. It has been suggested..

'tuple' object does not support item assignment

I am using the PIL library. I am trying to make an image look red-er, this is what i've got. from PIL import Image image = Image.open('balloon.jpg') pixels = list(image.getdata()) for pixel in pixel..

How to name an object within a PowerPoint slide?

So I know how to name a textbox, or a like object in PowerPoint with VB, but I was wondering if there was a way to name objects through the Ribbon (PowerPoint 2007). For instance, if I add a text box ..

How to get the nth occurrence in a string?

I would like to get the starting position of the 2nd occurrence of ABC with something like this: var string = "XYZ 123 ABC 456 ABC 789 ABC"; getPosition(string, 'ABC', 2) // --> 16 How would you..

Set output of a command as a variable (with pipes)

Can you redirect the output of a command to a variable with pipes? I haven't tried much as I haven't been able to think of anything to try, but I have tried one method (with two variations)... For e..

Change border-bottom color using jquery?

I want to change the color of the bottom border using jquery..Thanks..

How do I navigate to another page when PHP script is done?

I have a simple POST script that I need to return to the page that was doing the Posting. Is there any way to do it like this? if($done) { //go to page } ..

The best node module for XML parsing

As far as XML parsing is concerned, which is the best node module, that I can use for XML parsing?..

Check if a class `active` exist on element with jquery

Check if a class active exist on an li with a class menu For example <li class="menu active">something...</li> ..

Split column at delimiter in data frame

I would like to split one column into two within at data frame based on a delimiter. For example, a|b b|c to become a b b c within a data frame. Thanks!..

How to get all options in a drop-down list by Selenium WebDriver using C#?

I'm new to both C# and Selenium WebDriver. I know how to select/click on an option in a drop-down list, but I've a problem before that. Since the drop-down list is dynamically generated, I have to g..

horizontal line and right way to code it in html, css

I need to draw a horizontal line after some block, and I have three ways to do it: 1) Define a class h_line and add css features to it, like #css .hline { width:100%; height:1px; background: #fff } ..

Check Whether a User Exists

I want to create a script to check whether a user exists. I am using the logic below: # getent passwd test > /dev/null 2&>1 # echo $? 0 # getent passwd test1 > /dev/null 2&>1 # ec..

C++: Rounding up to the nearest multiple of a number

OK - I'm almost embarrassed posting this here (and I will delete if anyone votes to close) as it seems like a basic question. Is this the correct way to round up to a multiple of a number in C++? I..

Uploading an Excel sheet and importing the data into SQL Server database

I am developing this simple application to upload an Excel file (.xlsx) and import the data present in that Excel worksheet into a SQL Server Express database in .NET I'm using the following code on..

Why am I getting an OPTIONS request instead of a GET request?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script> <script> $.get("http://example.com/", function(data) { alert(data); })..

What would be the Unicode character for big bullet in the middle of the character?

I want something like 0x2022 8226 BULLET • But bigger. I can't even seem to find them at http://www.ssec.wisc.edu/~tomw/java/unicode.html What should I search for? Dots? bullets?..

convert UIImage to NSData

I am using this code in my app which will help me to send a image. However, I have an image view with an image. I have no file in appbundle but have the image in my side. How can I change the below c..

how to use font awesome in own css?

I'm using bootstrap and Font Awesome. In a custom css class I'm working on I tried to include Font Awesome icons instead of using images. Here is my code before Font Awesome. .data .close { display..

Difference between links and depends_on in docker_compose.yml

According to the Docker Compose's compose-file documentation: depends_on - Express dependency between services. links - Link to containers in another service and also express dependency between serv..

Pinging servers in Python

In Python, is there a way to ping a server through ICMP and return TRUE if the server responds, or FALSE if there is no response?..

WebSockets vs. Server-Sent events/EventSource

Both WebSockets and Server-Sent Events are capable of pushing data to browsers. To me they seem to be competing technologies. What is the difference between them? When would you choose one over the ot..

How can I include css files using node, express, and ejs?

I'm trying to follow the instructions to https://stackoverflow.com/a/18633827/2063561, but I still can't get my styles.css to load. From app.js app.use(express.static(path.join(__dirname, 'public')..

Remove Sub String by using Python

I already extract some information from a forum. It is the raw string I have now: string = 'i think mabe 124 + <font color="black"><font face="Times New Roman">but I don\'t have a big exp..

Decreasing for loops in Python impossible?

I could be wrong (just let me know and I'll delete the question) but it seems python won't respond to for n in range(6,0): print n I tried using xrange and it didn't work either. How can I impl..

Uploading Images to Server android

I wanted to know which is the best way to upload image to server without loosing its quality. I have searched on google found various methods of posting data. But I am not sure which one would be best..

AddRange to a Collection

A coworker asked me today how to add a range to a collection. He has a class that inherits from Collection<T>. There's a get-only property of that type that already contains some items. He wants..

Unable to locate tools.jar

Possible Duplicate: Unable to locate tools.jar I'm trying to use ant to compile using this command : ant compile I don't know if the problem comes from my windows 64bit, or by something..

Javascript: best Singleton pattern

Possible Duplicate: Simplest/Cleanest way to implement singleton in JavaScript? I'm using this pattern for singletons, in the example the singleton is PlanetEarth: var NAMESPACE = function..

Need to find a max of three numbers in java

Possible Duplicate: Find the max of 3 numbers in Java with different data types (Basic Java) Write a program that uses a scanner to read three integers (positive) displays the biggest numbe..

How to use __DATE__ and __TIME__ predefined macros in as two integers, then stringify?

Want to use __ DATE __ and __ TIME __ as integer for giving automated version to my code in compile time. #define STRINGIZER(arg) #arg #define STR_VALUE(arg) STRINGIZER(arg) #define DATE_as..

how to execute php code within javascript

<button type="button" id="okButton" onclick="funk()" value="okButton">Order now </button> <script type="text/javascript"> function funk(){ alert("asdasd"); <?p..

How to execute a shell script on a remote server using Ansible?

I am planning to execute a shell script on a remote server using Ansible playbook. blank test.sh file: touch test.sh Playbook: --- - name: Transfer and execute a script. hosts: server user: t..

onchange event on input type=range is not triggering in firefox while dragging

When I played with <input type="range">, Firefox triggers an onchange event only if we drop the slider to a new position where Chrome and others triggers onchange events while the slider is drag..

how to toggle attr() in jquery

I have a simple add attribute function: $(".list-toggle").click(function() { $(".list-sort").attr('colspan', 6); }); My question is: how can I turn this into a toggle, so colspan="6" is removed..

Font is not available to the JVM with Jasper Reports

I'm trying to generate report with DynamicJasper, but I'm getting the following error: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not..

Java default constructor

What exactly is a default constructor — can you tell me which one of the following is a default constructor and what differentiates it from any other constructor? public Module() { this.name = "..

Trim Whitespaces (New Line and Tab space) in a String in Oracle

I need to trim New Line (Chr(13) and Chr(10) and Tab space from the beginning and end of a String) in an Oracle query. I learnt that there is no easy way to trim multiple characters in Oracle. "trim" ..

Javascript: 'window' is not defined

I'm trying to learn JavaScript, but the following code has been giving me a lot of trouble: window.onload = function () { for ( var i = 0; i < seats.length; i++) { for ( var j = 0; j &..

Eclipse: How do you change the highlight color of the currently selected method/expression?

In eclipse, when your cursor is placed on a method (or other things), other places the method exists are highlighted. I'd like to change the color of this highlight, but after scouring the eclipse pre..

How to overwrite styling in Twitter Bootstrap

How can I overwrite the stylings in Twitter Bootstrap? For instance, I am currently using a .sidebar class that has the CSS rule 'float: left;' How can I change this so that it goes to the right ins..

How to execute the start script with Nodemon

How can I execute the start script from a package.json file with Nodemon?..

How to analyze disk usage of a Docker container

I can see that Docker takes 12GB of my filesystem: 2.7G /var/lib/docker/vfs/dir 2.7G /var/lib/docker/vfs 2.8G /var/lib/docker/devicemapper/mnt 6.3G /var/lib/docker/devicemapper/devicemapp..

How to set proxy for wget?

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

How to obtain the location of cacerts of the default java installation?

I am looking on how how to obtain the location of cacerts of the default java installation, when you do not have JAVA_HOME or JRE_HOME defined. I need a solution that works at least for OS X and Linu..

Node Multer unexpected field

I'm working on uploading a file to my app using the multer npm module. The multer function I have defined is to allow a single file uploaded to the file system. Everything works during run time; the..

Facebook share button and custom text

Is there any way to make facebook share button which post custom text on the wall or news feed?..

Get key and value of object in JavaScript?

Given a JavaScript array of objects, how can I get the key and value of each object? The code below shows what I'd like to do, but obviously doesn't work: var top_brands = [ { 'Adidas' : 100 }, { 'N..

Use of Custom Data Types in VBA

I am trying to create a custom data type in VBA for Excel. Let's call this data type "truck". Each truck has the following attributes: NumberOfAxles (this is an integer) AxleWeights (this is an array..

JQuery ajax call default timeout value

I got a bug report that I can't duplicate, but ajax-call timeout is the current best guess. So I'm trying to find out the default value for timeout of a jQuery $.ajax() call. Anybody have an idea? C..

Setting the default page for ASP.NET (Visual Studio) server configuration

When I build and run my application I get a directory listing in the browser (also happens for sub folders), and I have to click on Index.aspx. It's making me crazy. Visual Studio 2008 ASP.NET Devel..

java.io.IOException: Invalid Keystore format

Does anyone know how to solve this? I tried many things, but none of them worked. And when I click more details I get this: at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source) atsun.sec..

Facebook key hash does not match any stored key hashes

I'm really having troubles with the Facebook hash key. I generated it in my Eclipse.. proof: Then I went to https://developers.facebook.com/ and registered a new app. And finally I've set my hash..

How to disable XDebug

I think that my server became slow since I installed XDebug. So, in order to test my hypothesis I want to disable XDebug completely. I've been searching for tutorials on how to do this but I can't fin..

How can I save multiple documents concurrently in Mongoose/Node.js?

At the moment I use save to add a single document. Suppose I have an array of documents that I wish to store as single objects. Is there a way of adding them all with a single function call and then..

How do you display a Toast from a background thread on Android?

How can I display Toast messages from a thread? ..

Can you use a trailing comma in a JSON object?

When manually generating a JSON object or array, it's often easier to leave a trailing comma on the last item in the object or array. For example, code to output from an array of strings might look l..

How to create an HTML button that acts like a link?

I would like to create an HTML button that acts like a link. So, when you click the button, it redirects to a page. I would like it to be as accessible as possible. I would also like it so there aren..

Returning first x items from array

I want to return first 5 items from array. How can I do this?..

How can I put the current running linux process in background?

I have a command that uploads files using git to a remote server from the Linux shell and it will take many hours to finish. How can I put that running program in background? So that I can still wor..

pip install gives error: Unable to find vcvarsall.bat

Using pip install zipline on Windows 8 with Python 2.7 gives me the error: Downloading/unpacking six (from python-dateutil==2.1->delorean->zipline[all]) Running setup.py egg_info for package ..

Entity Framework VS LINQ to SQL VS ADO.NET with stored procedures?

How would you rate each of them in terms of: Performance Speed of development Neat, intuitive, maintainable code Flexibility Overall I like my SQL and so have always been a die-hard fan of ADO.NET..