Questions Tagged with #Setwindowlong

How to get milliseconds from LocalDateTime in Java 8

I am wondering if there is a way to get current milliseconds since 1-1-1970 (epoch) using the new LocalDate, LocalTime or LocalDateTime classes of Java 8. The known way is below: long currentMilli..

MAX function in where clause mysql

How can I use max() function in where clause of a mysql query, I am trying: select firstName,Lastname,MAX(id) as max where id=max; this is giving me an error: Unknown column 'max' in 'where claus..

Scatter plot and Color mapping in Python

I have a range of points x and y stored in numpy arrays. Those represent x(t) and y(t) where t=0...T-1 I am plotting a scatter plot using import matplotlib.pyplot as plt plt.scatter(x,y) plt.show()..

How do you stop MySQL on a Mac OS install?

I installed MySQL via MacPorts. What is the command I need to stop the server (I need to test how my application behave when MySQL is dead)?..

How to extract text from a PDF file?

I'm trying to extract the text included in this PDF file using Python. I'm using the PyPDF2 module, and have the following script: import PyPDF2 pdf_file = open('sample.pdf') read_pdf = PyPDF2.PdfFi..

not finding android sdk (Unity)

Error: Invalid command android UnityEditor.HostView:OnGUI() CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more d..

A default document is not configured for the requested URL, and directory browsing is not enabled on the server

I have just deployed my asp.net mvc-2 website to a server (using dotnetpanel). But getting this error A default document is not configured for the requested URL, and directory browsing is not enabled..

View JSON file in Browser

It is not a programming question, but need your views in few words. When we hit the JSON url in Broswer, it asks us to save the file. Why this happens ? Is there any way to view it on the page its..

API pagination best practices

I'd love some some help handling a strange edge case with a paginated API I'm building. Like many APIs, this one paginates large results. If you query /foos, you'll get 100 results (i.e. foo #1-100),..

How can I get a favicon to show up in my django app?

I just want to drop the favicon.ico in my staticfiles directory and then have it show up in my app. How can I accomplish this? I have placed the favicon.ico file in my staticfiles directory, but it ..

How to remove a package in sublime text 2

I would like to remove and/or deactivate the Emmet package in Sublime Text 2. Should I just remove the Emmet directory or what is the typical workflow for removal of a package?..

Change Orientation of Bluestack : portrait/landscape mode

if using the emulator, press CTRL-F12 we will change portrait or landscape mode . How can i do this with BlueStack ?..

How do I make a text go onto the next line if it overflows?

I tried word-wrap: break-word;, but it separates lines mid word...

Is it possible to disable the network in iOS Simulator?

I am trying to debug some inconsistent behaviour I am seeing in an application that gets its primary data from the internet. I don't see the issues in the simulator, just on the device, so I'd like t..

Why would I use dirname(__FILE__) in an include or include_once statement?

I have seen this: <?php include( dirname(__FILE__) . DIRECTORY_SEPARATOR . 'my_file.php'); ?> Why would I ever need to do this? Why would I go to the trouble of getting the dirname and the..

addEventListener in Internet Explorer

What is the equivalent to the Element Object in Internet Explorer 9? if (!Element.prototype.addEventListener) { Element.prototype.addEventListener = function() { .. } } How does it works in I..

tell pip to install the dependencies of packages listed in a requirement file

Developing a Django web app, I have a list of packages I need to install in a virtualenv. Say: Django==1.3.1 --extra-index-url=http://dist.pinaxproject.com/dev/ Pinax==0.9b1.dev10 git+git://github.c..

How to insert element into arrays at specific position?

Let's imagine that we have two arrays: $array_1 = array( '0' => 'zero', '1' => 'one', '2' => 'two', '3' => 'three', ); $array_2 = array( 'zero' => '0', 'one' => '1',..

How to push a single file in a subdirectory to Github (not master)

I have changed a single file in a subdirectory of my repository and I want to push just that file to Github. I've made a small change to one file, and I don't want to re-upload the entire repositor..

How to generate a random number in C++?

I'm trying to make a game with dice, and I need to have random numbers in it (to simulate the sides of the die. I know how to make it between 1 and 6). Using #include <cstdlib> #include <..

Globally catch exceptions in a WPF application?

We are having a WPF application where parts of it may throw exceptions at runtime. I'd like to globally catch any unhandled exception and log them, but otherwise continue program execution as if nothi..

How to specify a editor to open crontab file? "export EDITOR=vi" does not work

I'm using Red Hat Enterprise Linux 5, and I want to set the vim editor to edit the crontab file. If I run echo $EDITOR, I get vim. But when I run crontab -e, I get different editor...

Running Node.Js on Android

So I know this has been questioned quite a lot. To be exact for example in these questions: Run NodeJs server in Android How to run my node.js project on android? and NodeJS on IOS/Android ..

How to find a value in an excel column by vba code Cells.Find

I have to find a value celda in an Excel sheet. I was using this vba code to find it: Set cell = Cells.Find(What:=celda, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlWhole, SearchOrder:=xl..

Is it possible to style html5 audio tag?

I haven't found any resources on how to do that. Something as simple as changing the color of the player would be nice to have :)..

How do I bind onchange event of a TextBox using JQuery?

How can I bind an OnChange event of a TextBox to function using jQuery? Am trying this and its failing: $(document).ready(function() { $("input#tags").bind("change",autoFill); }); function auto..

Regex Explanation ^.*$

When I use this code: 'DTH' + @fileDate + '^.*$' I get DTH201510080900.xlsx What does ^.*$ do? Does that give me the 0900 time?..

How to get all table names from a database?

I'd like to retrieve all table names from a database schema, and, if possible, get all table starting with a specified prefix. I tried using JDBC's connection.getMetaData().getTables() but it didn't..

How do I get SUM function in MySQL to return '0' if no values are found?

Say I have a simple function in MySQL: SELECT SUM(Column_1) FROM Table WHERE Column_2 = 'Test' If no entries in Column_2 contain the text 'Test' then this function returns NULL, while I would like ..

Which mime type should I use for mp3

I'm trying to decide which mime type to choose for returning mp3 data (served up by php) according to this listing of mime types: http://www.webmaster-toolkit.com/mime-types.shtml .mp3 audio/mpeg..

std::cin input with spaces?

#include <string> std::string input; std::cin >> input; The user wants to enter "Hello World". But cin fails at the space between the two words. How can I make cin take in the whole of ..

Copy table without copying data

CREATE TABLE foo SELECT * FROM bar copies the table foo and duplicates it as a new table called bar. How can I copy the schema of foo to a new table called bar without copying over the data as well..

What should I do if the current ASP.NET session is null?

In my web application, I do something like this to read the session variables: if (HttpContext.Current.Session != null && HttpContext.Current.Session["MyVariable"] != null) { string myVa..

Check if a path represents a file or a folder

I need a valid method to check if a String represents a path for file or a directory. What are valid directory names in Android? As it comes out, folder names can contain '.' chars, so how does system..

Task not serializable: java.io.NotSerializableException when calling function outside closure only on classes not objects

Getting strange behavior when calling function outside of a closure: when function is in a object everything is working when function is in a class get : Task not serializable: java.io.NotSeri..

How can I remove Nan from list Python/NumPy

I have a list that countain values, one of the values I got is 'nan' countries= [nan, 'USA', 'UK', 'France'] I tried to remove it, but I everytime get an error cleanedList = [x for x in countries..

Create a new TextView programmatically then display it below another TextView

String[] textArray={"one","two","asdasasdf asdf dsdaa"}; int length=textArray.length; RelativeLayout layout = new RelativeLayout(this); RelativeLayout.LayoutParams relativeParams = new RelativeLayout...

Open Google Chrome from VBA/Excel

I'm trying to open a Chrome browser from VBA. I understand Chrome does not support ActiveX settings so I'm curious if theres any work-arounds? Dim ie As Object Set ie = CreateObject("ChromeTab.Chrom..

How do I start/stop IIS Express Server?

I have installed MS Visual Web Developer 2010 which includes IIS Express. Before this, I had installed XAMPP server for my php applications. I would like to know how can I stop IIS in order to be ab..

How do you configure tomcat to bind to a single ip address (localhost) instead of all addresses?

How do you configure tomcat to bind to a single ip address (localhost) instead of all addresses?..

Nodejs - Redirect url

How do I get a node.js server to redirect users to a 404.html page when they enter an invalid url? I did some searching, and it looks like most results are for Express, but I want to write my server ..

onKeyPress Vs. onKeyUp and onKeyDown

What is the difference between these three events? Upon googling I found that: The onKeyDown event is triggered when the user presses a key. The onKeyUp event is triggered when the user relea..

How to overcome the CORS issue in ReactJS

I am trying to make an API call through Axios in my React Application.However, Iam getting this CORS issue on my browser. I am wondering if i can resolve this issue from a client side as i donot have ..

Swift - Integer conversion to Hours/Minutes/Seconds

I have a (somewhat?) basic question regarding time conversions in Swift. I have an integer that I would like converted into Hours / Minutes / Seconds. Example: Int = 27005 would give me: 7 Hours 3..

Add/remove class with jquery based on vertical scroll?

So basically I'd like to remove the class from 'header' after the user scrolls down a little and add another class to change it's look. Trying to figure out the simplest way of doing this but I can't..

PHP Warning: include_once() Failed opening '' for inclusion (include_path='.;C:\xampp\php\PEAR')

I know this error is very common, I've tried to search google, I did the tricks to no avail. So my setup is, I have 3 directories: CLASSES->constants PAGES INITCONTROLS EDIT: I've got new erro..

How does strtok() split the string into tokens in C?

Please explain to me the working of strtok() function. The manual says it breaks the string into tokens. I am unable to understand from the manual what it actually does. I added watches on str and *p..

Can an Android NFC phone act as an NFC tag?

From what I have understood so far, an NFC phone will act as an NFC reader which will read data from an NFC tag. Now my question is, can we switch this around? Can we make an Android NFC phone behave ..

How can I use grep to show just filenames on Linux?

How can I use grep to show just file-names (no in-line matches) on Linux? I am usually using something like: find . -iname "*php" -exec grep -H myString {} \; How can I just get the file-names (wi..

Copy file or directories recursively in Python

Python seems to have functions for copying files (e.g. shutil.copy) and functions for copying directories (e.g. shutil.copytree) but I haven't found any function that handles both. Sure, it's trivial ..

How to create a secure random AES key in Java?

What is the recommended way of generating a secure, random AES key in Java, using the standard JDK? In other posts, I have found this, but using a SecretKeyFactory might be a better idea: KeyGenerat..

ERROR 1067 (42000): Invalid default value for 'created_at'

When I tried to alter the table it showed the error: ERROR 1067 (42000): Invalid default value for 'created_at' I googled for this error but all I found was as if they tried to alter the timestamp ..

How to create a pivot query in sql server without aggregate function

I am using MS SQL SERVER 2008 and I have following data: select * from account; | PERIOD | ACCOUNT | VALUE | ---------------------------- | 2000 | Asset | 205 | | 2000 | Equity | 365 | |..

How to write to a file without overwriting current contents?

with open("games.txt", "w") as text_file: print(driver.current_url) text_file.write(driver.current_url + "\n") I'm using this code right now, but when it writes to the file it overwrites the..

(Mac) -bash: __git_ps1: command not found

I'm trying to change my command promt in terminal. I keep getting the error: -bash: __git_ps1: command not found I've tried it just by typing it into the terminal as is: __git_ps1. I've also tried i..

How to include view/partial specific styling in AngularJS

What is the proper/accepted way to use separate stylesheets for the various views my application uses? Currently I'm placing a link element in the view/partial's html at the top but I've been told th..

Is there a command to undo git init?

I just Git init'ed a repos with a wrong user, and want to undo it. Is there any command for this? Do I actually have to go in and edit the .git directory?..

Sorting a Dictionary in place with respect to keys

I have a dictionary in C# like Dictionary<Person, int> and I want to sort that dictionary in place with respect to keys (a field in class Person). How can I do it? Every available help on the..

How to generate random positive and negative numbers in Java

I am trying to generate random integers over the range (-32768, 32767) of the primitive data type short. The java Random object only generates positive numbers. How would I go about randomly creating ..

How can I confirm a database is Oracle & what version it is using SQL?

I'm building an installer for an application. The user gets to select a datasource they have configured and nominate what type of database it is. I want to confirm that the database type is indeed Or..

How to resolve a Java Rounding Double issue

Seems like the subtraction is triggering some kind of issue and the resulting value is wrong. double tempCommission = targetPremium.doubleValue()*rate.doubleValue()/100d; 78.75 = 787.5 * 10.0/100d ..

How to wait 5 seconds with jQuery?

I'm trying to create an effect where the page loads, and after 5 seconds, the success message on the screen fades out, or slides up. How can I achieve this?..

JQuery find first parent element with specific class prefix

I want to get the first parent which has a specific class prefix, suppose: <div class="div-a3332"> <div class="div-a89892"> <p> <div class="div-b2"> <d..

Regex match one of two words

I have an input that can have only 2 values apple or banana. What regular expression can I use to ensure that either of the two words was submitted?..

How to debug ORA-01775: looping chain of synonyms?

I'm familiar with the issue behind ORA-01775: looping chain of synonyms, but is there any trick to debugging it, or do I just have to "create or replace" my way out of it? Is there a way to query t..

How to debug stored procedures with print statements?

I am trying to debug stored procedures in SQL Server Management Studio 2008. I want to insert some print statements to test some IF-statements that I know are wrong. In order to do debugging, I tried..

Why so red? IntelliJ seems to think every declaration/method cannot be found/resolved

I just installed and re-installed IntelliJ. Every Java file is coming up RED. I checked the JDK; it is at 1.6.##. The maven clean install build worked just fine. I'm getting the usual highlighted err..

Multi-dimensional arrays in Bash

I am planning a script to manage some pieces of my Linux systems and am at the point of deciding if I want to use bash or python. I would prefer to do this as a Bash script simply because the command..

Accessing localhost of PC from USB connected Android mobile device

I have an android device (Samsung galaxy tab) connected to my PC via USB . I want to use WebServices and run a web page which is located on my local xampp server of my PC on my android device . I ca..

Unable to begin a distributed transaction

I'm trying to run SQL against a linked server, but I get the errors below : BEGIN DISTRIBUTED TRANSACTION SELECT TOP 1 * FROM Sessions OLE DB provider "SQLNCLI" for linked server "ASI..

How to delete images from a private docker registry?

I run a private docker registry, and I want to delete all images but the latest from a repository. I don't want to delete the entire repository, just some of the images inside it. The API docs don't m..

Python Requests package: Handling xml response

I like very much the requests package and its comfortable way to handle JSON responses. Unfortunately, I did not understand if I can also process XML responses. Has anybody experience how to handle ..

how to remove only one style property with jquery

I have a div with this property style="-moz-user-select:none; position:static !important;". I need to remove the -moz-user-select Tried with $(selector).css() but I don't know what value to set becaus..

How can one print a size_t variable portably using the printf family?

I have a variable of type size_t, and I want to print it using printf(). What format specifier do I use to print it portably? In 32-bit machine, %u seems right. I compiled with g++ -g -W -Wall -Werr..

Inserting a blank table row with a smaller height

I have a table consisting of a header row and a couple of data rows. What I want to do is to create a blank row in between the header and the data rows, but I want this blank row to be smaller in heig..

Jquery function BEFORE form submission

I am trying to fire a function using Jquery when the form submit button is clicked, but the function needs to fire BEFORE the form is actually submitted. I am trying to copy some div tag attributes in..

Object variable or With block variable not set (Error 91)

I have the following code: Sub AddSources() Dim pubPage As Page Dim pubShape As Shape Dim hprlink As Hyperlink Dim origAddress() As String Dim exportFileName As String exportF..

Blocks and yields in Ruby

I am trying to understand blocks and yield and how they work in Ruby. How is yield used? Many of the Rails applications I've looked at use yield in a weird way. Can someone explain to me or show me ..

How to get a jqGrid cell value when editing

How to get a jqGrid cell value when in-line editing (getcell and getRowData returns the cell content and not the actuall value of the input element)...

Server cannot set status after HTTP headers have been sent IIS7.5

Sometimes I get exception in my production environment: Process information Process ID: 3832 Process name: w3wp.exe Account name: NT AUTHORITY\NETWORK SERVICE Exception i..

Android studio logcat nothing to show

I installed Android Studio yesterday, and I tried to use the LogCat to see the logs. But there is nothing to show in the logcat. I used the terminal to run ./adb logcat and it works. Is there someo..

Why is 1/1/1970 the "epoch time"?

Why is 1 January 1970 00:00:00 considered the epoch time?..

How to split a string into a list?

I want my Python function to split a sentence (input) and store each word in a list. My current code splits the sentence, but does not store the words as a list. How do I do that? def split_line(text..

Calculate a MD5 hash from a string

I use the following C# code to calculate a MD5 hash from a string. It works well and generates a 32-character hex string like this: 900150983cd24fb0d6963f7d28e17f72 string sSourceData; byte[] tmpSour..

How to set response header in JAX-RS so that user sees download popup for Excel?

I wrote code that generate Excel file using REST JAX-RS and I confirmed that the generated Excel file is in GlassFish server directory. But my goal is when user click on the button (which generate Ex..

How to create a directory in Java?

How do I create Directory/folder? Once I have tested System.getProperty("user.home"); I have to create a directory (directory name "new folder" ) if and only if new folder does not exist...

How do you convert a C++ string to an int?

Possible Duplicate: How to parse a string to an int in C++? How do you convert a C++ string to an int? Assume you are expecting the string to have actual numbers in it ("1", "345", "38944"..

linq query to return distinct field values from a list of objects

class obj { int typeId; //10 types 0-9 string uniqueString; //this is unique } Assume there is list with 100 elements of obj, but only 10 unique typeIDs. Is it possible to do write a LINQ q..

How do you get a list of the names of all files present in a directory in Node.js?

I'm trying to get a list of the names of all the files present in a directory using Node.js. I want output that is an array of filenames. How can I do this?..

J2ME/Android/BlackBerry - driving directions, route between two locations

On Android 1.0 there was a com.google.googlenav namespace for driving directions: Route - Improved Google Driving Directions But in newer SDK it was removed by some reason... Android: DrivingDirection..

How to pass a Javascript Array via JQuery Post so that all its contents are accessible via the PHP $_POST array?

How can I pass a Javascript Array via JQuery Post so that all its contents are accessible via the PHP $_POST array? Please show an example of code that would do the trick. Thanks!..

Why does AngularJS include an empty option in select?

I've been working with AngularJS for the last few weeks, and the one thing which is really bothering me is that even after trying all permutations or the configuration defined in the specification at ..

java.lang.RuntimeException: Unable to start activity ComponentInfo

I know this error appeared on forum million of times, but please help me find what I missed. I'm trying to do simple tab orientated application,I don't have much (except errors) 1) my main activity i..

converting epoch time with milliseconds to datetime

I have used a ruby script to convert iso time stamp to epoch, the files that I am parsing has following time stamp structure: 2009-03-08T00:27:31.807 Since I want to keep milliseconds I used follo..

ArithmeticException: "Non-terminating decimal expansion; no exact representable decimal result"

Why does the following code raise the exception shown below? BigDecimal a = new BigDecimal("1.6"); BigDecimal b = new BigDecimal("9.2"); a.divide(b) // results in the following exception. Exception..

jQuery: load txt file and insert into div

I want to load a *.txt file and insert the content into a div. Here my code: js: $(document).ready(function() { $("#lesen").click(function() { $.ajax({ url : "helloworld.txt"..

How do you make strings "XML safe"?

I am responding to an AJAX call by sending it an XML document through PHP echos. In order to form this XML document, I loop through the records of a database. The problem is that the database includ..

Error:attempt to apply non-function

I'm trying to run the following code in R, but I'm getting an error. I'm not sure what part of the formula is incorrect. Any help would be greatly appreciated. > censusdata_20$AGB93 = WD * exp(-1..

Deserialize JSON with C#

I'm trying to deserialize a Facebook friend's Graph API call into a list of objects. The JSON object looks like: {"data":[{"id":"518523721","name":"ftyft"}, {"id":"527032438","name":"ftyfty..

Mean filter for smoothing images in Matlab

I need to test some basic image processing techniques in Matlab. I need to test and compare especially two types of filters: mean filter and median filter. To smooth image using median filtering, the..

Excel VBA For Each Worksheet Loop

I am working on code to basically go through each sheet in my Workbook, and then update column widths. Below is the code I wrote; I don't receive any errors, but it also doesn't actually do anything. ..

There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'xxx'

There are a couple of posts about this on Stack Overflow but none with an answer that seem to fix the problem in my current situation. I have a page with a table in it, each row has a number of text ..

how to set auto increment column with sql developer

How do I set a column to increment automatically with Oracle SQL Developer? Why is the form disabled? Note: The image shows the Data Modeler, but the question and top answer talk about editing an e..

How do you make an element "flash" in jQuery

I'm brand new to jQuery and have some experience using Prototype. In Prototype, there is a method to "flash" an element — ie. briefly highlight it in another color and have it fade back to norma..

When should I use Write-Error vs. Throw? Terminating vs. non-terminating errors

Looking at a Get-WebFile script over on PoshCode, http://poshcode.org/3226, I noticed this strange-to-me contraption: $URL_Format_Error = [string]"..." Write-Error $URL_Format_Error return What is ..

Using helpers in model: how do I include helper dependencies?

I'm writing a model that handles user input from a text area. Following the advice from http://blog.caboo.se/articles/2008/8/25/sanitize-your-users-html-input, I'm cleaning up the input in the model ..

WHERE IS NULL, IS NOT NULL or NO WHERE clause depending on SQL Server parameter value

I have a stored procedure in SQL Server 2000 that performs a search based on parameter values. For one of the parameters passed in, I need a different WHERE clause depending on its value - the problem..

Stop Chrome Caching My JS Files

I will make a change to my JS files but it won't really change in the browser, I have to rename the files every time so that it reloads it. Is there some sort of .htaccess command I can add or somethi..

How to export a mysql database using Command Prompt?

I have a database that is quite large so I want to export it using Command Prompt but I don't know how to. I am using WAMP...

How to pass payload via JSON file for curl?

I can successfully create a place via curl executing the following command: $ curl -vX POST https://server/api/v1/places.json -d " auth_token=B8dsbz4HExMskqUa6Qhn& \ place[name]=Fuelstation C..

How to programmatically turn off WiFi on Android device?

I need to turn off the WiFi a while after pressing the "Turn off the Screen" button. There is a need for this app for my tablet because sometimes I just forget to turn off the WiFi and this discharges..

Import regular CSS file in SCSS file?

Is there anyway to import a regular CSS file with Sass's @import command? While I'm not using all of the SCSS syntax from sass, I do still enjoy it's combining/compressing features, and would like to ..

ImportError: No module named model_selection

I am trying to use train_test_split function and write: from sklearn.model_selection import train_test_split and this causes ImportError: No module named model_selection Why? And how to overcom..

Swift's guard keyword

Swift 2 introduced the guard keyword, which could be used to ensure that various data is configured ready to go. An example I saw on this website demonstrates an submitTapped function: func submitTap..

How to check if a variable is an integer or a string?

I have an application that has a couple of commands. When you type a certain command, you have to type in additional info about something/someone. Now that info has to be strictly an integer or a stri..

PHP how to get the base domain/url?

function url(){ if(isset($_SERVER['HTTPS'])){ $protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http"; } else{ $protocol = 'http'; } ..

SQL Server CTE and recursion example

I never use CTE with recursion. I was just reading an article on it. This article shows employee info with the help of Sql server CTE and recursion. It is basically showing employees and their manager..

How to define two angular apps / modules in one page?

I'm trying to add two angular apps / modules to one page. In the fiddles below you can see that always only the first module, referenced in the html code, will work correctly, whereas the second is no..

how to run vibrate continuously in iphone?

In my application I'm using following coding pattern to vibrate my iPhone device Include: AudioToolbox framework Header File: #import "AudioToolbox/AudioServices.h" Code: AudioServicesPlaySystem..

What is a Y-combinator?

A Y-combinator is a computer science concept from the “functional” side of things. Most programmers don't know much at all about combinators, if they've even heard about them. What is a ..

How does one target IE7 and IE8 with valid CSS?

I want to target IE7 and IE8 with W3C-compliant CSS. Sometimes fixing CSS for one version does not fix for the other. How can I achieve this?..

Character reading from file in Python

In a text file, there is a string "I don't like this". However, when I read it into a string, it becomes "I don\xe2\x80\x98t like this". I understand that \u2018 is the unicode representation of "'"...

Use and meaning of "in" in an if statement?

In an example from Zed Shaw's Learn Python the Hard Way, one of the exercises displays the following code: next = raw_input("> ") if "0" in next or "1" in next: how_much = int(next) I'm havi..

str.startswith with a list of strings to test for

I'm trying to avoid using so many if statements and comparisons and simply use a list, but not sure how to use it with str.startswith: if link.lower().startswith("js/") or link.lower().startswith("ca..

Checking on a thread / remove from list

I have a thread which extends Thread. The code looks a little like this; class MyThread(Thread): def run(self): # Do stuff my_threads = [] while has_jobs() and len(my_threads) < 5: ..

Getting Integer value from a String using javascript/jquery

These are the strings I have: "test123.00" "yes50.00" I want to add the 123.00 with 50.00. How can I do this? I used the command parseInt() but it displays NaN error in alert box. This is the co..

import error: 'No module named' *does* exist

I am getting this stack trace when I start pyramid pserve: % python $(which pserve) ../etc/development.ini Traceback (most recent call last): File "/home/hughdbrown/.local/bin/pserve", line 9, in &..

Smooth scroll to specific div on click

What I'm trying to do is make it so that if you click on a button, it scrolls down (smoothly) to a specific div on the page. What I need is if you click on the button, it smooth scrolls to the div 's..

how to make password textbox value visible when hover an icon

Good day all, I have a form that has a password field: <input type="password" name="password" size="30" /> Naturally, the input text will be replaced by (*). So if the user typed 123 the bo..

Git Bash won't run my python files?

I have been trying to run my python files in Git Bash but I keep getting an error and can't figure out how to fix it. My command as follows in the git bash executable python filename.py then it says ..

Escaping single quotes in JavaScript string for JavaScript evaluation

I have a project, in which some JavaScript var is evaluated. Because the string needs to be escaped (single quotes only), I have written the exact same code in a test function. I have the following bi..

Generate JSON string from NSDictionary in iOS

I have a dictionary I need to generate a JSON string by using dictionary. Is it possible to convert it? Can you guys please help on this?..

Convert dateTime to ISO format yyyy-mm-dd hh:mm:ss in C#

Is there a standard way in .NET/C# to convert a datetime object to ISO 8601 format yyyy-mm-dd hh:mm:ss? Or do I need to do some string manipulation to get the date string?..

submit form on click event using jquery

So can someone please tell why neither of these options will actually submit the form? I am trying to do something more complicated but I have boiled it down to this to try and figure out why I can't..

C# Creating and using Functions

I need help with C# programming; I am new to it and I come from C background. I have a Console Application like this: using System; using System.Collections.Generic; using System.Linq; using System...

How can I install the Beautiful Soup module on the Mac?

I read this without finding the solution: http://docs.python.org/install/index.html..

Android Studio: Can't start Git

When I start Android Studio there's a message Can't start Git: C:\Program Files (x86)\Git\cmd\git.cmd Probably the path to Git executable is not valid. Fix it. But I can see that the git.cmd I..

ImportError: No module named six

I'm trying to build OpenERP project, done with dependencies. It's giving this error now Traceback (most recent call last): File "openerp-client.py", line 105, in <module> File "modules\__in..

MVC 4 Razor adding input type date

I'm wondering how to insert a <input type="date"/> for datetime attributes of my model. As for now Razor creates a plain input element with type="datetime". I want to make use of the new input ..

"The specified Android SDK Build Tools version (26.0.0) is ignored..."

In Android Studio 3, I'm seeing this issue: The specified Android SDK Build Tools version (26.0.0) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3..

Action bar navigation modes are deprecated in Android L

Taking a look at the API diff report for the Android "L" preview, I see that all methods related to navigation modes in the ActionBar class (such as setNavigationMode(), addTab(), selectTab(), &c)..

How to set selected item of Spinner by value, not by position?

I have a update view, where I need to preselect the value stored in database for a Spinner. I was having in mind something like this, but the Adapter has no indexOf method, so I am stuck. void setSp..

Set a:hover based on class

I have the following HTML: <div class="menu"> <a class="main-nav-item" href="home">home</a> <a class="main-nav-item-current" href="business">business</a> <..

What's the difference between 'git merge' and 'git rebase'?

What's the difference between git merge and git rebase?..

How to check the version of scipy

How can I check the version of scipy installed on my system?..

How to find out which JavaScript events fired?

I have a select list: <select id="filter"> <option value="Open" selected="selected">Open</option> <option value="Closed">Closed</option> </select> When I sel..

OWIN Startup Class Missing

I'm getting this error as my project is not able to find the reference for OWIN startup class. I've even installed all the OWIN reference packages through Nuget still getting the same issue. I'm using..

First Heroku deploy failed `error code=H10`

I deployed my app to Heroku. It's a node.js + express + socket.io app and this is the package.json file { "name": "game_test", "author": "Ilya", "description": "A test app for our board game", ..

Getting "type or namespace name could not be found" but everything seems ok?

I'm getting a: type or namespace name could not be found error for a C# WPF app in VS2010. This area of code was compiling fine, but suddenly I'm getting this error. I've tried removing the Proj..

How do I check for a network connection?

What is the best way to determine if there is a network connection available?..

Why are empty catch blocks a bad idea?

I've just seen a question on try-catch, which people (including Jon Skeet) say empty catch blocks are a really bad idea? Why this? Is there no situation where an empty catch is not a wrong design deci..

"pip install json" fails on Ubuntu

Cannot install the json module. As far as I know I shouldn't use sudo. what's the matter? pip install json The directory '/home/snow/.cache/pip/http' or its parent directory is not owned by the curr..

How to get current date & time in MySQL?

Is there a value or command like DATETIME that I can use in a manual query to insert the current date and time? INSERT INTO servers ( server_name, online_status, exchange, disk_space, network_shar..

Getting Chrome to accept self-signed localhost certificate

I have created a self-signed SSL certificate for the localhost CN. Firefox accepts this certificate after initially complaining about it, as expected. Chrome and IE, however, refuse to accept it, even..

Rounded Corners Image in Flutter

I am using Flutter to make a list of information about movies. Now I want the cover image on the left to be a rounded corners picture. I did the following, but it didn’t work. Thanks! getItem(v..

How can I import a database with MySQL from terminal?

How can I import a database with mysql from terminal? I cannot find the exact syntax...

Get current date/time in seconds

How do I get the current date/time in seconds in Javascript?..

AngularJS: Can't I set a variable value on ng-click?

I have a modal that uses ng-show="prefs" to determine visibility. My desire is to use the close button in the modal to set $scope.prefs to false and to use an anchor tag to set the value to true. How..

Laravel 5.1 - Checking a Database Connection

I am trying to check if a database is connected in Laravel. I've looked around the documentation and can't find anything. The closest thing I've found is this, but this doesn't solve my problem. I h..

Can an ASP.NET MVC controller return an Image?

Can I create a Controller that simply returns an image asset? I would like to route this logic through a controller, whenever a URL such as the following is requested: www.mywebsite.com/resource/ima..

How to tell if a <script> tag failed to load

I'm dynamically adding <script> tags to a page's <head>, and I'd like to be able to tell whether the loading failed in some way -- a 404, a script error in the loaded script, whatever. In..

How to convert this var string to URL in Swift

I need url filepath be a URL (NSURL in old versions of Swift). I have this: let paths = NSSearchPathForDirectoriesInDomains( .documentDirectory, .userDomainMask, true) // NSString *documents..

How do I perform an IF...THEN in an SQL SELECT?

How do I perform an IF...THEN in an SQL SELECT statement? For example: SELECT IF(Obsolete = 'N' OR InStock = 'Y' ? 1 : 0) AS Saleable, * FROM Product ..

Using a scanner to accept String input and storing in a String Array

Can someone help me please. I have done numerous searches but can't find a solution anywhere. I'm a beginner to Java and currently practicing some code while on a break from college. I am trying to..

How to truncate text in Angular2?

Is there a way that I could limit the length of the string to a number characters? for e.g: I have to limit a title length to 20 {{ data.title }}. Is there any pipe or filter to limit the length?..

how to remove css property using javascript?

is it possible to remove a CSS property of an element using JavaScript ? e.g. I have div.style.zoom = 1.2, now i want to remove the zoom property through JavaScript ?..

How to remove multiple deleted files in Git repository

I have deleted some files and git status shows as below. I have committed and pushed. GitHub still shows the deleted files in the repository. How can I delete files in the GitHub repository? # On ..

AcquireConnection method call to the connection manager <Excel Connection Manager> failed with error code 0xC0202009

I have an SSIS package which reads an Excel File (Data Flow Source) and transfer the data to SQL Server using OLEDB Destination Data Flow Item. The OLEDB Connection Manager used for the destination is..

How can I force a hard reload in Chrome for Android

In Chrome for desktop I have options in the dev tools to disable cache completely when dev tools are opened and I have the options to manually do a hard reload when long clicking on the reload button ..

How to let PHP to create subdomain automatically for each user?

How do I create subdomain like http://user.mywebsite.com ? Do i have to access htaccess somehow? Is it actually simply possible to create it via pure php code or I need to use some external script-ser..

Remove object from a list of objects in python

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

How to "wait" a Thread in Android

private void startGameTimeElapseThread(){ new Thread(new Runnable() { Date d = new Date(); public void run() { while (gameOn){ Log.d(TAG,""+d.getTime()+..

How do I calculate r-squared using Python and Numpy?

I'm using Python and Numpy to calculate a best fit polynomial of arbitrary degree. I pass a list of x values, y values, and the degree of the polynomial I want to fit (linear, quadratic, etc.). This..

Execute php file from another php

I want to call a PHP file that starts like <?php function connection () { //Statements } I call from the PHP like this: <?php exec ('/opt/lampp/htdocs/stuff/name.php'); ?> I get: l..

Correct way of getting Client's IP Addresses from http.Request

What's the correct way to get all client's IP Addresses from http.Request? In PHP there are a lot of variables that I should check. Is it the same on Go? One that I found is: req.RemoteAddr And i..

GIT commit as different user without email / or only email

I'm trying to commit some changes as a different user, but i do not have a valid email address, following command is not working for me: git commit --author="john doe" -m "some fix" fatal: No existin..

Loading another html page from javascript

Is it possible to load a Javascript program from an html page and then make the Javascript load another html page instead of the page the loaded the program?..

printf() prints whole array

Let's assume I have the following code in my C program: #include <stdio.h> void PrintSomeMessage( char *p ); int main(int argc, char *argv[]) { char arr[10] = "hello"; PrintSomeMessa..

Implementing autocomplete

I am having trouble finding a good autocomplete component for Angular2. Just anything that I can pass a list of key-label objects to and have a nice autocomplete on an input field. Kendo does not sup..

How to convert signed to unsigned integer in python

Let's say I have this number i = -6884376. How do I refer to it as to an unsigned variable? Something like (unsigned long)i in C...

How do I create a readable diff of two spreadsheets using git diff?

We have a lot of spreadsheets (xls) in our source code repository. These are usually edited with gnumeric or openoffice.org, and are mostly used to populate databases for unit testing with dbUnit. T..

What is .Net Framework 4 extended?

For testing purposes, I installed .Net Framework 4 Client Profile. My tests ended and I was to uninstall it, in order to install .Net Framework 4 full. The uninstaller told me to uninstall .Net Frame..

What exactly does a jar file contain?

As an intern, I use company code in my projects and they usually send me a jar file to work with. I add it to the build path in Eclipse and usually all is fine and dandy. However, I got curious to kn..

How do I kill a process using Vb.NET or C#?

I have a scenario where I have to check whether user has already opened Microsoft Word. If he has, then I have to kill the winword.exe process and continue to execute my code. Does any one have any..

How to persist a property of type List<String> in JPA?

What is the smartest way to get an entity with a field of type List persisted? Command.java package persistlistofstring; import java.io.Serializable; import java.util.ArrayList; import java.util.Li..

Apache Tomcat :java.net.ConnectException: Connection refused

while i try to stop tomcat server its giving an error like this. [root@server classes]# service tomcat restart Stopping Tomcat service: Using CATALINA_BASE: /opt/tomcat Using CATALINA_HOME: /opt..

Set ANDROID_HOME environment variable in mac

I am new in developing native app using Salesforce SDK. I tried to create android project from command line using forcedroid tool but there is problem in setting environment variable named ANDROID_HOM..

What are the specific differences between .msi and setup.exe file?

I searched a lot, but all are guessed answers. Help me to find the exact answer...

What is the difference between background, backgroundTint, backgroundTintMode attributes in android layout xml?

While working with the android layout xml I came across backgroundTint attribute . I don't understand what is for. Also what is backgroundTintMode ??..

Best practice for storing and protecting private API keys in applications

Most app developers will integrate some third party libraries into their apps. If it's to access a service, such as Dropbox or YouTube, or for logging crashes. The number of third party libraries and ..

Programmatically read from STDIN or input file in Perl

What is the slickest way to programatically read from stdin or an input file (if provided) in Perl?..

What exactly are DLL files, and how do they work?

How exactly do DLL files work? There seems to be an awful lot of them, but I don't know what they are or how they work. So, what's the deal with them?..

Python truncate a long string

How does one truncate a string to 75 characters in Python? This is how it is done in JavaScript: var data="saddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddsaddddd..

Get the column number in R given the column name

Possible Duplicate: Get column index from label in a data frame I need to get the column number of a column given its name. Supose we have the following dataframe: df <- data.frame(a=r..

How to change password using TortoiseSVN?

I need to change my SVN password. I am using TortoiseSVN client. I am not able to find the password change or add user option. Is it possible? Is there any work around or command line syntax to..

How can I convert an image into Base64 string using JavaScript?

I need to convert my image to a Base64 string so that I can send my image to a server. Is there any JavaScript file for this? Else, how can I convert it?..

What is the correct syntax of ng-include?

I’m trying to include an HTML snippet inside of an ng-repeat, but I can’t get the include to work. It seems the current syntax of ng-include is different than what it was previously: I see many ex..

Min/Max-value validators in asp.net mvc

Validation using attributes in asp.net mvc is really nice. I have been using the [Range(min, max)] validator this far for checking values, like e.g.: [Range(1, 10)] public int SomeNumber { get; set;..

jQuery add image inside of div tag

I have a div tag <div id="theDiv">Where is the image?</div> I would like to add an image tag inside of the div End result: <div id="theDiv"><img id="theImg" src="theImg.png"..

How to use Javascript to read local text file and read line by line?

I have a web page made by html+javascript which is demo, I want to know how to read a local csv file and read line by line so that I can extract data from the csv file...