Questions Tagged with #Base64

Base64 is a set of encoding schemes that represent binary data in an ASCII string format.

Convert Base64 string to an image file?

I am trying to convert my base64 image string to an image file. This is my Base64 string: http://pastebin.com/ENkTrGNG Using following code to convert it into an image file: function base64_to_jpeg..

base64 encoded images in email signatures

I have to include some images (company logo's etc) in email signatures. I've had all sorts of issues using the embedded images produced by the email system in question (they get sent as attachments ge..

How can I save a base64-encoded image to disk?

My Express app is receiving a base64-encoded PNG from the browser (generated from canvas with toDataURL() ) and writing it to a file. But the file isn't a valid image file, and the "file" utility simp..

Base64 PNG data to HTML5 canvas

I want to load a PNG image encoded in Base64 to canvas element. I have this code: <html> <head> </head> <body> <canvas id="c"></canvas> <script type="text/javas..

Python base64 data decode

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

PHP - get base64 img string decode and save as jpg (resulting empty image )

hi i'm actually sending a base64 image string trough ajax to a php script which just decodes string and save content as .jpg file. But the result is an empty image. How can this be possible? php sc..

Decoding base64 in batch

I am trying to make an installer using batch. Of course, an installer needs to consist of files that will be installed, so I'm thinking of encoding the files in base64, and simply decode them and writ..

ReadFile in Base64 Nodejs

I'm trying to read an image from client side encoded in base64. How to read with nodejs? My code: // add to buffer base64 image var encondedImage = new Buffer(image.name, 'base64'); fs.readFile(enc..

Convert an image (selected by path) to base64 string

How do you convert an image from a path on the user's computer to a base64 string in C#? For example, I have the path to the image (in the format C:/image/1.gif) and would like to have a data URI like..

How to convert Base64 String to javascript file object like as from file input form?

I want to convert Base64String extracted from file(ex: "AAAAA....~") to a javascript file object. The javascript file object what I mean is like this code: HTML: <input type="file" id="selectFi..

How can you encode a string to Base64 in JavaScript?

I have a PHP script that can encode a PNG image to a Base64 string. I'd like to do the same thing using JavaScript. I know how to open files, but I'm not sure how to do the encoding. I'm not used to ..

Convert between UIImage and Base64 string

Does anyone know how to convert a UIImage to a Base64 string, and then reverse it? I have the below code; the original image before encoding is good, but I only get a blank image after I encode and d..

Base64 String throwing invalid character error

I keep getting a Base64 invalid character error even though I shouldn't. The program takes an XML file and exports it to a document. If the user wants, it will compress the file as well. The compress..

C# Base64 String to JPEG Image

I am trying to convert a Base64String to an image which needs to be saved locally. At the moment, my code is able to save the image but when I open the saved image, it says "Invalid Image". Code: ..

Java - Convert image to Base64

I'm having a problem while converting a gif image to a base 64 string. When I converts it, the code adds me like 100,000 AAAAAA whereas the image is really small! Here is my code: import java.io.Bu..

RegEx to parse or validate Base64 data

Is it possible to use a RegEx to validate, or sanitize Base64 data? That's the simple question, but the factors that drive this question are what make it difficult. I have a Base64 decoder that can ..

java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String() in Java EE application

I am developing a Java EE application in which I need Base64 Encoding/Decoding So I added commons-codec-1.5.jar in WEB-INF/lib folder of my application and used import org.apache.commons.codec.bina..

Conversion from byte array to base64 and back

I am trying to: Generate a byte array. Convert that byte array to base64 Convert that base64 string back to a byte array. I've tried out a few solutions, for example those in this question. Fo..

Convert base64 string to image

I am trying to crop/resize user profile image using jquery plugin namely crop.js which sends user image as base64 via ajax to my controller as $.ajax({ type: "post", dataType: "jso..

Is there a way to set background-image as a base64 encoded image?

I want to change background dynamically in JS and my set of images is in base64 encoded. I try: document.getElementById("bg_image").style.backgroundImage = "url('http://amigo.com/300107-2853.jpg'..

Encode a FileStream to base64 with c#

I know how to encode / decode a simple string to / from base64. But how would I do that if the data is already been written to a FileStream object. Let's say I have only access to the FileStream obj..

How to display Base64 images in HTML?

I'm having trouble displaying a Base64 image inline. Can someone point me in the right direction? <!DOCTYPE html> <html> <head> <title>Display Image</title> <..

How do I decode a base64 encoded string?

I am trying to "decode" this following Base64 string: OBFZDTcPCxlCKhdXCQ0kMQhKPh9uIgYIAQxALBtZAwUeOzcdcUEeW0dMO1kbPElWCV1ISFFKZ0kdWFlLAURPZhEFQVseXVtPOUUICVhMAzcfZ14AVEdIVVgfAUIBWVpOUlAeaUVMXFlKIy..

Encoding an image file with base64

I want to encode an image into a string using the base64 module. I've ran into a problem though. How do I specify the image I want to be encoded? I tried using the directory to the image, but that sim..

How to save a PNG image server-side, from a base64 data string

I'm using Nihilogic's "Canvas2Image" JavaScript tool to convert canvas drawings to PNG images. What I need now is to turn those base64 strings that this tool generates, into actual PNG files on the s..

How to check whether a string is Base64 encoded or not

I want to decode a Base64 encoded string, then store it in my database. If the input is not Base64 encoded, I need to throw an error. How can I check if a string is Base64 encoded?..

Binary Data in JSON String. Something better than Base64

The JSON format natively doesn't support binary data. The binary data has to be escaped so that it can be placed into a string element (i.e. zero or more Unicode chars in double quotes using backslash..

How to check for a valid Base64 encoded string

Is there a way in C# to see if a string is Base 64 encoded other than just trying to convert it and see if there is an error? I have code code like this: // Convert base64-encoded hash value into a ..

How to convert base64 string to image?

I'm converting an image to base64 string and sending it from android device to the server. Now, I need to change that string back to an image and save it in the database. Any help?..

Send a base64 image in HTML email

Using a rich-text editor, our users can drag and drop a saved image from their desktop to the editor. The image appears and displays properly in the web page after they submit. Since the image is not..

How to convert an Image to base64 string in java?

It may be a duplicate but i am facing some problem to convert the image into Base64 for sending it for Http Post. I have tried this code but it gave me wrong encoded string. public static void main(..

How to convert a Base64 string into a Bitmap image to show it in a ImageView?

I have a Base64 String that represents a BitMap image. I need to transform that String into a BitMap image again to use it on a ImageView in my Android app How to do it? This is the code that I use..

How to save a base64 image to user's disk using JavaScript?

I have converted the source content from the <img> html tag to a base64String using JavaScript. The image was displayed clearly. Now I want to save that image to user's disk using javascript. &..

C# Convert a Base64 -> byte[]

I have a Base64 byte[] array which is transferred from a stream which i need to convert it to a normal byte[] how to do this ?..

Storing image in database directly or as base64 data?

The common method to store images in a database is to convert the image to base64 data before storing the data. This process will increase the size by 33%. Alternatively it is possible to directly sto..

How to decode a Base64 string?

I have a normal string in Powershell that is from a text file containing Base64 text; it is stored in $x. I am trying to decode it as such: $z = [System.Text.Encoding]::Unicode.GetString([System.Conv..

convert base64 to image in javascript/jquery

I have written some code for image capturing using javascript/jquery Below is the code: function capture_image(){ alert("capture_image"); var p = webcam.capture(); webcam.save(); ..

Base64: java.lang.IllegalArgumentException: Illegal character

I'm trying to send a confirmation email after user registration. I'm using the JavaMail library for this purpose and the Java 8 Base64 util class. I'm encoding user emails in the following way: byte..

How can I convert an image into a Base64 string?

What is the code to transform an image (maximum of 200 KB) into a Base64 String? I need to know how to do it with Android, because I have to add the functionality to upload images to a remote se..

Decode Base64 data in Java

I have an image that is Base64 encoded. What is the best way to decode that in Java? Hopefully using only the libraries included with Sun Java 6...

How to encode text to base64 in python

I am trying to encode a text string to base64. i tried doing this : name = "your name" print('encoding %s in base64 yields = %s\n'%(name,name.encode('base64','strict'))) But this gives me the foll..

How to convert uint8 Array to base64 Encoded String?

I got a webSocket comunication, I recieve base64 encoded string, convert it to uint8 and work on it, but now I need to send back, I got the uint8 array, and need to convert it to base64 string, so I c..

Base64 decode snippet in C++

Is there a freely available Base64 decoding code snippet in C++?..

How do I base64 encode a string efficiently using Excel VBA?

I need to encode a 100KB+ string as base64 in VBA. Are there any built-in functions or COM objects available which will do this as a pure VBA approach is either complex or doesn't scale well at these ..

How to Resize a Bitmap in Android?

I have a bitmap taken of a Base64 String from my remote database, (encodedImage is the string representing the image with Base64): profileImage = (ImageView)findViewById(R.id.profileImage); byte[] i..

Android Bitmap to Base64 String

How do I convert a large Bitmap (photo taken with the phone's camera) to a Base64 String?..

Get image data url in JavaScript?

I have a regular HTML page with some images (just regular <img /> HTML tags). I'd like to get their content, base64 encoded preferably, without the need to redownload the image (ie. it's already..

ArrayBuffer to base64 encoded string

I need an efficient (read native) way to convert an ArrayBuffer to a base64 string which needs to be used on a multipart post. ..

Base 64 encode and decode example code

Does anyone know how to decode and encode a string in Base64 using the Base64. I am using the following code, but it's not working. String source = "password"; byte[] byteArray = source.getBytes("UT..

How to do Base64 encoding in node.js?

Does node.js have built-in base64 encoding yet? The reason why I ask this is that final() from crypto can only output hex, binary or ascii data. For example: var cipher = crypto.createCipheriv('des-..

Convert base64 png data to javascript file objects

I have two base64 encoded in PNG, and I need to compare them using Resemble.JS I think that the best way to do it is to convert the PNG's into file objects using fileReader. How can I do it?..

Python: Ignore 'Incorrect padding' error when base64 decoding

I have some data that is base64 encoded that I want to convert back to binary even if there is a padding error in it. If I use base64.decodestring(b64_string) it raises an 'Incorrect padding' erro..

How do I base64 encode (decode) in C?

I have binary data in an unsigned char variable. I need to convert them to PEM base64 in c. I looked in openssl library but i could not find any function. Does any body have any idea?..

Why do I need 'b' to encode a string with Base64?

Following this python example, I encode a string as Base64 with: >>> import base64 >>> encoded = base64.b64encode(b'data to be encoded') >>> encoded b'ZGF0YSB0byBiZSBlbmNvZ..

Why do we use Base64?

Wikipedia says Base64 encoding schemes are commonly used when there is a need to encode binary data that needs be stored and transferred over media that are designed to deal with textual data. Thi..

Decoding a Base64 string in Java

I'm trying to decode a simple Base64 string, but am unable to do so. I'm currently using the org.apache.commons.codec.binary.Base64 package. The test string I'm using is: abcdefg, encoded using PHP ..

Passing base64 encoded strings in URL

Is it safe to pass raw base64 encoded strings via GET parameters?..

base64 encode in MySQL

I want to select a blob col from one table, base64 encode it and insert it into another tables. Is there any way to do this without round tripping the data out of the DB and through my app?..

Base64 encoding and decoding in oracle

How can I do Base64 encode/decode a value in Oracle?..

How can I set Image source with base64

I want to set the Image source to a base64 source but it does not work: JSfiddle.net/NT9KB <img id="img" src="" /> the JavaScript document.getElementById("img").src = "data:image/png;base64..

Pdf.js: rendering a pdf file using a base64 file source instead of url

I'm trying to render a page from a pdf with pdf.js Normally, using a url, I can do this: PDFJS.getDocument("http://www.server.com/file.pdf").then(function getPdfHelloWorld(pdf) { // // Fetch the..

How to convert file to base64 in JavaScript?

UPD TypeScript version is also available in answers Now I'm getting File object by this line: file = document.querySelector('#files > input[type="file"]').files[0] I need to send this fi..

Convert UTF-8 to base64 string

I'm trying to convert UTF-8 to base64 string. Example: I have "abcdef==" in UTF-8. It's in fact a "representation" of a base64 string. How can I retrieve a "abcdef==" base64 string (note that I don..

Invalid length for a Base-64 char array

As the title says, I am getting: Invalid length for a Base-64 char array. I have read about this problem on here and it seems that the suggestion is to store ViewState in SQL if it is large...

How can I encode a string to Base64 in Swift?

I want to convert a string to Base64. I found answers in several places, but it does not work anymore in Swift. I am using Xcode 6.2. I believe the answer might be work in previous Xcode versions and ..

How to get base64 encoded data from html image

I have a registration form where users can choose an avatar. They have 2 possibilities: Choose a default avatar Upload their own avatar In my HTML page I have this. <img id="preview" src="img/..

Convert base64 string to ArrayBuffer

I need to convert a base64 encode string into an ArrayBuffer. The base64 strings are user input, they will be copy and pasted from an email, so they're not there when the page is loaded. I would like ..

Can we convert a byte array into an InputStream in Java?

Can we convert a byte array into an InputStream in Java? I have been looking on the internet but couldn't find it. I have a method that has an InputStream as argument. The InputStream cph I have is ..

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

Base64 Java encode and decode a string

I want to encode a string into base64 and transfer it through a socket and decode it back. But after decoding it gives different answer. Following is my code and result is "77+9x6s=" import javax..

what does this mean ? image/png;base64?

I don't know what we call this. but i found a image at google 404 url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKsAAADVCAMAAAAfHvCaAAAAGFBMVEVYn%2BH%2F%2F%2F%2Bex%2B3U5vd7s%2Bfq8%2Fs0itq72PMLUP..

Base64 encoding in SQL Server 2005 T-SQL

I'd like to write a T-SQL query where I encode a string as a Base64 string. Surprisingly, I can't find any native T-SQL functions for doing Base64 encoding. Does a native function exist? If not, wh..

The input is not a valid Base-64 string as it contains a non-base 64 character

I have a REST service that reads a file and sends it to another console application after converting it to Byte array and then to Base64 string. This part works, but when the same stream is received a..

Save base64 string as PDF at client side with JavaScript

So here my problem: I have a pdf file as a base64 String that i am getting from the server. I would like to use this string to either display the PDF directly to the browser or give it a option of "Sa..

Base64 encoding and decoding in client-side Javascript

Are there any methods in JavaScript that could be used to encode and decode a string using base64 encoding?..

Get Base64 encode file-data from Input Form

I've got a basic HTML form from which I can grab a bit of information that I'm examining in Firebug. My only issues is that I'm trying to base64 encode the file data before it's sent to the server whe..

How to base64 encode image in linux bash / shell

I'm trying to base64 encode an image in a shell script and put it into variable: test="$(printf DSC_0251.JPG | base64)" echo $test RFNDXzAyNTEuSlBH I've also tried something like this: test=\`echo..

NodeJS: How to decode base64 encoded string back to binary?

I was implementing password hashing with salt, so I generated salt as binary, hashed the password, base64 encoded the password and salt then stored them into database. Now when I am checking password..

Write Base64-encoded image to file

How to write a Base64-encoded image to file? I have encoded an image to a string using Base64. First, I read the file, then convert it to a byte array and then apply Base64 encoding to convert the im..

How do I do base64 encoding on iOS?

I'd like to do base64 encoding and decoding, but I could not find any support from the iPhone SDK. How can I do base64 encoding and decoding with or without a library?..

Secure random token in Node.js

In this question Erik needs to generate a secure random token in Node.js. There's the method crypto.randomBytes that generates a random Buffer. However, the base64 encoding in node is not url-safe, it..

Get data from file input in JQuery

I actually have a file input and I would like to retrieve the Base64 data of the file. I tried: $('input#myInput')[0].files[0] to retrieve the data. But it only provides the name, the length, the..

How do I encode and decode a base64 string?

How do I return a base64 encoded string given a string? How do I decode a base64 encoded string into a string? ..

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

Creating a BLOB from a Base64 string in JavaScript

I have Base64-encoded binary data in a string: const contentType = 'image/png'; const b64Data = 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAA..

Is embedding background image data into CSS as Base64 good or bad practice?

I was looking at the source of a greasemonkey userscript and noticed the following in their css: .even { background: #fff url(data:image/gif;base64,R0lGODlhBgASALMAAOfn5+rq6uvr6+zs7O7u7vHx8fPz8/b29vj..

Encoding as Base64 in Java

I need to encode some data in the Base64 encoding in Java. How do I do that? What is the name of the class that provides a Base64 encoder? I tried to use the sun.misc.BASE64Encoder class, without s..

What is the effect of encoding an image in base64?

If I convert an image (jpg or png) to base64, then will it be bigger, or will it have the same size? How much greater will it be? Is it recommended to use base64 encoded images on my website?..

Image convert to Base64

<input type="file" id="asd"/> I would like to get the image in base64 once the user chose that (before submitting the form) Something like : $(input).on('change',function(){ var data = $(t..

Why does a base64 encoded string have an = sign at the end

I know what base64 encoding is and how to calculate base64 encoding in C#, however I have seen several times that when I convert a string into base64, there is an = at the end. A few questions came u..

Converting file into Base64String and back again

The title says it all: I read in a tar.gz archive like so break the file into an array of bytes Convert those bytes into a Base64 string Convert that Base64 string back into an array of bytes Write..

Embedding Base64 Images

Purely out of curiosity, which browsers does Base64 image embedding work in? What I'm referring to is this. I realize it's not usually a good solution for most things, as it increases the page size q..

How to convert an image to base64 encoding?

Can you please guide me how can I convert an image from a URL to base64 encoding?..

Base64 length calculation?

After reading the base64 wiki ... I'm trying to figure out how's the formula working : Given a string with length of n , the base64 length will be Which is : 4*Math.Ceiling(((double)s.Length/3)..

What is base 64 encoding used for?

I've heard people talking about "base 64 encoding" here and there. What is it used for?..

converting a base 64 string to an image and saving it

Here is my code: protected void SaveMyImage_Click(object sender, EventArgs e) { string imageUrl = Hidden1.Value; string saveLocation = Server.MapPath("~/PictureUploads..

How to create a String with carriage returns?

For a JUnit test I need a String which consists of multiple lines. But all I get is a single lined String. I tried the following: String str = ";;;;;;\n" + "Name, number, address..

Python creating a dictionary of lists

I want to create a dictionary whose values are lists. For example: { 1: ['1'], 2: ['1','2'], 3: ['2'] } If I do: d = dict() a = ['1', '2'] for i in a: for j in range(int(i), int(i) + 2..

Access-Control-Allow-Origin and Angular.js $http

Whenever I make a webapp and I get a CORS problem, I start making coffee. After screwing with it for a while I manage to get it working but this time it's not and I need help. Here is the client side..

Cannot ping AWS EC2 instance

I have an EC2 instance running in AWS. When I try to ping from my local box it is not available. How can I make the instance pingable?..

Tkinter: How to use threads to preventing main event loop from "freezing"

I have a small GUI test with a "Start" button and a Progress bar. The desired behavior is: Click Start Progressbar oscillates for 5 seconds Progressbar stops The observed behavior is the "Start" b..

Tried to Load Angular More Than Once

I have a yeoman scaffolded app (the angular fullstack generator). grunt serve works fine, but grunt build produces a distribution that locks up memory, most probably because of circular references i..

Oracle: SQL select date with timestamp

I have the following data: SQL> select * from booking_session; BK_ID|BK_DATE -----|------------------------- 1|18-MAR-12 10.00.00.000000 2|18-MAR-12 10.25.00.000000 3|18-MAR-12 10.30...

How to get all elements by class name?

How to get all elements by class name on pure javascript ? Analog $('.class') in Jquery ?..

How to set maximum height for table-cell?

I got a table-cell with fixed width and height and if text is too large, cell size should remain the same and text should be hidden by overflow:hidden. div { display: table-cell height: 100px; ..

How can I change cols of textarea in twitter-bootstrap?

If I change the value of :rows, it works. But it stays at the default cols whatever value I set with ':cols =>'. Column width won't change. I viewed the html source and it reflected the change. I won..

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

Is it possible to get a history of queries made in postgres

Is it possible to get a history of queries made in postgres? and is it be possible to get the time it took for each query? I'm currently trying to identify slow queries in the application I'm working ..

How to install sshpass on mac?

I would like to automate ssh login from my mac. It does have a simple solution: sshpass -p my_password ssh m_username@hostname but my problem is installing sshpass on my mac. ..

Permission denied on accessing host directory in Docker

Summary I am trying to mount a host directory in Docker, but then I can not access it from within the container, even if the access permissions look good. Details I am doing sudo docker run -i -v /dat..

Laravel assets url

I have installed Laravel and began trying to write an app. I made some directories for my assets in the same directory as /app. But when I try to visit an image in my localhost for example: http://lo..

Stopping an Android app from console

Is it possible to stop an Android app from the console? Something like: adb stop com.my.app.package It would speed up our testing process so much. Right now we uninstall/install the app each time t..

Transform only one axis to log10 scale with ggplot2

I have the following problem: I would like to visualize a discrete and a continuous variable on a boxplot in which the latter has a few extreme high values. This makes the boxplot meaningless (the poi..

how to query LIST using linq

Suppose if I add person class instance to list and then I need to query the list using linq. List lst=new List(); lst.add(new person{ID=1,Name="jhon",salary=2500}); lst.add(new person{ID=2,Name="Sena..

How to make full screen background in a web page

How to make an image as background for web page, regardless of the screen size displaying this web page? I want to display it properly. How?..

Remove HTML Tags from an NSString on the iPhone

There are a couple of different ways to remove HTML tags from an NSString in Cocoa. One way is to render the string into an NSAttributedString and then grab the rendered text. Another way is to use ..

How to evaluate a boolean variable in an if block in bash?

I have defined the following variable: myVar=true now I'd like to run something along the lines of this: if [ myVar ] then echo "true" else echo "false" fi The above code does work, but ..

How do I change the title of the "back" button on a Navigation Bar

Currently the left bar button default value is the title of the view that loaded the current one, in other words the view to be shown when the button is pressed (back button). I want to change the te..

Error:Execution failed for task ':app:transformClassesWithDexForDebug' in android studio

I am moving my projects from eclipse to Android Studio. While running one of my app I get the following error. Not able to find any solution. I have enabled multidex as well. Error:Execution faile..

How to line-break from css, without using <br />?

output: hello How are you code: <p>hello <br> How are you </p> How to achieve same output without <br>?..

How do I "shake" an Android device within the Android emulator to bring up the dev menu to debug my React Native app

I am working on a cross-platform React Native mobile app. I am writing console.log statements as I develop. I want to see these logging statements in Chrome while I'm running the Android app in the de..

Only get hash value using md5sum (without filename)

I use md5sum to generate a hash value for a file. But i only need to receive the hash value, not the file name. md5=`md5sum ${my_iso_file}` echo ${md5} 3abb17b66815bc7946cefe727737d295 ./iso/somef..

Can't import Numpy in Python

I'm trying to write some code that uses Numpy. However, I can't import it: Python 2.6.2 (r262, May 15 2009, 10:22:27) [GCC 3.4.2] on linux2 Type "help", "copyright", "credits" or "license" for more..

Create Windows service from executable

Is there any quick way to, given an executable file, create a Windows service that, when started, launches it?..

How to randomly pick an element from an array

I am looking for solution to pick number randomly from an integer array. For example I have an array new int[]{1,2,3}, how can I pick a number randomly?..

How to add headers to a multicolumn listbox in an Excel userform using VBA

Is it possible to set up the headers in a multicolumn listbox without using a worksheet range as the source? The following uses an array of variants which is assigned to the list property of the list..

How to get the insert ID in JDBC?

I want to INSERT a record in a database (which is Microsoft SQL Server in my case) using JDBC in Java. At the same time, I want to obtain the insert ID. How can I achieve this using JDBC API?..

Check If only numeric values were entered in input. (jQuery)

I would like to check if users enter correct phone number in, with help of jQuery, so far I got to this stage: var phone = $("input#phone").val(); if (phone !== "") { //Check if phone is numeric ..

Django error - matching query does not exist

I finally released my project to the production level and suddenly I have some issues I never had to deal with in the development phase. When the users posts some actions, I sometimes get the followi..

how to execute php code within javascript

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

How to import a bak file into SQL Server Express

I have a .bak file, and I want to use this file to recreate the database in a fresh install of SQL Server 2008 Management Studio. Can someone point me in the right direction on how this can be done? ..

How to use putExtra() and getExtra() for string data

Can someone please tell me how exactly to use getExtra() and putExtra() for intents? Actually I have a string variable, say str, which stores some string data. Now, I want to send this data from one a..

Nodejs convert string into UTF-8

From my DB im getting the following string: Johan Öbert What it should say is: Johan Öbert I've tried to convert it into utf-8 like so: nameString.toString("utf8"); But still same proble..

How do I check if a Socket is currently connected in Java?

I'm trying to find out whether a Java TCP Socket is currently connected, the following just seems to tell me whether the socket has been connected at some point - not whether it is currently still con..

Fixed size div?

I want a normal div for the body of my text and a bunch of little divs that are exactly 150px by 150px. How might i do this?..

Read a text file in R line by line

I would like to read a text file in R, line by line, using a for loop and with the length of the file. The problem is that it only prints character(0). This is the code: fileName="up_down.txt" con=fi..

Retain precision with double in Java

public class doublePrecision { public static void main(String[] args) { double total = 0; total += 5.6; total += 5.8; System.out.println(total); } } The abov..

Find the item with maximum occurrences in a list

In Python, I have a list: L = [1, 2, 45, 55, 5, 4, 4, 4, 4, 4, 4, 5456, 56, 6, 7, 67] I want to identify the item that occurred the highest number of times. I am able to solve it but I need the f..

What is the !! (not not) operator in JavaScript?

I saw some code that seems to use an operator I don't recognize, in the form of two exclamation points, like so: !!. Can someone please tell me what this operator does? The context in which I saw thi..

How to select a directory and store the location using tkinter in Python

I am creating a GUI with a browse button which I only want to return the path. I've been looking at solutions using code like below. Tkinter.Button(subframe, text = "Browse", command = self.loadtemp..

How to empty a char array?

Have an array of chars like char members[255]. How can I empty it completely without using a loop? char members[255]; By "empty" I mean that if it had some values stored in it then it should not. F..

Is it possible to insert HTML content in XML document?

I need to insert HTML content into an XML document, is this possible or should HTML content be, for example, encoded in BASE64 or with something else like that?..

What's the best way to override a user agent CSS stylesheet rule that gives unordered-lists a 1em margin?

I'm working on a web app that has a topBar similar to facebook's blue bar at the top. I have an unordered list within the div of that bar to list some items, like Inbox, Notifications, etc. The UL ha..

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

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

php exec() is not executing the command

I have tried to use exec() with 'whoami' to check if it works and I got the result of nt authority\system Now I need to run a .exe file with parameters from php via exec() function. I tried this..

What is the difference between HTML tags and elements?

I notice that most people use the words HTML tags and HTML elements interchangeably. But what is the difference between them? The way I see it is that tags are in the source code and elements are ..

Setting environment variables on OS X

What is the proper way to modify environment variables like PATH in OS X? I've looked on Google a little bit and found three different files to edit: /etc/paths ~/.profile ~/.tcshrc I don't ..

Convert integer to string Jinja

I have an integer {% set curYear = 2013 %} In {% if %} statement I have to compare it with some string. I can't set curYear to string at the beginning because I have to decrement it in loop. How c..

How to check if a JavaScript variable is NOT undefined?

Things I’ve tried that don’t seem to work: if(lastName != "undefined") if(lastName != undefined) if(undefined != lastName) ..

Regular Expression Match to test for a valid year

Given a value I want to validate it to check if it is a valid year. My criteria is simple where the value should be an integer with 4 characters. I know this is not the best solution as it will not al..

Split string to equal length substrings in Java

How to split the string "Thequickbrownfoxjumps" to substrings of equal size in Java. Eg. "Thequickbrownfoxjumps" of 4 equal size should give the output. ["Theq","uick","brow","nfox","jump","s"] Sim..

Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

I opened an existing iOS project with Xcode6 beta6, and Xcode lists the following warning for both Storyboard and Xib files: Automatic Preferred Max Layout Width is not available on iOS versions ..

How can I delete an item from an array in VB.NET?

How can I delete an item from an array in VB.NET?..

Differences between "java -cp" and "java -jar"?

What is the difference between running a Java application withjava -cp CLASSPATH and java -jar JAR_FILE_PATH? Is one of them preferred to the other for running a Java application? I mean which one of ..

Error 415 Unsupported Media Type: POST not reaching REST if JSON, but it does if XML

I am actually new to REST WS but really I don't get this 415 Unsupported Media Type. I am testing my REST with Poster on Firefox and the GET works fine for me, also the POST (when it's a application..

Clear icon inside input text

Is there a quick way to create an input text element with an icon on the right to clear the input element itself (like the google search box)? I looked around but I only found how to put an icon as b..

MySQL select all rows from last month until (now() - 1 month), for comparative purposes

I need some help writing a MySQL query to show me rows from last month, but not the whole month, only up and until the same day, hour and minute as it is now(), but 1 month before. So for example, if..

Accessing the web page's HTTP Headers in JavaScript

How do I access a page's HTTP response headers via JavaScript? Related to this question, which was modified to ask about accessing two specific HTTP headers. Related: How do I access the HTTP r..

matplotlib: how to change data points color based on some variable

I have 2 variables (x,y) that change with time (t). I want to plot x vs. t and color the ticks based on the value of y. e.g. for highest values of y the tick color is dark green, for lowest value is d..

Command line tool to dump Windows DLL version?

I need a command line tool to dump standard Windows DLL version info so I can process it by means of a bash script (Cygwin). As a Java developer I am not very used to Microsoft development tools (tho..

d3 add text to circle

I am trying to add some text into circle. I have been following example from a mbostock tutorial, but wasn't able to get the right output. The code snippet is: var data; var code; d3.json("/json/tr..

"The given path's format is not supported."

I have the following code in my web service: string str_uploadpath = Server.MapPath("/UploadBucket/Raw/"); FileStream objfilestream = new FileStream(str_uploadpath + fileName, FileMod..

CORS header 'Access-Control-Allow-Origin' missing

I'm calling this function from my asp.net form and getting following error on firebug console while calling ajax. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote ..

How to search a string in a single column (A) in excel using VBA

I want to change these lines in my excel VBA code to something much faster, instead of looping through all the rows, i did saw examples but could not understand them as i am not a VBA user. When I us..

Error in plot.new() : figure margins too large in R

I'm new to R but I've made numerous correlation plots with smaller data sets. However, when I try to plot a large dataset (2gb+), I can produce the plot just fine, but the legend doesn't show up. Any ..

Returning data from Axios API

I am trying to use a Node.JS application to make and receive API requests. It does a get request to another server using Axios with data it receives from an API call it receives. The second snippet is..

How do I update all my CPAN modules to their latest versions?

How do I update all my CPAN modules to their latest versions?..

Is there a CSS parent selector?

How do I select the <li> element that is a direct parent of the anchor element? As an example, my CSS would be something like this: li < a.active { property: value; } Obviously there ..

Array of arrays (Python/NumPy)

I am using Python/NumPy, and I have two arrays like the following: array1 = [1 2 3] array2 = [4 5 6] And I would like to create a new array: array3 = [[1 2 3], [4 5 6]] and append items to it. S..

Using gdb to single-step assembly code outside specified executable causes error "cannot find bounds of current function"

I'm outside gdb's target executable and I don't even have a stack that corresponds to that target. I want to single-step anyway, so that I can verify what's going on in my assembly code, because I'm ..

Where do I configure log4j in a JUnit test class?

Looking at the last JUnit test case I wrote, I called log4j's BasicConfigurator.configure() method inside the class constructor. That worked fine for running just that single class from Eclipse's "ru..

Hex-encoded String to Byte Array

String str = "9B7D2C34A366BF890C730641E6CECF6F"; I want to convert str into byte array, but str.getBytes() returns 32 bytes instead of 16. ..

Is there a foreach loop in Go?

Is there a foreach construct in the Go language? Can I iterate over a slice or array using a for?..

Find first element in a sequence that matches a predicate

I want an idiomatic way to find the first element in a list that matches a predicate. The current code is quite ugly: [x for x in seq if predicate(x)][0] I've thought about changing it to: from i..

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

Add vertical whitespace using Twitter Bootstrap?

What's the best way to add vertical whitespace using Twitter's Bootstrap? For example, let's say that I am creating a landing page and would like a bit (100px) of blank whitespace above and below a ..

Get keys of a Typescript interface as array of strings

I've a lot of tables in Lovefield and their respective Interfaces for what columns they have. Example: export interface IMyTable { id: number; title: string; createdAt: Date; isDeleted: boolea..

List directory tree structure in python?

I know that we can use os.walk() to list all sub-directories or all files in a directory. However, I would like to list the full directory tree content: - Subdirectory 1: - file11 - file12 -..

How do I convert a javascript object array to a string array of the object attribute I want?

Possible Duplicate: Accessing properties of an array of objects Given: [{ 'id':1, 'name':'john' },{ 'id':2, 'name':'jane' }........,{ 'id':2000, 'name':'zack' }] W..

When to use StringBuilder in Java

It is supposed to be generally preferable to use a StringBuilder for string concatenation in Java. Is this always the case? What I mean is this: Is the overhead of creating a StringBuilder object, ca..

Convert array to JSON string in swift

How do you convert an array to a JSON string in swift? Basically I have a textfield with a button embedded in it. When button is pressed, the textfield text is added unto the testArray. Furthermore, I..

How can I exit from a javascript function?

I have the following: function refreshGrid(entity) { var store = window.localStorage; var partitionKey; ... ... I would like to exit from this function if an "if" condition is met. ..

Append a dictionary to a dictionary

I have two existing dictionaries, and I wish to 'append' one of them to the other. By that I mean that the key,values of the other dictionary should be made into the first dictionary. For example: or..

Recursive file search using PowerShell

I am searching for a file in all the folders. Copyforbuild.bat is available in many places, and I would like to search recursively. $File = "V:\Myfolder\**\*.CopyForbuild.bat" How can I do it in P..

Can I pass a JavaScript variable to another browser window?

I have a page which spawns a popup browser window. I have a JavaScript variable in the parent browser window and I would like to pass it to the popped-up browser window. Is there a way to do this? I ..

Android: Scale a Drawable or background image?

On a layout I want to scale the background image (keeping its aspect ratio) to the space allocated when the page gets created. Does anyone have an idea how to do this? I am using layout.setBackground..

Running Python code in Vim

I am writing Python code using Vim, and every time I want to run my code, I type this inside Vim: :w !python This gets frustrating, so I was looking for a quicker method to run Python code inside V..

Get all parameters from JSP page

I have n number of text fields named in the form "Question.....". How can I get all the parameters which starts with "question" from the JSP page to the Action?..

Where does linux store my syslog?

I wrote a simple test application to log something in a log file. I am using linux mint and after the application executes I try to view the log using this command: tail -n 100 /var/log/messages b..

CSS full screen div with text in the middle

I have a css class defined so I can make a div to use all the browser's viewport, the rule is the following: .fullscreenDiv { background-color: #e8e8e8; width: 100%; height: auto; bot..

Microsoft Advertising SDK doesn't deliverer ads

So I have a Windows Phone solution that has an ad in it. When my Solution References Microsoft.Advertising.SDK Advertising.Mobile Advertising.Mobile.UI Everything works fine and I get ads. Unfortu..

Server http:/localhost:8080 requires a user name and a password. The server says: XDB

I am trying to access localhost:8080 but it is showing me I need to enter user name and pass word. I remember messing up with the server some 4 months ago while I was trying to develop a web applicati..

Reading JSON POST using PHP

I looked around a lot before posting this question so my apologies if it is on another post and this is only my second quesiton on here so apologies if I don't format this question correctly. I have ..

iPhone - Get Position of UIView within entire UIWindow

The position of a UIView can obviously be determined by view.center or view.frame etc. but this only returns the position of the UIView in relation to it's immediate superview. I need to determine th..

Where are Magento's log files located?

I am new to Magento. I can't find log files in Magento. I googled it, but the Magento Commerce site returns closed and some other sites explain how to create custom log files. I want to know the locat..

Safely casting long to int in Java

What's the most idiomatic way in Java to verify that a cast from long to int does not lose any information? This is my current implementation: public static int safeLongToInt(long l) { int i = (..

"Uncaught (in promise) undefined" error when using with=location in Facebook Graph API query

I am currently developing a web application with the Facebook Graph API. My current goal is to retrieve only posts which have a location attached. While retrieving posts with and without location is..

Bad operand type for unary +: 'str'

I cannot figure out a problem I am having with code written in Python 2.7. I am converting the references to ints, but I keep getting a type exception bad operand type for unary +: 'str'. Can anyone a..

Specifying Font and Size in HTML table

I am trying to specify the Font Face and Size for text in a table. It seems to respect the FACE= but ignores the SIZE=. For example, I have the HTML shown below. It correctly displays the text in Co..

MySQL case sensitive query

This has been asked on this site before but I couldn't find a sufficient answer. If I'm doing a query like: Select Seller from Table where Location = 'San Jose' How can I make it return only Seller..

How to work offline with TFS

Our TFS server has some temporary connectivity issues right now, and as such VS has gone unresponsive, leaving 50+ developers unable to work! Is it possible to switch TFS into an offline mode in the ..

Is there any way to wait for AJAX response and halt execution?

Here is some code I'd like to execute. I'd like to wait for AJAX response so I can return something from the server. Any way to achieve this? function functABC(){ $.ajax({ url: 'myPage.ph..

Authentication issue when debugging in VS2013 - iis express

I'm trying to pick up the windows username when debugging in Visual Studio 2013. I am simply using: httpcontext.current.user.identity.name If I run this on my Dev Server it works fine, if I run it ..

How to dynamic filter options of <select > with jQuery?

<select > <option value="something">something</option> <option value="something_else">something else</option> </select> <input type="text" > So that when us..

How to import a module in Python with importlib.import_module

I'm trying to use importlib.import_module in Python 2.7.2 and run into the strange error. Consider the following dir structure: a | + - __init__.py - b | + - __ini..

Difference between <input type='submit' /> and <button type='submit'>text</button>

There are many legends about them. I want to know the truth. What are the differences between the two following examples? <input type='submit' value='text' /> <button type='submit'>text&..

How to read and write excel file

I want to read and write an Excel file from Java with 3 columns and N rows, printing one string in each cell. Can anyone give me simple code snippet for this? Do I need to use any external lib or doe..

How to access session variables from any class in ASP.NET?

I have created a class file in the App_Code folder in my application. I have a session variable Session["loginId"] I want to access this session variables in my class, but when I am writing the fo..

Angular 2: How to write a for loop, not a foreach loop

Using Angular 2, I want to duplicate a line in a template multiple times. Iterating over an object is easy, *ngFor="let object of objects". However, I want to run a simple for loop, not a fo..

Can I store images in MySQL

Possible Duplicates: Images in MySQL Storing images in MySQL I'm trying to develop a website where users upload their images as part of registration. I want it that for each image, there ..

how to store Image as blob in Sqlite & how to retrieve it?

I want to store an image(from url) into a sqlite database. For that I use: db = new DataBase(getApplicationContext()); URL url = new URL("http://sree.cc/wp-content/uploads/schogini_team.png"); URLC..

When to use the !important property in CSS

Consider: #div p { color: red !important; } ... #div p { color: blue; } I understand how !important works. In this case the div will render red because now it has priority (!important). But..

How do I extract a substring from a string until the second space is encountered?

I have a string like this: "o1 1232.5467 1232.5467 1232.5467 1232.5467 1232.5467 1232.5467" How do I extract only "o1 1232.5467"? The number of characters to be extracted are not the same always. H..

How do I clear my local working directory in Git?

How can I clear my working directory in Git?..

Days between two dates?

What's the shortest way to see how many full days have passed between two dates? Here's what I'm doing now. math.floor((b - a).total_seconds()/float(86400)) ..

SQL - How to find the highest number in a column?

Let's say I have the following data in the Customers table: (nothing more) ID FirstName LastName ------------------------------- 20 John Mackenzie 21 Ted Green 22 Marcy ..

How to randomize Excel rows

How can I randomize lots of rows in Excel? For example I have an excel sheet with data in 3 rows. 1 A dataA 2 B dataB 3 C dataC I want to randomize the row order. For example 2 B dataB 1 A dataA ..

How to install PyQt4 in anaconda?

From the PyQt4 website their instructions for installing the package are to download the tarball and use the config file. I have two versions of Python, one is my normal system and the other is within..

z-index not working with position absolute

I opened the console (chrome\firefox) and ran the following lines: $("body").append("<div id=\"popupFrame\" style=\"width:100%;height:100%;background-color:black;opacity:0.5;position:absolute;top:..

Before and After Suite execution hook in jUnit 4.x

I'm trying to preform setup and teardown for a set of integration tests, using jUnit 4.4 to execute the tests. The teardown needs to be run reliably. I'm having other problems with TestNG, so I'm look..

How to determine CPU and memory consumption from inside a process?

I once had the task of determining the following performance parameters from inside a running application: Total virtual memory available Virtual memory currently used Virtual memory currently used ..

Decimal number regular expression, where digit after decimal is optional

I need a regular expression that validates a number, but doesn't require a digit after the decimal. ie. 123 123. 123.4 would all be valid 123.. would be invalid Any would be greatly appreciated..

How to launch a Google Chrome Tab with specific URL using C#

Is there a way I can launch a tab (not a new Window) in Google Chrome with a specific URL loaded into it from a custom app? My application is coded in C# (.NET 4 Full). I'm performing some actions v..

What is the difference between XML and XSD?

What is the difference between Extensible Markup Language (XML) and XML Schema (XSD)?..

How to get the indices list of all NaN value in numpy array?

Say now I have a numpy array which is defined as, [[1,2,3,4], [2,3,NaN,5], [NaN,5,2,3]] Now I want to have a list that contains all the indices of the missing values, which is [(1,2),(2,0)] at this..

How to check object is nil or not in swift?

Suppose I have String like : var abc : NSString = "ABC" and I want to check that it is nil or not and for that I try : if abc == nil{ //TODO: } But this is not working and giving m..

How to run Conda?

I installed Anaconda and can run Python, so I assume that I installed it correctly. Following this introductory documentation, I am trying to install Python v3.3, so I am copying and pasting the follo..

How to convert a normal Git repository to a bare one?

How can I convert a 'normal' Git repository to a bare one? The main difference seems to be: in the normal Git repository, you have a .git folder inside the repository containing all relevant data a..

Populating VBA dynamic arrays

The following code gives me error 9 "subscript out of range". I meant to declare a dynamic array so that the dimension changes as I add elements to it. Do I have to create a "spot" on the array before..

Git Push Error: insufficient permission for adding an object to repository database

When I try to push to a shared git remote, I get the following error: insufficient permission for adding an object to repository database Then I read about a fix here: Fix This worked for the next p..

How do I set up DNS for an apex domain (no www) pointing to a Heroku app?

I already added a custom domain to my Heroku app and it works with www.domain.com. I need to know how to set up the domain without www to resolve to the app, too. Here are my current DNS settings: ..

What is the difference between cssSelector & Xpath and which is better with respect to performance for cross browser testing?

I am working with the Selenium WebDriver 2.25.0 on multilingual web application & mainly test the page content (For different languages like Arabic, English, Russian & so on). For my applicat..

Why is it not advisable to have the database and web server on the same machine?

Listening to Scott Hanselman's interview with the Stack Overflow team (part 1 and 2), he was adamant that the SQL server and application server should be on separate machines. Is this just to make su..

Difference between CLOCK_REALTIME and CLOCK_MONOTONIC?

Could you explain the difference between CLOCK_REALTIME and CLOCK_MONOTONIC clocks returned by clock_gettime() on Linux? Which is a better choice if I need to compute elapsed time between timestamps ..

How to print all key and values from HashMap in Android?

I am very new for Android development, and I am trying to use HashMap in Android sample project. Now, am doing sample project for learn android. I just store keys and values in HashMap, i want to show..

How to update a plot in matplotlib?

I'm having issues with redrawing the figure here. I allow the user to specify the units in the time scale (x-axis) and then I recalculate and call this function plots(). I want the plot to simply upda..

npm - how to show the latest version of a package

How do I use npm to show the latest version of a module? I am expecting something like npm --latest express to print out v3.0.0...

How can I change image source on click with jQuery?

I 'm currently building a full background image layout and I want to change the image based on which page the user is visiting. To get to the point: I need to change a images attribute when the user c..

Java Reflection Performance

Does creating an object using reflection rather than calling the class constructor result in any significant performance differences?..

What is the correct way to start a mongod service on linux / OS X?

I've installed mongodb and have been able to run it, work with it, do simple DB read / write type stuff. Now I'm trying to set up my Mac to run mongod as a service. I get "Command not found" in resp..

Use basic authentication with jQuery and Ajax

I am trying to create a basic authentication through the browser, but I can't really get there. If this script won't be here the browser authentication will take over, but I want to tell the browser ..

How can I create numbered map markers in Google Maps V3?

I'm working on a map that has multiple markers on it. These markers use a custom icon, but I'd also like to add numbers on top. I've seen how this has been accomplished using older versions of the AP..

Replace HTML page with contents retrieved via AJAX

I have an HTML page with a typical structure: <html> <head> <script src="..." ></script> <style>...</style> </head> <body> content <..

How to get DataGridView cell value in messagebox?

How can I get DataGridView cell value to be written in the MessageBox in C#?..

Can you autoplay HTML5 videos on the iPad?

The <video> tags autoplay="autoplay" attribute works fine in Safari. When testing on an iPad, the video must be activated manually. I thought it was a loading issue, so I ran a loop checking f..

SQL Server 2008 - IF NOT EXISTS INSERT ELSE UPDATE

I apologize, but this is kind of a two part question. I'm extremely new to SQL and am trying to develop a time clock application for the small office that I work in. I'm playing around with the SQL b..

What is "X-Content-Type-Options=nosniff"?

I am doing some penetration testing on my localhost with OWASP ZAP, and it keeps reporting this message: The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff' This c..

React img tag issue with url and class

I have the following simple react code in my JSX file: /** @jsx React.DOM */ var Hello = React.createClass({ render: function() { return <div><img src='http://placehold.it/400x2..

Comparing Java enum members: == or equals()?

I know that Java enums are compiled to classes with private constructors and a bunch of public static members. When comparing two members of a given enum, I've always used .equals(), e.g. public useE..

Returning from a void function

Which is more correct way to return from function: void function() { // blah some code } OR void function() { // blah some code return; } Rationale for second way: It expresses develop..

JQuery Ajax Post results in 500 Internal Server Error

I am trying to perform this AJAX post but for some reason I am getting a server 500 error. I can see it hit break points in the controller. So the problem seems to be on the callback. Anyone? $.ajax(..

Call method in directive controller from other controller

I have a directive that has its own controller. See the below code: var popdown = angular.module('xModules',[]); popdown.directive('popdown', function () { var PopdownController = function ($sco..

How can I get the current user's username in Bash?

I am writing a program in Bash that needs to get the user's username. I have heard of a thing called whoami, but I have no idea what it does or how to use it. What command do I use to get the curren..

How to open a URL in a new Tab using JavaScript or jQuery?

How to open a URL in new tab instead of new window programatically?..

What svn command would list all the files modified on a branch?

In svn, I have a branch which was created, say at revision 22334. Commits were then made on the branch. How do I get a list of all files that were changed on the branch compared to what's on the trun..

C++ Best way to get integer division and remainder

I am just wondering, if I want to divide a by b, and am interested both in the result c and the remainder (e.g. say I have number of seconds and want to split that into minutes and seconds), what is t..

jQuery validate Uncaught TypeError: Cannot read property 'nodeName' of null

I have the following code: $(document).ready ( function () { $.validator.addMethod( "lessThan", function (value, element, param) { // bind to the b..

Passing properties by reference in C#

I'm trying to do do the following: GetString( inputString, ref Client.WorkPhone) private void GetString(string inValue, ref string outValue) { if (!string.IsNullOrEmpty(inValue)) { ..

Creating a ZIP archive in memory using System.IO.Compression

I'm trying to create a ZIP archive with a simple demo text file using a MemoryStream as follows: using (var memoryStream = new MemoryStream()) using (var archive = new ZipArchive(memoryStream , ZipAr..

typeof operator in C

Is typeof in C, really an operator? I'm thinking because there is no polymorphism in C, that there is nothing to do at run-time. That is, the answer to typeof is known at compile-time. (I can't thin..

Java Enum Methods - return opposite direction enum

I would like to declare an enum Direction, that has a method that returns the opposite direction (the following is not syntactically correct, i.e, enums cannot be instantiated, but it illustrates my p..

Something like 'contains any' for Java set?

I have two sets, A and B, of the same type. I have to find if A contains any element from the set B. What would be the best way to do that without iterating over the sets? The Set library has contai..

u'\ufeff' in Python string

I got an error with the following exception message: UnicodeEncodeError: 'ascii' codec can't encode character u'\ufeff' in position 155: ordinal not in range(128) Not sure what u'\ufeff' is, it shows..

Programmatically register a broadcast receiver

I'd like to know what is the best practice/way of programmatically register a broadcast receiver. I want to register specific receivers according to user choice. As the registration is done through t..

Build .so file from .c file using gcc command line

I'm trying to create a hello world project for Linux dynamic libraries (.so files). So I have a file hello.c: #include <stdio.h> void hello() { printf("Hello world!\n"); } How do I create..

iOS - Dismiss keyboard when touching outside of UITextField

I'm wondering how to make the keyboard disappear when the user touches outside of a UITextField...

Laravel: PDOException: could not find driver

I am developing a website on a server I only have access to MySQL and FTP, so all commands I run are through the b374k php shell . I am experiencing a Laravel problem with SQL driver. I tried switchin..

Cannot access mongodb through browser - It looks like you are trying to access MongoDB over HTTP on the native driver port

I open terminal and enter the following commands sudo mongod which then outputs [initandlisten] waiting for connections on port 27017 I open another terminal and enter sudo mongo which open t..

Remove row lines in twitter bootstrap

I'm using twitter bootstrap for some web app I'm forced to do (I'm not a web developer) and I can't find a way to disable the row lines for tables. As you can see from the Bootstrap documentation, th..

Python Progress Bar

How do I use a progress bar when my script is doing some task that is likely to take time? For example, a function which takes some time to complete and returns True when done. How can I display a pr..

how to kill hadoop jobs

I want to kill all my hadoop jobs automatically when my code encounters an unhandled exception. I am wondering what is the best practice to do it? Thanks..

Is there a way to avoid null check before the for-each loop iteration starts?

Every time I have to iterate over a collection I end up checking for null, just before the iteration of the for-each loop starts. Like this: if( list1 != null ){ for(Object obj : list1){ } }..

Converting newline formatting from Mac to Windows

I need a conversion utility/script that will convert a .sql dump file generated on Mac to one readable on Windows. This is a continuation of a problem I had here. The issue seems to be with newline ..

Print a file's last modified date in Bash

I can't seem to find how to print out the date of a file. I'm so far able to print out all the files in a directory, but I need to print out the dates with it. I know I need to attach a date format ..

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

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

Using XPATH to search text containing &nbsp;

I use XPather Browser to check my XPATH expressions on an HTML page. My end goal is to use these expressions in Selenium for the testing of my user interfaces. I got an HTML file with a content simi..

How to fade changing background image

I want to fade the images when I do this code: $("#large-img").css('background-image', 'url('+$img+')'); I've tried putting fade in so many places. Thanks..

JS regex: replace all digits in string

I need to replace all digits. My function only replaces the first digit. var s = "04.07.2012"; alert(s.replace(new RegExp("[0-9]"), "X")); // returns "X4.07.2012" ..

How to find the index of an element in an array in Java?

I am looking to find the index of a given element, knowing its contents, in Java. I tried the following example, which does not work: class masi { public static void main( String[] args ) { ..

The remote certificate is invalid according to the validation procedure

Running the following code, I get an exception: using (var client = new Pop3Client()) { client.Connect(provider.ServerWithoutPort, provider.Port, true); } The Exception I get: The remote certi..

Sorting a Python list by two fields

I have the following list created from a sorted csv list1 = sorted(csv1, key=operator.itemgetter(1)) I would actually like to sort the list by two criteria: first by the value in field 1 and then b..

How to get user's high resolution profile picture on Twitter?

I was reading the Twitter documentation at https://dev.twitter.com/overview/general/user-profile-images-and-banners and it clearly states that: Alternative image sizes for user profile images You ..

How do I find out which computer is the domain controller in Windows programmatically?

I am looking for a way to determine what the Name/IP Address of the domain controller is for a given domain that a client computer is connected to. At our company we have a lot of small little networ..

How to paste text to end of every line? Sublime 2

I'm curious if there is a way to paste text to the end of every line in Sublime 2? And conversely, to the beginning of every line. test line one test line two test line three test line four ... ..

How do I get the coordinate position after using jQuery drag and drop?

How do I get the coordinate position after using jQuery drag and drop? I want to save the coordinate to a database, so that next time I visit, the item will be in that position. For example, x: 520px..

How to create custom view programmatically in swift having controls text field, button etc

I am trying to access the MyCustomView from another class using the following code in ViewController.swift .. var view = MyCustomView(frame: CGRectZero) .. in the viewDidLoad method. The problem is..

How to get the difference between two dictionaries in Python?

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

How to shrink temp tablespace in oracle?

How can we shrink temp tablespace in oracle? And why it is increasing so much like upto 25 GB since there is only one schema in the database for the application and data table space size is 2 GB and i..

Can Console.Clear be used to only clear a line instead of whole console?

While working on a question/answer program for school, it occurred to me that I can use Console.Clear() to wipe out everything on the screen. I wonder if I can use Console.Readline(valueOne), then out..

How do I get and set Environment variables in C#?

How can I get Environnment variables and if something is missing, set the value?..

Getting a union of two arrays in JavaScript

Say I have an array of [34, 35, 45, 48, 49] and another array of [48, 55]. How can I get a resulting array of [34, 35, 45, 48, 49, 55]?..

Best Free Text Editor Supporting *More Than* 4GB Files?

I am looking for a text editor that will be able to load a 4+ Gigabyte file into it. Textpad doesn't work. I own a copy of it and have been to its support site, it just doesn't do it. Maybe I need ..

Can I access variables from another file?

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

Java: How to get input from System.console()

I am trying to use Console class to get input from user but a null object is returned when I call System.console(). Do I have to change anything before using System.console? Console co=System.console..

Displaying files (e.g. images) stored in Google Drive on a website

I was wondering if its possible to access/display files like images which are stored in Google Drive on a public website...

The type is defined in an assembly that is not referenced, how to find the cause?

I know the error message is common and there are plenty of questions on SO about this error, but no solutions have helped me so far, so I decided to ask the question. Difference to most of similar que..