Questions Tagged with #Serialization

Serialization is the process by which data-structures are converted into a format that can be easily stored or transmitted and subsequently reconstructed.

How to write and read java serialized objects into a file

I am going to write multiple objects to a file and then retrieve them in another part of my code. My code has no error, but it is not working properly. Could you please help me find what is wrong abou..

How to serialize a JObject without the formatting?

I have a JObject (I'm using Json.Net) that I constructed with LINQ to JSON (also provided by the same library). When I call the ToString() method on the JObject, it outputs the results as formatted J..

JSONResult to String

I have a JsonResult that is working fine, and returning JSON from some POCO's. I want to save the JSON as a string in a DB. public JsonResult GetJSON() { JsonResult json = new JsonResult ..

How to Deserialize XML document

How do I Deserialize this XML document: <?xml version="1.0" encoding="utf-8"?> <Cars> <Car> <StockNumber>1020</StockNumber> <Make>Nissan</Make> ..

java.io.InvalidClassException: local class incompatible:

I created client and server and then added a class in client side for serializing purposes, then simply just went to the folder of the client in my hard drive and copy paste it to the server correpond..

Cannot deserialize the JSON array (e.g. [1,2,3]) into type ' ' because type requires JSON object (e.g. {"name":"value"}) to deserialize correctly

I have this JSON: [ { "Attributes": [ { "Key": "Name", "Value": { "Value": "Acc 1", "Values": [ ..

Understanding passport serialize deserialize

How would you explain the workflow of Passport's serialize and deserialize methods to a layman. Where does user.id go after passport.serializeUser has been called? We are calling passport.deserializ..

Converting an object to a string

How can I convert a JavaScript object into a string? Example: var o = {a:1, b:2} console.log(o) console.log('Item: ' + o) Output: Object { a=1, b=2} // very nice readable output :) Item: [ob..

How to generate serial version UID in Intellij

When I used Eclipse it had a nice feature to generate serial version UID. But what to do in IntelliJ? How to choose or generate identical serial version UID in IntelliJ? And what to do when you mo..

Convert a JSON string to object in Java ME?

Is there a way in Java/J2ME to convert a string, such as: {name:"MyNode", width:200, height:100} to an internal Object representation of the same, in one line of code? Because the current method ..

.NET NewtonSoft JSON deserialize map to a different property name

I have following JSON string which is received from an external party. { "team":[ { "v1":"", "attributes":{ "eighty_min_score":"", "home_or_away":"h..

Ruby objects and JSON serialization (without Rails)

I'm trying to understand the JSON serialization landscape in Ruby. I'm new to Ruby. Is there any good JSON serialization options if you are not working with Rails? That seems to be where this answer..

Saving an Object (Data persistence)

I've created an object like this: company1.name = 'banana' company1.value = 40 I would like to save this object. How can I do that?..

Is it possible to serialize and deserialize a class in C++?

Is it possible to serialize and deserialize a class in C++? I've been using Java for 3 years now, and serialization / deserialization is fairly trivial in that language. Does C++ have similar feature..

<Django object > is not JSON serializable

I have the following code for serializing the queryset; def render_to_response(self, context, **response_kwargs): return HttpResponse(json.simplejson.dumps(list(self.get_queryset())), ..

Jackson - How to process (deserialize) nested JSON?

{ vendors: [ { vendor: { id: 367, name: "Kuhn-Pollich", company_id: 1, } }, { vendor: { id: 374, name: "Sawayn-Hermann", ..

Best way to save a trained model in PyTorch?

I was looking for alternative ways to save a trained model in PyTorch. So far, I have found two alternatives. torch.save() to save a model and torch.load() to load a model. model.state_dict() to sav..

java.io.StreamCorruptedException: invalid stream header: 7371007E

I have a client Server application which communicate using objects. when I send only one object from the client to server all works well. when I attempt to send several objects one after another on th..

how to do file upload using jquery serialization

So I have a form and I'm submitting the form through ajax using jquery serialization function serialized = $(Forms).serialize(); $.ajax({ type : "POST", cach..

XML serialization in Java?

What is the Java analogue of .NET's XML serialization?..

Deserialize from string instead TextReader

I want to change my code from: string path = @"c:\Directory\test.xml"; XmlSerializer s = new XmlSerializer(typeof(Car)); TextReader r = new StreamReader(path); Car car = (Car)s.Deserialize(r); r.Cl..

Parcelable encountered IOException writing serializable object getactivity()

so I am getting this in logcat: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.resources.student_list.Student) I know this means that my stud..

Exception: Serialization of 'Closure' is not allowed

So I am not sure exactly what I would have to show you guys, how ever if you need more code please do not hesitate to ask: So this method will set up the initMailer for Zend with in our application: ..

Entity framework self referencing loop detected

I have a strange error. I'm experimenting with a .NET 4.5 Web API, Entity Framework and MS SQL Server. I've already created the database and set up the correct primary and foreign keys and relationshi..

Can Json.NET serialize / deserialize to / from a stream?

I have heard that Json.NET is faster than DataContractJsonSerializer, and wanted to give it a try... But I couldn't find any methods on JsonConvert that take a stream rather than a string. For de..

How to deserialize a JObject to .NET object

I happily use the Newtonsoft JSON library. For example, I would create a JObject from a .NET object, in this case an instance of Exception (might or might not be a subclass) if (result is Exception)..

Convert a python dict to a string and back

I am writing a program that stores data in a dictionary object, but this data needs to be saved at some point during the program execution and loaded back into the dictionary object when the program i..

How to make a class JSON serializable

How to make a Python class serializable? A simple class: class FileItem: def __init__(self, fname): self.fname = fname What should I do to be able to get output of: >>> imp..

Serializing to JSON in jQuery

I need to serialize an object to JSON. I'm using jQuery. Is there a "standard" way to do this? My specific situation: I have an array defined as shown below: var countries = new Array(); countries[0..

jQuery to serialize only elements within a div

I would like to get the same effect as jQuery.serialize() but I would like to return only the child elments of a given div. Sample result : single=Single2&multiple=Multiple&radio=radio1 ..

jQuery: serialize() form and other parameters

Is it possible to send form elements (serialized with .serialize() method) and other parameters with a single AJAX request? Example: $.ajax({ type : 'POST', url : 'url', data : { ..

How to send objects through bundle

I need to pass a reference to the class that does the majority of my processing through a bundle. The problem is it has nothing to do with intents or contexts and has a large amount of non-primitive ..

Convert Dictionary to JSON in Swift

I have create the next Dictionary: var postJSON = [ids[0]:answersArray[0], ids[1]:answersArray[1], ids[2]:answersArray[2]] as Dictionary and I get: [2: B, 1: A, 3: C] So, how can I convert it to..

Json.net serialize/deserialize derived types?

json.net (newtonsoft) I am looking through the documentation but I can't find anything on this or the best way to do it. public class Base { public string Name; } public class Derived : Base { ..

Deserialize JSON array(or list) in C#

here is the basic code: public static string DeserializeNames() { jsonData = "{\"name\":[{\"last\":\"Smith\"},{\"last\":\"Doe\"}]}"; JavaScriptSerializer ser = new JavaScriptSerializer(); ..

When should we implement Serializable interface?

public class Contact implements Serializable { private String name; private String email; public String getName() { return name; } public void setName(String name) { ..

What is the difference between Serialization and Marshaling?

I know that in terms of several distributed techniques (such as RPC), the term "Marshaling" is used but don't understand how it differs from Serialization. Aren't they both transforming obje..

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

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

Gson: How to exclude specific fields from Serialization without annotations

I'm trying to learn Gson and I'm struggling with field exclusion. Here are my classes public class Student { private Long id; private String firstName = "Ph..

Converting Stream to String and back...what are we missing?

I want to serialize objects to strings, and back. We use protobuf-net to turn an object into a Stream and back, successfully. However, Stream to string and back... not so successful. After going thr..

What is deserialize and serialize in JSON?

I have seen the terms "deserialize" and "serialize" with JSON. What do they mean?..

converting Java bitmap to byte array

Bitmap bmp = intent.getExtras().get("data"); int size = bmp.getRowBytes() * bmp.getHeight(); ByteBuffer b = ByteBuffer.allocate(size); bmp.copyPixelsToBuffer(b); byte[] bytes = new b..

What are Transient and Volatile Modifiers?

Can someone explain what the transient and volatile modifiers mean in Java?..

Is it possible to deserialize XML into List<T>?

Given the following XML: <?xml version="1.0"?> <user_list> <user> <id>1</id> <name>Joe</name> </user> <user> <id>..

How can I display a JavaScript object?

How do I display the content of a JavaScript object in a string format like when we alert a variable? The same formatted way I want to display an object...

Best way to serialize/unserialize objects in JavaScript?

I have many JavaScript objects in my application, something like: function Person(age) { this.age = age; this.isOld = function (){ return this.age > 60; } } // before serialize..

Java: object to byte[] and byte[] to object converter (for Tokyo Cabinet)

I need to convert objects to a byte[] to be stored in the Tokyo Cabinet key-value store. I also need to unbyte the byte[] to an Object when reading from the key-value store. Are there any packages ou..

Converting any object to a byte array in java

I have an object of type X which I want to convert into byte array before sending it to store in S3. Can anybody tell me how to do this? I appreciate your help...

What is a serialVersionUID and why should I use it?

Eclipse issues warnings when a serialVersionUID is missing. The serializable class Foo does not declare a static final serialVersionUID field of type long What is serialVersionUID and why is..

Converting between strings and ArrayBuffers

Is there a commonly accepted technique for efficiently converting JavaScript strings to ArrayBuffers and vice-versa? Specifically, I'd like to be able to write the contents of an ArrayBuffer to localS..

Java to Jackson JSON serialization: Money fields

Currently, I'm using Jackson to send out JSON results from my Spring-based web application. The problem I'm having is trying to get all money fields to output with 2 decimal places. I wasn't able to ..

C# JSON Serialization of Dictionary into {key:value, ...} instead of {key:key, value:value, ...}

Is it possible to serialize a .Net Dictionary<Key,Value> into JSON with DataContractJsonSerializer that is of the format: { key0:value0, key1:value1, ... } I use Dictionary <K,V>,..

What is object serialization?

What is meant by "object serialization"? Can you please explain it with some examples? ..

How do I copy a hash in Ruby?

I'll admit that I'm a bit of a ruby newbie (writing rake scripts, now). In most languages, copy constructors are easy to find. Half an hour of searching didn't find it in ruby. I want to create a copy..

How do you do a deep copy of an object in .NET?

I want a true deep copy. In Java, this was easy, but how do you do it in C#?..

What is [Serializable] and when should I use it?

I found out that some classes use the [Serializable] attribute. What is it? When should I use it? What kinds of benefits will I get? ..

Java serialization - java.io.InvalidClassException local class incompatible

I've got a public class, which implements Serializable, that is extended by multiple other classes. Only those subclasses were ever serialized before - never the super class. The super class had def..

Form submit with AJAX passing form data to PHP without page refresh

Can anyone tell me why this bit of code isn't working? <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script> $(function (..

Deserialize JSON into C# dynamic object?

Is there a way to deserialize JSON content into a C# 4 dynamic type? It would be nice to skip creating a bunch of classes in order to use the DataContractJsonSerializer. ..

Serialize object to query string in JavaScript/jQuery

I'm trying to find information on how to serialize an object to query string format, but all my searches are drowning in results on how to go the other way (string/form/whatever to JSON). I have { o..

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

Simple working Example of json.net in VB.net

I have the following simplified JSON string from a provider, its been a long time since I used Visual Studio and vb.Net, so I'm very rusty! { "Venue": { "ID": 3145, "Name": "Big Venue, Clap..

Biggest differences of Thrift vs Protocol Buffers?

What are the biggest pros and cons of Apache Thrift vs Google's Protocol Buffers?..

How can I ignore a property when serializing using the DataContractSerializer?

I am using .NET 3.5SP1 and DataContractSerializer to serialize a class. In SP1, they changed the behavior so that you don't have to include DataContract/DataMember attributes on the class and it will..

Using JsonConvert.DeserializeObject to deserialize Json to a C# POCO class

Here is my simple User POCO class: /// <summary> /// The User class represents a Coderwall User. /// </summary> public class User { /// <summary> /// A User's username. eg: ..

How to serialize object to CSV file?

I want to write a Object into CSV file. For XML we have XStream like this So if i want to convert object to CSV do we have any such library ? EDIT: I want to pass my list of Bean to a method which ..

Serializing/deserializing with memory stream

I'm having an issue with serializing using memory stream. Here is my code: /// <summary> /// serializes the given object into memory stream /// </summary> /// <param name="objectType"&..

How do I serialize a Python dictionary into a string, and then back to a dictionary?

How do I serialize a Python dictionary into a string, and then back to a dictionary? The dictionary will have lists and other dictionaries inside it...

Parsing JSON using Json.net

I'm trying to parse some JSON using the JSon.Net library. The documentation seems a little sparse and I'm confused as to how to accomplish what I need. Here is the format for the JSON I need to pars..

Serializing class instance to JSON

I am trying to create a JSON string representation of a class instance and having difficulty. Let's say the class is built like this: class testclass: value1 = "a" value2 = "b" A call to th..

NewtonSoft.Json Serialize and Deserialize class with property of type IEnumerable<ISomeInterface>

I am trying to move some code to consume ASP.NET MVC Web API generated Json data instead of SOAP Xml. I have run into a problem with serializing and deserializing properties of type: IEnumerable<..

How do I turn a C# object into a JSON string in .NET?

I have classes like these: class MyDate { int year, month, day; } class Lad { string firstName; string lastName; MyDate dateOfBirth; } And I would like to turn a Lad object into a ..

Convert an object to an XML string

I have got a class named WebserviceType I got from the tool xsd.exe from an XSD file. Now I want to deserialize an instance of an WebServiceType object to a string. How can I do this? The MethodC..

Submit form using AJAX and jQuery

It seems like this should be something built into jQuery without the need for more than a few lines of code, but I can't find the "simple" solution. Say, I have an HTML form: <form method="get" a..

How to get string objects instead of Unicode from JSON?

I'm using Python 2 to parse JSON from ASCII encoded text files. When loading these files with either json or simplejson, all my string values are cast to Unicode objects instead of string objects. ..

How to serialize an object into a string

I am able to serialize an object into a file and then restore it again as is shown in the next code snippet. I would like to serialize the object into a string and store into a database instead. Can a..

JSON.NET Error Self referencing loop detected for type

I tried to serialize POCO class that was automatically generated from Entity Data Model .edmx and when I used JsonConvert.SerializeObject I got the following error: Error Self referencing loop dete..

How do you serialize a model instance in Django?

There is a lot of documentation on how to serialize a Model QuerySet but how do you just serialize to JSON the fields of a Model Instance?..

How to save/restore serializable object to/from file?

I have a list of objects and I need to save that somewhere in my computer. I have read some forums and I know that the object has to be Serializable. But it would be nice if I can get an example. For ..

Fastest way to serialize and deserialize .NET objects

I'm looking for the fastest way to serialize and deserialize .NET objects. Here is what I have so far: public class TD { public List<CT> CTs { get; set; } public List<TE> TEs { ge..

MaxJsonLength exception in ASP.NET MVC during JavaScriptSerializer

In one of my controller actions I am returning a very large JsonResult to fill a grid. I am getting the following InvalidOperationException exception: Error during serialization or deserialization u..

How do I use a custom Serializer with Jackson?

I have two Java classes that I want to serialize to JSON using Jackson: public class User { public final int id; public final String name; public User(int id, String name) { this..

Why does writeObject throw java.io.NotSerializableException and how do I fix it?

I have this exception and I don't understand why it would be thrown or, how I should handle it. try { os.writeObject(element); } catch (IOException e) { e.printStackTrace(); } Where elemen..

JSON.Net Self referencing loop detected

I have a mssql database for my website within 4 tables. When I use this: public static string GetAllEventsForJSON() { using (CyberDBDataContext db = new CyberDBDataContext()) { retur..

Serializing list to JSON

I am sending information between client and Django server, and I would like to use JSON to this. I am sending simple information - list of strings. I tried using django.core.serializers, but when I di..

How to repair a serialized string which has been corrupted by an incorrect byte count length?

I am using Hotaru CMS with the Image Upload plugin, I get this error if I try to attach an image to a post, otherwise there is no error: unserialize() [function.unserialize]: Error at offset The..

How to JSON serialize sets?

I have a Python set that contains objects with __hash__ and __eq__ methods in order to make certain no duplicates are included in the collection. I need to json encode this result set, but passing ev..

What is the difference between Serializable and Externalizable in Java?

What is the difference between Serializable and Externalizable in Java?..

Serializing and submitting a form with jQuery and PHP

I'm trying to send a form's data using jQuery. However, data does not reach the server. Can you please tell me what I'm doing wrong? My HTML form: <form id="contactForm" name="contactForm" method..

Java: JSON -> Protobuf & back conversion

I have an existing system, which is using protobuf-based communication protocol between GUI and server. Now I would like to add some persistence, but at the moment protobuf messages are straight conve..

Cannot deserialize the current JSON array (e.g. [1,2,3])

I am trying to read my JSON result. Here is my RootObject public class RootObject { public int id { get; set; } public bool is_default { get; set; } public string name { get; set; } public int quant..

TypeError: Object of type 'bytes' is not JSON serializable

I just started programming Python. I want to use scrapy to create a bot,and it showed TypeError: Object of type 'bytes' is not JSON serializable when I run the project. import json import codecs c..

Why when a constructor is annotated with @JsonCreator, its arguments must be annotated with @JsonProperty?

In Jackson, when you annotate a constructor with @JsonCreator, you must annotate its arguments with @JsonProperty. So this constructor public Point(double x, double y) { this.x = x; this.y = ..

JavaScriptSerializer.Deserialize - how to change field names

Summary: How do I map a field name in JSON data to a field name of a .Net object when using JavaScriptSerializer.Deserialize ? Longer version: I have the following JSON data coming to me from a serve..

@JsonProperty annotation on field as well as getter/setter

I have inherited a certain bit code that has the @JsonProperty annotation on getter/setters. The purpose is so that when the object is serialized using the Jackson library, the fields have that specif..

How to Serialize a list in java?

I would like to deep clone a List. for that we are having a method // apache commons method. This object should be serializable SerializationUtils.clone ( object ) so now to clone my List i should..

How do I PHP-unserialize a jQuery-serialized form?

Using $('#form').serialize(), I was able to send this over to a PHP page. Now how do I unserialize it in PHP? It was serialized in jQuery...

How do I serialize an object and save it to a file in Android?

Say I have some simple class and once it's instantiated as an object I want to be able to serialize its contents to a file, and retrieve it by loading that file at some later time... I'm not sure wher..

$(this).serialize() -- How to add a value?

currently I have the following: $.ajax({ type: 'POST', url: this.action, data: $(this).serialize(), }); This works fine, however I would like to add a value to data, so I tried $.ajax(..

form serialize javascript (no framework)

Wondering is there a function in javascript without jquery or any framework that allows me to serialize the form and access the serialized version?..

How to get JSON data from the URL (REST API) to UI using jQuery or plain JavaScript?

I have a URL "http://localhost:8888/api/rest/abc" which will give following json data. I wants to get this data in my UI using Jquery or java script. I'm trying this from couple of hours but I'm unabl..

System.Data.SqlClient.SqlException: Invalid object name 'dbo.Projects'

My MVC app is returning SqlExceptions when trying to access any table in my database. Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'dbo.Projects'. My app us linq for th..

Loop X number of times

I'm working on my first PowerShell script and can't figure the loop out. I have the following, which will repeat $ActiveCampaigns number of times: Write-Host "Creating $PQCampaign1 Pre-Qualified Rep..

Verilog: How to instantiate a module

If I have a Verilog module 'top' and a verilog module 'subcomponent' how do I instantiate subcomponent in top? top: module top( input clk, input rst_n, input enable, ..

JPA CascadeType.ALL does not delete orphans

I am having trouble deleting orphan nodes using JPA with the following mapping @OneToMany (cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner") private List<Bikes> bikes; I..

file_put_contents - failed to open stream: Permission denied

I am trying to write a query to a file for debugging. The file is in database/execute.php. The file I want to write to is database/queries.php. I am trying to use file_put_contents('queries.txt', $qu..

SQL Server: Extract Table Meta-Data (description, fields and their data types)

I am trying to find a way to extract information about my tables in SQL Server (2008). The data I need needs to include the description of the table (filled from the Description property in the Proper..

socket.shutdown vs socket.close

I recently saw a bit of code that looked like this (with sock being a socket object of course): sock.shutdown(socket.SHUT_RDWR) sock.close() What exactly is the purpose of calling shutdown on the s..

Generating an MD5 checksum of a file

Is there any simple way of generating (and checking) MD5 checksums of a list of files in Python? (I have a small program I'm working on, and I'd like to confirm the checksums of the files)...

Colspan all columns

How can I specify a td tag should span all columns (when the exact amount of columns in the table will be variable/difficult to determine when the HTML is being rendered)? w3schools mentions you can u..

How can foreign key constraints be temporarily disabled using T-SQL?

Are disabling and enabling foreign key constraints supported in SQL Server? Or is my only option to drop and then re-create the constraints?..

CSS Input with width: 100% goes outside parent's bound

I am trying to make a login form constituted of two input fields with an inset padding, but those two fields always end up exceeding its parent's boundaries; the issue stems from the added inset paddi..

Switch to selected tab by name in Jquery-UI Tabs

If I have three tabs: <div id="tabs"> <ul> <li><a href="#sample-tab-1"><span>One</span></a></li> <li><a href="#sample-tab-..

Is there an equivalent to CTRL+C in IPython Notebook in Firefox to break cells that are running?

I've started to use the IPython Notebook and am enjoying it. Sometimes, I write buggy code that takes massive memory requirements or has an infinite loop. I find the "interrupt kernel" option sluggish..

Intellij JAVA_HOME variable

I started using Gradle and Intellij but I am having problems to configure Gradle's JVM. When I start a new Gradle project I am not allowed to define JVM as my JAVA_HOME variable. The following screens..

How to place div in top right hand corner of page

How do you float a div to the top right hand corner of a page using css? I want to float the topcorner div which is below: <p><a href="login.php">Log in</a></p> <div class..

How do I print out the contents of an object in Rails for easy debugging?

I think I'm trying to get the PHP equivalent of print_r() (print human-readable); at present the raw output is: ActiveRecord::Relation:0x10355d1c0 What should I do?..

What is the "N+1 selects problem" in ORM (Object-Relational Mapping)?

The "N+1 selects problem" is generally stated as a problem in Object-Relational mapping (ORM) discussions, and I understand that it has something to do with having to make a lot of database queries fo..

When do I need to do "git pull", before or after "git add, git commit"?

What is the right way? git add foo.js git commit foo.js -m "commit" git pull git push Or git pull git add foo.js git commit foo.js -m "commit" git push Or git add foo.js git pull git commit foo..

Determine SQL Server Database Size

SQL Server 2005/2008 Express edition has the limitation of 4 GB per database. As far as I known the database engine considers data only, thus excluding log files, unused space, and index size. Gettin..

reading external sql script in python

I am working on a learning how to execute SQL in python (I know SQL, not Python). I have an external sql file. It creates and inserts data into three tables 'Zookeeper', 'Handles', 'Animal'. Then I..

Using ListView : How to add a header view?

I looke at the ListView API and I saw the method: addHeaderView(View v) What I want to do is to have a layout above the list, is this possible ? I tried doing something like : EditText et=..

Do you use source control for your database items?

I feel that my shop has a hole because we don't have a solid process in place for versioning our database schema changes. We do a lot of backups so we're more or less covered, but it's bad practice to..

How do I check which version of NumPy I'm using?

How can I check which version of NumPy I'm using? (FYI this question has been edited because both the question and answer are not platform specific.)..

Javascript callback when IFRAME is finished loading?

I need to execute a callback when an IFRAME has finished loading. I have no control over the content in the IFRAME, so I can't fire the callback from there. This IFRAME is programmaticly created, and..

Using tr to replace newline with space

Have output from sed: http://sitename.com/galleries/83450 72-profile Those two strings should be merged into one and separated with space like: http://sitename.com/galleries/83450 72-profile Two..

Shorthand for if-else statement

I have some code with a lot of if/else statements similar to this: var name = "true"; if (name == "true") { var hasName = 'Y'; } else if (name == "false") { var hasName = 'N'; }; But is th..

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

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

firefox proxy settings via command line

How do I change Firefox Proxy settings via command line on windows xp/2k? Thanks..

How to open a new tab using Selenium WebDriver

How can I open a new tab in the existing Firefox browser using Selenium WebDriver (a.k.a. Selenium 2)?..

Regex AND operator

Based on this answer Regular Expressions: Is there an AND operator? I tried the following on http://regexpal.com/ but was unable to get it to work. What am missing? Does javascript not support it? ..

How do I restart a program based on user input?

I'm trying to restart a program using an if-test based on the input from the user. This code doesn't work, but it's approximately what I'm after: answer = str(raw_input('Run again? (y/n): ')) if an..

What's the "Content-Length" field in HTTP header?

What does it mean? Byte count of encoded content string with encoding specified in header. Character count of content string. Especially in case of Content-Type: application/x-www-form-urlencoded...

Best way to convert text files between character sets?

What is the fastest, easiest tool or method to convert text files between character sets? Specifically, I need to convert from UTF-8 to ISO-8859-15 and vice versa. Everything goes: one-liners in you..

Best way to store a key=>value array in JavaScript?

What's the best way to store a key=>value array in javascript, and how can that be looped through? The key of each element should be a tag, such as {id} or just id and the value should be the nume..

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need he..

How to randomize (or permute) a dataframe rowwise and columnwise?

I have a dataframe (df1) like this. f1 f2 f3 f4 f5 d1 1 0 1 1 1 d2 1 0 0 1 0 d3 0 0 0 1 1 d4 0 1 0 0 1 The d1...d4 column is t..

What is the purpose of willSet and didSet in Swift?

Swift has a property declaration syntax very similar to C#'s: var foo: Int { get { return getFoo() } set { setFoo(newValue) } } However, it also has willSet and didSet actions. These are ca..

How to align form at the center of the page in html/css

I am new to html/css. i am trying to build up my own form and i am trying to align it in the center. I used the align property in css but its not working. Html code: <!DOCTYPE HTML> <head&g..

How do the major C# DI/IoC frameworks compare?

At the risk of stepping into holy war territory, What are the strengths and weaknesses of these popular DI/IoC frameworks, and could one easily be considered the best? ..: Ninject Unity Castle.Wind..

Callback when CSS3 transition finishes

I'd like to fade out an element (transitioning its opacity to 0) and then when finished remove the element from the DOM. In jQuery this is straight forward since you can specify the "Remove" to happe..

How to check a channel is closed or not without reading it?

This is a good example of workers & controller mode in Go written by @Jimt, in answer to "Is there some elegant way to pause & resume any other goroutine in golang?" package main import ( ..

How can I regenerate ios folder in React Native project?

So a while ago I deleted the /ios directory in my react native app (let's call it X). I've been developing and testing using the android emulator but now I'd like to make sure it works on ios with xco..

How can I turn a List of Lists into a List in Java 8?

If I have a List<List<Object>>, how can I turn that into a List<Object> that contains all the objects in the same iteration order by using the features of Java 8?..

Error to use a section registered as allowDefinition='MachineToApplication' beyond application level

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. The top line in all of my aspx pages in my /portal/ directory has this error message..

What are queues in jQuery?

I found the jQuery.com document on queue()/dequeue() is too simple to understand. What exactly are queues in jQuery? How should I use them?..

undefined reference to boost::system::system_category() when compiling

I'm trying to compile a program on Ubuntu 11.10 that uses the Boost libraries. I have the 1.46-dev Boost libraries from the Ubuntu Repository installed, but I get an error when compiling the program. ..

MVC4 DataType.Date EditorFor won't display date value in Chrome, fine in Internet Explorer

I'm using the DataType.Date attribute on my model and an EditorFor in my view. This is working fine in Internet Explorer 8 and Internet Explorer 9, but in Google Chrome it is showi..

Back button and refreshing previous activity

If we have two activities: List of files and last modified time File editing activity A user selects a file from the list and is taken to the file editing activity. When done editing, the user pre..

How to make the Facebook Like Box responsive?

I am using the Facebook like box code in my side bar by pasting the Facebook code into a text widget. My theme is responsive, and I'd like to get the like box to resize correctly. I found this tutoria..

What is a callback in java

Possible Duplicate: What is a callback function? I have read the wikipedia definition of a callback but I still didn't get it. Can anyone explain me what a callback is, especially the follo..

javascript filter array of objects

I have an array of objects and I'm wondering the best way to search it. Given the below example how can I search for name = "Joe" and age < 30? Is there anything jQuery can help with or do I have t..

Django Template Variables and Javascript

When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}. Is there a way to access the s..

How to find current transaction level?

How do you find current database's transaction level on SQL Server?..

Maven: Failed to retrieve plugin descriptor error

I configured Maven 3.0.3 and tried to download a sample project using archetypes with this command: mvn archetype:generate -DarchetypeGroupId=org.graniteds.archetypes -Darche..

Is there a way to run Bash scripts on Windows?

I have bought and I use Windows 7 Ultimate, and I like to use it to develop applications. One of the down sides (as with every OS) is that I can not run Bash scripts. Is there a way to run Bash script..

How to check identical array in most efficient way?

I want to check if the two arrays are identical (not content wise, but in exact order). For example: array1 = [1,2,3,4,5] array2 = [1,2,3,4,5] array3 = [3,5,1,2,4] Array 1 and 2 are identical b..

Sending mail attachment using Java

I am trying to send an email using Java and Gmail. I have stored my files on the cloud and the stored files I want to send as an attachment to my email. It should add those files to this mail and not..

Execute JavaScript code stored as a string

How do I execute some JavaScript that is a string? function ExecuteJavascriptString() { var s = "alert('hello')"; // how do I get a browser to alert('hello')? } ..

Matrix Transpose in Python

I am trying to create a matrix transpose function for python but I can't seem to make it work. Say I have theArray = [['a','b','c'],['d','e','f'],['g','h','i']] and I want my function to come up w..

How to disable the parent form when a child form is active?

How to disable a parent form when child form is active using c#?..

Why would one omit the close tag?

I keep reading it is poor practice to use the PHP close tag ?> at the end of the file. The header problem seems irrelevant in the following context (and this is the only good argument so far): ..

What does the term "Tuple" Mean in Relational Databases?

Please explain what is meant by tuples in sql?Thanks....

how to change attribute "hidden" in jquery

<td> <input id="check" type="checkbox" name="del_attachment_id[]" value="<?php echo $attachment['link'];?>"> </td> <td id="delete" hidden="true"> the file will be delete..

How to set background color of a View

I'm trying to set the background color of a View (in this case a Button). I use this code: // set the background to green v.setBackgroundColor(0x0000FF00 ); v.invalidate(); It causes the Button to..

Unit Testing C Code

I worked on an embedded system this summer written in straight C. It was an existing project that the company I work for had taken over. I have become quite accustomed to writing unit tests in Java ..

"The POM for ... is missing, no dependency information available" even though it exists in Maven Repository

Problem: A dependency will not download even though I copied it from the Maven Repository. When I hover over the dependency in Eclipse, it warns: "Maven Missing artifact org.raml:jaxrs-code-generato..

How to start Fragment from an Activity

I already want to start my RecipientFragment from my MainActivity and pass data onto the Fragment from my MainActivity. Here is the code that I have implemented. But the fragment does not start. Bund..

JavaScript check if value is only undefined, null or false

Other than creating a function, is there a shorter way to check if a value is undefined,null or false only in JavaScript? The below if statement is equivalent to if(val===null && val===undefi..

Capture close event on Bootstrap Modal

I have a Bootstrap Modal to select events. If the user clicks on the X button or outside the modal, I would like to send them to the default event. How can I capture these events? This is my HTML cod..

Inline <style> tags vs. inline css properties

What is the preferred method for setting CSS properties? Inline style properties: <div style="width:20px;height:20px;background-color:#ffcc00;"></div> Style properties in <style>..

How to get to Model or Viewbag Variables in a Script Tag

Vs'12 asp.net C# MVC4 - Int.Appl.Template EF Code First Here is my very simple Script <script class="TractsScript"> $('#Add').click(function (e) { var val = @ViewBag.ForSection..

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

Is there a way to return a list of all the image file names from a folder using only Javascript?

I want to display all images from folder located in server in image gallery. Is there a way to return a list of all the image file names from a folder using only JavaScript or JQuery? Also I want to..

What is (functional) reactive programming?

I've read the Wikipedia article on reactive programming. I've also read the small article on functional reactive programming. The descriptions are quite abstract. What does functional reactive progr..

Deserializing JSON Object Array with Json.net

I am attempt to use an API that use the follow example structure for their returned json [ { "customer":{ "first_name":"Test", "last_name":"Account", "email":"test..

Get Element value with minidom with Python

I am creating a GUI frontend for the Eve Online API in Python. I have successfully pulled the XML data from their server. I am trying to grab the value from a node called "name": from xml.dom.minid..

Drawable image on a canvas

How can I get an image to the canvas in order to draw on that image?..

PermissionError: [WinError 5] Access is denied python using moviepy to write gif

I'm using windows 8.1 64 bit my code import pdb from moviepy.editor import * clip = VideoFileClip(".\\a.mp4") clip.write_gif('.\\aasda.gif') the exception is at write_gif method Traceback (most ..

Python set to list

How can I convert a set to a list in Python? Using a = set(["Blah", "Hello"]) a = list(a) doesn't work. It gives me: TypeError: 'set' object is not callable ..

Javascript Audio Play on click

I have a javascript code to start a sound on click . It works on chrome but on firefox it starts onload, but I want it onclick there too. Can anyone help? <script> var audio = new Audio("http..

Stopping fixed position scrolling at a certain point?

I have an element that is position:fixed and so scrolls with the page how i want it to however. when the user scrolls up I want the element to stop scrolling at a certain point, say when it is 250px f..

Make hibernate ignore class variables that are not mapped

I thought hibernate takes into consideration only class variables that are annotated with @Column. But strangely today when I added a variable (that is not mapped to any column, just a variable i nee..

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

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

Using JavaScript to display a Blob

I am retrieving a Blob image from a database, and I'd like to be able to view that image using JavaScript. The following code produces a broken image icon on the page: var image = document.createElem..

SQL WHERE condition is not equal to?

Is it possible to negate a where clause? e.g. DELETE * FROM table WHERE id != 2; ..

AngularJS. How to call controller function from outside of controller component

How I can call function defined under controller from any place of web page (outside of controller component)? It works perfectly when I press "get" button. But I need to call it from outside of div ..

How to add a char/int to an char array in C?

How can I add '.' to the char Array := "Hello World" in C, so I get a char Array: "Hello World." The Question seems simple but I'm struggling. Tried the following: char str[1024]; char tmp = '.'; s..

How to configure multi-module Maven + Sonar + JaCoCo to give merged coverage report?

I've searched up and down the internet for this one. There's lots of half-answers out there, to do with Maven properties such as ${sonar.jacoco.reportPath}, or org.jacoco:jacoco-maven-plugin:prepare-a..

Get specific ArrayList item

public static ArrayList mainList = someList; How can I get a specific item from this ArrayList? mainList[3]?..

Find all files with a filename beginning with a specified string?

I have a directory with roughly 100000 files in it, and I want to perform some function on all files beginning with a specified string, which may match tens of thousands of files. I have tried ls my..

How to get the error message from the error code returned by GetLastError()?

After a Windows API call, how can I get the last error message in a textual form? GetLastError() returns an integer value, not a text message...

How can I remove a substring from a given String?

Is there an easy way to remove substring from a given String in Java? Example: "Hello World!", removing "o" ? "Hell Wrld!"..

How does one add keyboard languages and switch between them in Linux Mint 16?

I've added languages in Language Support but I do not see the language icon in the panel tray, nor can I switch between languages...

Error running android: Gradle project sync failed. Please fix your project and try again

Android Studio (1.2 RC0) keeps telling me Error running android: Gradle project sync failed. Please fix your project and try again. How can I find out what the problem is? Unfortunately the solution..

Fast way to concatenate strings in nodeJS/JavaScript

I understand that doing something like var a = "hello"; a += " world"; It is relatively very slow, as the browser does that in O(n) . Is there a faster way of doing so without installing new librar..

JSONResult to String

I have a JsonResult that is working fine, and returning JSON from some POCO's. I want to save the JSON as a string in a DB. public JsonResult GetJSON() { JsonResult json = new JsonResult ..

How to assign more memory to docker container

As the title reads, I'm trying to assign more memory to my container. I'm using an image from docker hub called "aallam/tomcat-mysql" in case that's relevant. When I start it normally without any spe..

SQL Server: IF EXISTS ; ELSE

I have a tableA: ID value 1 100 2 101 2 444 3 501 Also TableB ID Code 1 2 Now I want to populate col = code of table B if there exists ID = 2 in tableA. for multiple values , get max va..

Eclipse "Invalid Project Description" when creating new project from existing source

I am trying to create a new project from existing source code. I keep getting the following error: "Invalid Project Description", project path "overlaps the location of another project" with the same ..

How to make div occupy remaining height?

I have this problem, I have two divs: <div style="width:100%; height:50px;" id="div1"></div> <div style="width:100%;" id="div2"></div> How do I make div2 occupy remaining he..

When to use references vs. pointers

I understand the syntax and general semantics of pointers versus references, but how should I decide when it is more-or-less appropriate to use references or pointers in an API? Naturally some situat..

Centering FontAwesome icons vertically and horizontally

I'm currently using FontAwesome, and am having a really hard time centering the icons both vertically and horizontally in their container. I have tried doing it via positioning and ran into issues bc..

How to deselect a selected UITableView cell?

I am working on a project on which I have to preselect a particular cell. I can preselect a cell using -willDisplayCell, but I can't deselect it when the user clicks on any other cell. - (void..

sprintf like functionality in Python

I would like to create a string buffer to do lots of processing, format and finally write the buffer in a text file using a C-style sprintf functionality in Python. Because of conditional statements, ..

.attr("disabled", "disabled") issue

I have this function toggles the disabled attribute form a input field: $('.someElement').click(function(){ if (someCondition) { console.log($target.prev('input')) // gives out the right..

Scanner is never closed

I'm working on a game and I came across a little problem with my scanner. I'm getting a resource leak scanner never closed. But I thought my scanner was working before without closing it. But now it ..

Java :Add scroll into text area

How can i add the scroll bar to my text area. i have tried with this code but it's not working. middlePanel=new JPanel(); middlePanel.setBorder(new TitledBorder(new EtchedBorder()..

What is the iOS 6 user agent string?

What is the iOS 6.0 user agent string? Previous user-agent strings: iOS 5.1 - What is the iOS 5.1 user agent string? iOS 5.0 - What is the iOS 5.0 user agent string? iOS 4.0 - What is the iPhone ..

How to debug Javascript with IE 8

How can we debug JavaScript with IE 8 ? The JavaScript debbuging with Visual Studio doesn't work after an update to IE 8...

Maven error "Failure to transfer..."

I am trying to set up a project using Maven (m2eclipse), but I get this error in Eclipse: Description Resource Path Location Type Could not calculate build plan: Failure to transfer ..

jQuery: How to get the HTTP status code from within the $.ajax.error method?

I'm using jQuery to make an AJAX request. I want to perform different actions whether or not the HTTP status code is a 400 error or a 500 error. How can I achieve this? $.ajax({ type: 'POST', ..

difference between css height : 100% vs height : auto

I was asked a question in an interview that "what is the difference between the css height:100% and height:auto?" Can any one explain?..

How to load all modules in a folder?

Could someone provide me with a good way of importing a whole directory of modules? I have a structure like this: /Foo bar.py spam.py eggs.py I tried just converting it to a package by ..

Can't import my own modules in Python

I'm having a hard time understanding how module importing works in Python (I've never done it in any other language before either). Let's say I have: myapp/__init__.py myapp/myapp/myapp.py myapp/mya..

Convert an NSURL to an NSString

I have an app where the user can choose an image either from the built-in app images or from the iphone photo library. I use an object Occasion that has an NSString property to save the imagePath. N..

Push JSON Objects to array in localStorage

I have a function in Javascript: var a = []; function SaveDataToLocalStorage(data) { var receiveddata = JSON.stringify(data); a.push(receiveddata); alert(a); localStorage.setI..

Code Sign error: The identity 'iPhone Developer' doesn't match any valid certificate/private key pair in the default keychain

How do you fix this XCode error : Code Sign error: The identity 'iPhone Developer' doesn't match any valid certificate/private key pair in the default keychain ..

List only stopped Docker containers

Docker gives you a way of listing running containers or all containers including stopped ones. This can be done by: $ docker ps # To list running containers Or by $ docker ps -a # To list running..

How to Delete a directory from Hadoop cluster which is having comma(,) in its name?

I have uploaded a Directory to hadoop cluster that is having "," in its name like "MyDir, Name" when I am trying to delete this Directory by using rmr hadoop shell command as following hadoop dfs -rm..

Using switch statement with a range of value in each case?

In Java, is it possible to write a switch statement where each case contains more than one value? For example (though clearly the following code won't work): switch (num) { case 1 .. 5: S..

Splitting a list into N parts of approximately equal length

What is the best way to divide a list into roughly equal parts? For example, if the list has 7 elements and is split it into 2 parts, we want to get 3 elements in one part, and the other should have 4..

Peak detection in a 2D array

I'm helping a veterinary clinic measuring pressure under a dogs paw. I use Python for my data analysis and now I'm stuck trying to divide the paws into (anatomical) subregions. I made a 2D array of e..

Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ' '

I am trying to query from a temp table and i keep getting this message: Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ' '. Can somebody tell me what the problem is? Is it due to convert..

Filter values only if not null using lambda in Java8

I have a list of objects say car. I want to filter this list based on some parameter using Java 8. But if the parameter is null, it throws NullPointerException. How to filter out null values? Current..

What is the height of iPhone's onscreen keyboard?

The height in portrait and the height in landscape measured in points...

MAMP mysql server won't start. No mysql processes are running

My MAMP mysql server won't start. All of the suggestions I've seen on the web say to check for other mysqld processes running and kill them if they exist, and that it should fix the problem, but it ha..

Attaching a Sass/SCSS to HTML docs

Hello I am new to web design. I would like to learn how to attach an SCSS file to an HTML file in the head tag : <link href="example" rel="stylesheet/scss" type="text/css&q..

IF EXISTS, THEN SELECT ELSE INSERT AND THEN SELECT

How do you say the following in Microsoft SQL Server 2005: IF EXISTS (SELECT * FROM Table WHERE FieldValue='') THEN SELECT TableID FROM Table WHERE FieldValue='' ELSE INSERT INTO TABLE(FieldVal..

Get the element with the highest occurrence in an array

I'm looking for an elegant way of determining which element has the highest occurrence (mode) in a JavaScript array. For example, in ['pear', 'apple', 'orange', 'apple'] the 'apple' element is th..

how to show calendar on text box click in html

In html i want to show calendar to select date while clicking a text box. then we select a date from that calendar then the selected date will be display in that text box...

UTF-8 encoding in JSP page

I have a JSP page whose page encoding is ISO-8859-1. This JSP page there is in a question answer blog. I want to include special characters during Q/A posting. The problem is JSP is not supporting U..

Deny all, allow only one IP through htaccess

I'm trying to deny all and allow only for a single IP. But, I would like to have the following htaccess working for that single IP. I'm not finding a way to have both working: the deny all and allow o..

How can I combine two commits into one commit?

I have a branch 'firstproject' with 2 commits. I want to get rid of these commits and make them appear as a single commit. The command git merge --squash sounds promising, but when I run git merge -..

Most efficient way to check for DBNull and then assign to a variable?

This question comes up occasionally, but I haven't seen a satisfactory answer. A typical pattern is (row is a DataRow): if (row["value"] != DBNull.Value) { someObject.Member = row["value"]; ..

CSS: background image on background color

I have panel which I colored blue if this panel is being selected (clicked on it). Additionally, I add a small sign (.png image) to that panel, which indicates that the selected panel has been already..

PHP: Inserting Values from the Form into MySQL

I created a users table in mysql from the terminal and I am trying to create simple task: insert values from the form. This is my dbConfig file <?php $mysqli = new mysqli("localhost", "root", "pa..

java.lang.ClassCastException

Normally whats the reason to get java.lang.ClassCastException ..? I get the following error in my application java.lang.ClassCastException: [Lcom.rsa.authagent.authapi.realmstat.AUTHw ..

How to wait for async method to complete?

I'm writing a WinForms application that transfers data to a USB HID class device. My application uses the excellent Generic HID library v6.0 which can be found here. In a nutshell, when I need to wr..

How to put multiple statements in one line?

I wasn't sure under what title to ponder this question exactly, coding golf seems appropriate if a bit unspecific. I know a little bit of comprehensions in python but they seem very hard to 'read'. Th..

How do I migrate an SVN repository with history to a new Git repository?

I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like: SVN repository in: svn://myserver/path/to/svn/repos G..

How to enable cURL in PHP / XAMPP

How do I enable cURL in PHP? ??..

SQL Error with Order By in Subquery

I'm working with SQL Server 2005. My query is: SELECT ( SELECT COUNT(1) FROM Seanslar WHERE MONTH(tarihi) = 4 GROUP BY refKlinik_id ORDER BY refKlinik_id ) as dorduncuay And the error: ..

HTTP could not register URL http://+:8000/HelloWCF/. Your process does not have access rights to this namespace

I'm a beginner in WCF, but trying to improve my experience. And on the first step I faced the problem. I created the simplest WCF service. The listing of code: (all the code in one file) using System..

How to set UTF-8 encoding for a PHP file

I have a PHP script called : http://cyber-flick.com/apiMorpho.php?method=getMorphoData&word=kot That displays some data in plain text: CzÄ?L?Ä? mowy: rzeczownik Przypadek: dopeL?niacz Rod..

How can I submit a POST form using the <a href="..."> tag?

How can I submit a POST form to showMessage.jsp using just the <a href="..."> tag? <form action="showMessage.jsp" method="post"> <a href="showMessage.jsp"><%=n%></a>..

Print raw string from variable? (not getting the answers)

I'm trying to find a way to print a string in raw form from a variable. For instance, if I add an environment variable to Windows for a path, which might look like 'C:\\Windows\Users\alexb\', I know I..

Should operator<< be implemented as a friend or as a member function?

That's basically the question, is there a "right" way to implement operator<< ? Reading this I can see that something like: friend bool operator<<(obj const& lhs, obj const& rhs);..

phpMyAdmin is throwing a #2002 cannot log in to the mysql server phpmyadmin

I have installed MySQL server enterprise 5.1 on my local machine and now I want to install phpMyAdmin, but it does not work. I have unrared phpMyAdmin to my server root directory and browsed to "loca..

What is your single most favorite command-line trick using Bash?

We all know how to use <ctrl>-R to reverse search through history, but did you know you can use <ctrl>-S to forward search if you set stty stop ""? Also, have you ever tried running bind ..

Import functions from another js file. Javascript

I have a question about including a file in javascript. I have a very simple example: --> index.html --> models --> course.js --> student.js course.js: function Course() ..

Java 8 forEach with index

Is there a way to build a forEach method in Java 8 that iterates with an index? Ideally I'd like something like this: params.forEach((idx, e) -> query.bind(idx, e)); The best I could do right no..

Spring: how do I inject an HttpServletRequest into a request-scoped bean?

I'm trying to set up a request-scoped bean in Spring. I've successfully set it up so the bean is created once per request. Now, it needs to access the HttpServletRequest object. Since the bean is cr..

Test if object implements interface

This has probably been asked before, but a quick search only brought up the same question asked for C#. See here. What I basically want to do is to check wether a given object implements a given inte..

iTerm2 keyboard shortcut - split pane navigation

I have been a long time user of the standard Mac Terminal. Decided to experiment with iTerm2 after hearing good things about it from my colleagues. One of the more useful features I am seeing on iTer..

java: HashMap<String, int> not working

HashMap<String, int> doesn't seem to work but HashMap<String, Integer> does work. Any ideas why?..

Android WebView not loading an HTTPS URL

public void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); setContentView(R.layout.show_voucher); webView=(WebView)findViewById(R.id.webview); webView.getSettin..

How do I get the offset().top value of an element without using jQuery?

I'm programming a single-page application using the Angular framework. I'm new to it. I've read this guide to help me understand the fundamental differences between jQuery and Angular and I'd like to ..

How do I make an HTML text box show a hint when empty?

I want the search box on my web page to display the word "Search" in gray italics. When the box receives focus, it should look just like an empty text box. If there is already text in it, it should di..

Dealing with multiple Python versions and PIP?

Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my site 2.5 installation or my site 2.6 installation. Fo..

How to redirect the output of a PowerShell to a file during its execution

I have a PowerShell script for which I would like to redirect the output to a file. The problem is that I cannot change the way this script is called. So I cannot do: .\MyScript.ps1 > output.txt ..

How to align two divs side by side using the float, clear, and overflow elements with a fixed position div/

So I've been trying to align two divs side by side without overlapping. I have one div which will be fixed as a sidebar and the right div as the content. Hopefully, someone can help me. _x000D_ _x000..

What are the differences between Deferred, Promise and Future in JavaScript?

What are the differences between Deferreds, Promises and Futures? Is there a generally approved theory behind all these three?..

Adding 1 hour to time variable

I have a time to which I want to add an hour: $time = '10:09'; I've tried: $time = strtotime('+1 hour'); strtotime('+1 hour', $time); $time = date('H:i', strtotime('+1 hour')); But none of the abo..

Why can't I do <img src="C:/localfile.jpg">?

It works if the html file is local (on my C drive), but not if the html file is on a server and the image file is local. Why is that? Any possible workarounds?..

Git Cherry-Pick and Conflicts

There are two different git branches. In one the development is going in (Branch1). In other branch some PoC work is going on (Branch2). Now, I want to cherry-pick the changes from Branch1 to Branch2..

In Java, how do you determine if a thread is running?

How do you determine if a thread is running?..

CSS: 100% width or height while keeping aspect ratio?

Currently, with STYLE, I can use width: 100% and auto on the height (or vice versa), but I still can't constrain the image into a specific position, either being too wide or too tall, respectively. A..

How to get the selected index of a RadioGroup in Android

Is there an easy way to get the selected index of a RadioGroup in Android or do I have to use OnCheckedChangeListener to listen for changes and have something that holds the last index selected? exam..

"Rate This App"-link in Google Play store app on the phone

I'd like to put a "Rate This App"-link in an Android App to open up the app-listing in the user's Google Play store app on their phone. What code do I have to write to create the market:// or http:/..

Compiling C++ on remote Linux machine - "clock skew detected" warning

I'm connected to my university's small Linux cluster via PuTTY and WinSCP, transferring files using the latter and compiling and running them with the former. My work so far has been performed in the..

C++ "Access violation reading location" Error

I have the following Vertex struct in a Graph class: struct Vertex { string country; string city; double lon; double lat; vector<edge> *adj; Vertex(string country, stri..

How can you program if you're blind?

Sight is one of the senses most programmers take for granted. Most programmers would spend hours looking at a computer monitor (especially during times when they are in the zone), but I know there are..

int to string in MySQL

Is it possible to do something like this? Essentially I want to cast a int into a string and used the string on a join. Pay attention to the %t1.id% select t2.* from t1 join t2 on t2.url='site.com/..

Renaming files in a folder to sequential numbers

I want to rename the files in a directory to sequential numbers. Based on creation date of the files. For Example sadf.jpg to 0001.jpg, wrjr3.jpg to 0002.jpg and so on, the number of leading zeroes d..

Difference between Fact table and Dimension table?

When reading a book for business objects, I came across the term- fact table and dimension table. I am trying to understand what is the different between Dimension table and Fact table? I read coup..

Include CSS and Javascript in my django template

I am a newbie in Django 1.5 and I have learn some basic things about it. My problem is , I am not able to include css and javascript in my template. I have read the documentation about it but as i hav..

Oracle Not Equals Operator

There are two not equals operator - != and <>. What's the difference between them? I heard that != is more efficient than other for comparing strings. Could anyone give a qualitative comment o..

How to style the option of an html "select" element?

Here's my HTML: <select id="ddlProducts" name="ddProducts"> <option>Product1 : Electronics </option> <option>Product2 : Sports </option> </select> I wa..

How can you customize the numbers in an ordered list?

How can I left-align the numbers in an ordered list? 1. an item // skip some items for brevity 9. another item 10. notice the 1 is under the 9, and the item contents also line up Change the char..

HTML5 Canvas vs. SVG vs. div

What is the best approach for creating elements on the fly and being able to move them around? For example, let's say I want to create a rectangle, circle and polygon and then select those objects and..

Escaping ampersand in URL

I am trying to send a GET message that contains strings with ampersands and can't figure how to escape the ampersand in the URL. Example: http://www.example.com?candy_name=M&M result => candy..

Count cells that contain any text

I want to count the cells that contain anything within a range. Any cell that contain text, or numbers or something else should do a plus one in my result-cell. I found this function, countif(range;..

Is there an embeddable Webkit component for Windows / C# development?

I've seen a few COM controls which wrap the Gecko rendering engine (GeckoFX, as well as the control shipped by Mozilla - mozctlx.dll). Is there a wrapper for Webkit that can be included in a .NET Winf..

How to extract Month from date in R

I am using the lubridate package and applying the month function to extract month from date. I ran the str command on date field and I got Factor w/ 9498 levels "01/01/1979","01/01/1980",..: 5305 1 ..

What's the difference between ".equals" and "=="?

I switched lecturers today and he stated using a weird code to me. (He said it's better to use .equals and when I asked why, he answered "because it is!") So here's an example: if (o1.equals(o2)) { ..

Cannot read property 'style' of undefined -- Uncaught Type Error

I would like to change the color, fontsize and font weight of the text in a span element of the html page. I am using the following code: if(window.location.href.indexOf("test") > -1){ var se..

WELD-001408: Unsatisfied dependencies for type Customer with qualifiers @Default

I'm a Java EE-newbie. I want to test JSF and therefore made a simple program but can not deploy it. I get the following error message: cannot Deploy onlineshop-war deploy is failing=Error occurred du..

change array size

Is it possible to change an array size after declaration? If not, is there any alternative to arrays? I do not want to create an array with a size of 1000, but I do not know the size of the array when..

How do I find where JDK is installed on my windows machine?

I need to know where JDK is located on my machine. On running Java -version in cmd, it shows the version as '1.6.xx'. To find the location of this SDK on my machine I tried using echo %JAVA_HOME% bu..

SQL SELECT multi-columns INTO multi-variable

I'm converting SQL from Teradata to SQL Server in Teradata, they have the format SELECT col1, col2 FROM table1 INTO @variable1, @variable2 In SQL Server, I found SET @variable1 = ( SELECT col1 ..

How does cookie based authentication work?

Can someone give me a step by step description of how cookie based authentication works? I've never done anything involving either authentication or cookies. What does the browser need to do? What doe..

How to cancel a pull request on github?

How can a pull request on github be cancelled?..

Getting Image from URL (Java)

I am trying to read the following image But it is showing IIOException. Here is the code: Image image = null; URL url = new URL("http://bks6.books.google.ca/books?id=5VTBuvfZDyoC&printsec=fro..

Which characters are valid/invalid in a JSON key name?

Are there any forbidden characters in key names, for JavaScript objects or JSON strings? Or characters that need to be escaped? To be more specific, I'd like to use "$", "-" and space in key names...

How to print something to the console in Xcode?

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

HTML Table cell background image alignment

I need the background image of a table cell to be aligned as Top in vertical side - Right in Horizontal But it is displaying as, Center in Vertical side ; Right in Horizontal Take a look a..

How to install XNA game studio on Visual Studio 2012?

Is it possible to create XNA games using Visual Studio 2012?..

OpenCV get pixel channel value from Mat image

Maybe I'm not looking hard enough, but everything seems to want me to use an array. Thus, how do I get the channel value for a particular pixel for foo if foo is something like Mat foo = imread("bar.p..

Use async await with Array.map

Given the following code: var arr = [1,2,3,4,5]; var results: number[] = await arr.map(async (item): Promise<number> => { await callAsynchronousOperation(item); return item ..