Questions Tagged with #Encode

to convert some data (e.g. string, picture) to some representation (e.g. bytes, electrical signals)

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

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

AJAX POST and Plus Sign ( + ) -- How to Encode?

I'm POSTing the contents of a form field via AJAX to a PHP script and using JavaScript to escape(field_contents). The problem is that any plus signs are being stripped out and replaced by spaces. Ho..

PHP "pretty print" json_encode

Possible Duplicate: Pretty-Printing JSON with PHP I'm working on a script that creates a JSON file. Right now I'm just using json_encode (PHP 5.2.x) to encode an array into JSON output. The..

UnicodeEncodeError: 'charmap' codec can't encode - character maps to <undefined>, print function

I am writing a Python (Python 3.3) program to send some data to a webpage using POST method. Mostly for debugging process I am getting the page result and displaying it on the screen using print() fu..

Encode URL in JavaScript?

How do you safely encode a URL using JavaScript such that it can be put into a GET string? var myUrl = "http://example.com/index.html?param=1&anotherParam=2"; var myOtherUrl = "http://example.com..

Convert int to ASCII and back in Python

I'm working on making a URL shortener for my site, and my current plan (I'm open to suggestions) is to use a node ID to generate the shortened URL. So, in theory, node 26 might be short.com/z, node 1 ..

How to convert a string or integer to binary in Ruby?

How do you create integers 0..9 and math operators + - * / in to binary strings. For example: 0 = 0000, 1 = 0001, ... 9 = 1001 Is there a way to do this with Ruby 1.8.6 without using a librar..

How to HTML encode/escape a string? Is there a built-in?

I have an untrusted string that I want to show as text in an HTML page. I need to escape the chars '<' and '&' as HTML entities. The less fuss the better. I'm using UTF8 and don't need other ..

What is base 64 encoding used for?

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

Python Unicode Encode Error

I'm reading and parsing an Amazon XML file and while the XML file shows a ' , when I try to print it I get the following error: 'ascii' codec can't encode character u'\u2019' in position 16: ordinal ..

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

How to center a View inside of an Android Layout?

I want to put a layout in the center of the screen. ..

Can I get all methods of a class?

Suppose that I have a .class file, can I get all the methods included in that class ?..

Custom Adapter for List View

I want to create a custom adapter for my list view. Is there any article that can walk me through how to create one and also explain how it works?..

Which MIME type to use for a binary file that's specific to my program?

My program uses its own binary file type, so I assume I can't use MIME type text/plain, as it is not a 7-bit ASCII file. Should I just call it "application/myappname"?..

Mysql error 1452 - Cannot add or update a child row: a foreign key constraint fails

I'm having a bit of a strange problem. I'm trying to add a foreign key to one table that references another, but it is failing for some reason. With my limited knowledge of MySQL, the only thing that ..

Grep to find item in Perl array

Every time I input something the code always tells me that it exists. But I know some of the inputs do not exist. What is wrong? #!/usr/bin/perl @array = <>; print "Enter the word you what to ..

Select current element in jQuery

I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a> </div> <div> <a>Link B1</a&..

How to Rotate a UIImage 90 degrees?

I have a UIImage that is UIImageOrientationUp (portrait) that I would like to rotate counter-clockwise by 90 degrees (to landscape). I don't want to use a CGAffineTransform. I want the pixels of the U..

Why does CSS not support negative padding?

I have seen this many a times that the prospect of a negative padding might help the development of CSS of certain page elements become better and easier. Yet, there is no provision for a negative pad..

How to fix a Div to top of page with CSS only

I am writing a glossary page. I have the alphabet links on the top of the page. I want to keep the top of the page (including the alphabet links) fixed, whilst the section of the page with the definit..

How to determine if a point is in a 2D triangle?

Is there an easy way to determine if a point is inside a triangle? It's 2D, not 3D...

Meaning of "487 Request Terminated"

Please tell me when a SIP call return 487 Request Terminated? Is it a termination issue?..

Class constructor type in typescript?

How can I declare a class type, so that I ensure the object is a constructor of a general class? In the following example, I want to know which type should I give to AnimalClass so that it could eit..

How do I integrate Ajax with Django applications?

I am new to Django and pretty new to Ajax. I am working on a project where I need to integrate the two. I believe that I understand the principles behind them both, but have not found a good explanati..

Pythonic way of checking if a condition holds for any element of a list

I have a list in Python, and I want to check if any elements are negative. Specman has the has() method for lists which does: x: list of uint; if (x.has(it < 0)) { // do something }; Where ..

Programmatically Add CenterX/CenterY Constraints

I have a UITableViewController that doesn't display any sections if there is nothing to show. I've added a label to indicate to the user that there is nothing to display with this code: label = UILa..

Differences between MySQL and SQL Server

I'm an ASP.NET developer who has used Microsoft SQL Server for all my database needs (both at work and for personal projects). I am considering trying out the LAMP stack for some of my personal proj..

AngularJs: Reload page

<a ng-href="#" class="navbar-brand" title="home" data-translate>PORTAL_NAME</a> I want to reload the page. How can I do this?..

Locking pattern for proper use of .NET MemoryCache

I assume this code has concurrency issues: const string CacheKey = "CacheKey"; static string GetCachedData() { string expensiveString =null; if (MemoryCache.Default.Contains(CacheKey)) { ..

how can I enable PHP Extension intl?

I am going to install Magento2 at my local server and it gives me following error notice. I am using XAMPP. When I tried to enable it from php.ini file it throws another error for missing dll: ..

Is Safari on iOS 6 caching $.ajax results?

Since the upgrade to iOS 6, we are seeing Safari's web view take the liberty of caching $.ajax calls. This is in the context of a PhoneGap application so it is using the Safari WebView. Our $.ajax cal..

Make WPF Application Fullscreen (Cover startmenu)

I would like to make my WPF application fullscreen. Right now the start menu prevents it from covering everything and shifts my application up. This is what I have for my MainWindow.xaml code: <Wi..

How to enable loglevel debug on Apache2 server

My error.log contains: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug..

How do I fix the npm UNMET PEER DEPENDENCY warning?

I'm on Windows 10, with Node 5.6.0 and npm 3.6.0. I'm trying to install angular-material and mdi into my working folder. npm install angular-material mdi errors with: +-- [email protected] +-- UNMET PEE..

What is the purpose of the single underscore "_" variable in Python?

What is the meaning of _ after for in this code? if tbh.bag: n = 0 for _ in tbh.bag.atom_set(): n += 1 ..

Convert string into integer in bash script - "Leading Zero" number error

In a text file, test.txt, I have the next information: sl-gs5 desconnected Wed Oct 10 08:00:01 EDT 2012 1001 I want to extract the hour of the event by the next command line: hour=$(grep -n sl-gs5..

Make a nav bar stick

Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav bar stick Make a nav ..

Android:java.lang.OutOfMemoryError: Failed to allocate a 23970828 byte allocation with 2097152 free bytes and 2MB until OOM

I want to show the Bitmap image in ImageView from sd card which is stored already. After run my application is crash and getting OutOfMemoryError error of: (java.lang.OutOfMemoryError: Failed to a..

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

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

Windows Scipy Install: No Lapack/Blas Resources Found

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

How do I assert an Iterable contains elements with a certain property?

Assume I want to unit test a method with this signature: List<MyItem> getMyItems(); Assume MyItem is a Pojo that has many properties, one of which is "name", accessed via getName(). All I ca..

Assignment makes pointer from integer without cast

Coming from a Java background I'm learning C, but I find those vague compiler error messages increasingly frustrating. Here's my code: /* * PURPOSE * Do case-insensetive string comparison. */..

Execute the setInterval function without delay the first time

It's there a way to configure the setInterval method of javascript to execute the method immediately and then executes with the timer..

How to dismiss keyboard iOS programmatically when pressing return

I created a UITextField programmatically making the UITextField a property of the viewController. I need to dismiss the keyboard with the return and the touch on the screen. I was able to get the scre..

Unexpected character encountered while parsing value

Currently, I have some issues. I'm using C# with Json.NET. The issue is that I always get: {"Unexpected character encountered while parsing value: e. Path '', line 0, position 0."} So the ..

CSS: fixed to bottom and centered

I need my footer to be fixed to the bottom of the page and to center it. The contents of the footer may change at all time so I can't just center it via margin-left: xxpx; margin-right: xxpx; The pro..

How to do encryption using AES in Openssl

I am trying to write a sample program to do AES encryption using Openssl. I tried going through Openssl documentation( it's a pain), could not figure out much. I went through the code and found the AP..

What does the 'L' in front a string mean in C++?

this->textBox1->Name = L"textBox1"; Although it seems to work without the L, what is the purpose of the prefix? The way it is used doesn't even make sense to a hardcore C programmer. ..

Python: can't assign to literal

My task is to write a program that asks the user to enter 5 names which it stores in a list. Next, it picks one of these names at random and declares that person as the winner. The only issue is that ..

How do I duplicate a line or selection within Visual Studio Code?

Using Microsoft's Visual Studio Code, how do I duplicate a line of code and then move it up and down? (Similar to Sublime's cmd+shift+d behaviour) It's a feature that I use constantly, and am struggl..

How to find all occurrences of an element in a list

index() will give the first occurrence of an item in a list. Is there a neat trick which returns all indices in a list for an element?..

How to cancel an $http request in AngularJS?

Given a Ajax request in AngularJS $http.get("/backend/").success(callback); what is the most effective way to cancel that request if another request is launched (same backend, different parameters ..

how can I login anonymously with ftp (/usr/bin/ftp)?

I'm trying to connect to an FTP server which allows anonymous access, I don't know how to specify the appropriate username/password required to do this though. I've tried using anonymous/anonymous as..

Getting a timestamp for today at midnight?

How would I go about getting a timestamp in php for today at midnight. Say it's monday 5PM and I want the Timestamp for Monday(today) at midnight(12 am) which already has happened. Thank you..

Homebrew: Could not symlink, /usr/local/bin is not writable

While installing tig, HomeBrew is displaying the following issues while installing a dependency: Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into..

In Angular, What is 'pathmatch: full' and what effect does it have?

In here it is use pathmatch as full and when i delete this pathmatch it doesn't even load the app or run the project import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/..

Youtube - downloading a playlist - youtube-dl

I am trying to download all the videos from the playlist: I am using youtube-dl for this and the command is: youtube-dl -citk –format mp4 –yes-playlist https://www.youtube.com/watch?v=7Vy8970q0..

Run script on mac prompt "Permission denied"

I'm new to mac with not familiar on terminal command, i put the dvtcolorconvert.rb file on root directory of my volume, this ruby script can converting xcode 3 themes into xcode 4 themes format, which..

How can I remove the string "\n" from within a Ruby string?

I have this string: "some text\nandsomemore" I need to remove the "\n" from it. I've tried "some text\nandsomemore".gsub('\n','') but it doesn't work. How do I do it? Thanks for reading...

Print the stack trace of an exception

How do I print the stack trace of an exception to a stream other than stderr? One way I found is to use getStackTrace() and print the entire list to the stream...

Difference between mkdir() and mkdirs() in java for java.io.File

Can anyone tell me the difference between these two methods: file.mkdir() file.mkdirs() ..

How do you underline a text in Android XML?

How do you underline a text in an XML file? I can't find an option in textStyle...

Google Gson - deserialize list<class> object? (generic type)

I want to transfer a list object via Google Gson, but I don't know how to deserialize generic types. What I tried after looking at this (BalusC's answer): MyClass mc = new Gson().fromJson(result, n..

Function to clear the console in R and RStudio

I am wondering if there is a function to clear the console in R and, in particular, RStudio I am looking for a function that I can type into the console, and not a keyboard shortcut. Someone has alre..

Remove Sub String by using Python

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

Can't load IA 32-bit .dll on a AMD 64-bit platform

I am trying to use SVMLight from Java, using the JNI wrapper on this page: static { System.loadLibrary("lib/JNI_SVM-light-6.01/lib/svmlight"); } I get the following error: ... lib\JNI_S..

React this.setState is not a function

I'm new in React and I'm trying to write an app working with an API. I keep getting this error: TypeError: this.setState is not a function when I try to handle the API response. I suspect ..

Failed to decode downloaded font

This is an error I am getting in Chrome and unfortunately searching for it hasn't given me much results. The font itself is appearing correctly. However I still get this error/warning. More specifical..

Spring default behavior for lazy-init

I am beginner to spring, ESP Inversion of control. I was puzzled understanding the difference between the following <bean id="demo" class="Demo" lazy-init="false"/> <bean id="demo" class=..

Uncaught TypeError: .indexOf is not a function

I am new to JavaScript and I'm getting an error as below. Uncaught TypeError: time.indexOf is not a function Gee, I really thought indexOf() really was a function. Here is a snippet of my code:..

Running javascript in Selenium using Python

I am totally new to Selenium. I want to execute a javascript snippet in the following code(as commented in the code), but can't do so. Please help. from selenium import webdriver import selenium from..

Toad for Oracle..How to execute multiple statements?

I have some 800-1200 INSERT statements generated from an excel sheet. I want to run these in TOAD - Oracle db. If I press F9, it runs only one line and F5 gives me syntax issue and do not seem to wor..

How to add element in List while iterating in java?

Say I have a List like: List<String> list = new ArrayList<>(); list.add("a"); list.add("h"); list.add("f"); list.add("s"); While iterating through this list I want to add an element at ..

kill a process in bash

How do I kill a process which is running in bash - for example, suppose I open a file: $ gedit file.txt is there any way within the command prompt to close it? This example is fairly trivial, si..

How do I load an org.w3c.dom.Document from XML in a string?

I have a complete XML document in a string and would like a Document object. Google turns up all sorts of garbage. What is the simplest solution? (In Java 1.5) Solution Thanks to Matt McMinn, I have ..

What is the difference between the operating system and the kernel?

I do not understand the difference between operating system and kernel. Can someone please explain it?..

MySQL ORDER BY rand(), name ASC

I would like to take a database of say, 1000 users and select 20 random ones (ORDER BY rand(),LIMIT 20) then order the resulting set by the names. I came up with the following query which is not worki..

Passing bash variable to jq

I have written a script to retrieve certain value from file.json. It works if I provide the value to jq select, but the variable doesn't seem to work (or I don't know how to use it). #!/bin/sh #this..

Programmatically switching between tabs within Swift

I need write some code to switch the view to another tab when the iOS app starts (so, for example, the second tab is shown by default rather than the first). I'm new to Swift, and have worked out the..

How to check for empty array in vba macro

I want to check for empty arrays. Google gave me varied solutions but nothing worked. Maybe I am not applying them correctly. Function GetBoiler(ByVal sFile As String) As String 'Email Signature ..

Disabling SSL Certificate Validation in Spring RestTemplate

I am having two Spring based web apps A and B, on two different machines. I want to make a https call from web app A to web app B, however I am using a self-signed certificate in Machine B. So my HTT..

Element count of an array in C++

Let's say I have an array arr. When would the following not give the number of elements of the array: sizeof(arr) / sizeof(arr[0])? I can thing of only one case: the array contains elements that are ..

Given two directory trees, how can I find out which files differ by content?

If I want find the differences between two directory trees, I usually just execute: diff -r dir1/ dir2/ This outputs exactly what the differences are between corresponding files. I'm interested in..

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

Proper MIME type for OTF fonts

Searching the web, I find heaps of different suggestions for what the proper MIME type for a font is, but I have yet to try any MIME type that rids me of a Chrome warning such as the following: Re..

How to test an Oracle Stored Procedure with RefCursor return type?

I'm looking for a good explanation on how to test an Oracle stored procedure in SQL Developer or Embarcardero Rapid XE2. Thank you...

Jquery - animate height toggle

I have a 10px bar along the top of the screen that, when clicked, I want it to animate to a height of 40px and then if clicked again, animate back down to 10px. I tried changing the id of the div, but..

The requested resource does not support HTTP method 'GET'

My route is correctly configured, and my methods have the decorated tag. I still get "The requested resource does not support HTTP method 'GET'" message? [System.Web.Mvc.AcceptVerbs("GET", "POST")] ..

What's the scope of a variable initialized in an if statement?

I'm new to Python, so this is probably a simple scoping question. The following code in a Python file (module) is confusing me slightly: if __name__ == '__main__': x = 1 print x In other langu..

Running interactive commands in Paramiko

I'm trying to run an interactive command through paramiko. The cmd execution tries to prompt for a password but I do not know how to supply the password through paramiko's exec_command and the execut..

Recreate the default website in IIS

I've accidentally deleted the default website in IIS; It no longer shows up in the tree of IIS manager and browsing "localhost" returns a 404 error. I've re-installed IIS, but the default website sti..

Printing newlines with print() in R

I am trying to print a multiline message in R. For example, print("File not supplied.\nUsage: ./program F=filename",quote=0) I get the output File not supplied.\nUsage: ./program F=filename inst..

ETag vs Header Expires

I've looked around but haven't been able to figure out if I should use both an ETag and an Expires Header or one or the other. What I'm trying to do is make sure that my flash files (and other images..

How to get current moment in ISO 8601 format with date, hour, and minute?

What is the most elegant way to get ISO 8601 formatted presentation of current moment, UTC? It should look like: 2010-10-12T08:50Z. Example: String iso8601 = DateFormat.getDateTimeInstance(DateForm..

How to use ternary operator in razor (specifically on HTML attributes)?

With the WebForms view engine, I'll commonly use the ternary operator for very simple conditionals, especially within HTML attributes. For example: <a class="<%=User.Identity.IsAuthenticated ? ..

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

AngularJS accessing DOM elements inside directive template

Is there a more "angular" way of selecting DOM elements inside a directive template? For example, say you have this directive: app.directive("myDirective", function() { return { template:..

How to set border on jPanel?

My projects constists of two classes, GoBoard extends JPanel. GoTest.java: import javax.swing.*; import java.awt.Graphics; import java.io.*; import java.awt.*; import javax.swing.border.Border; imp..

How to dynamically remove items from ListView on a button click?

I am working on an app that requires removing items from a ListView on a button event. I tried to remove it from ArrayList and create the whole new adapter and load the list again. As my list is huge..

How to create a POJO?

Recently I've started hearing about "POJOs" (Plain Old Java Objects). I googled it, but still don't understand the concept well. Can anyone give me a clear description of a POJO? Consider a class "Pe..

What is the difference between dim and set in vba

Pardon me as am a newbie in VBA. Sometimes I use Dim r as Range r = Range("A1") Other times I use Set r = Range("A1") What is the difference? And when should I use what?..

How to pretty print XML from Java?

I have a Java String that contains XML, with no line feeds or indentations. I would like to turn it into a String with nicely formatted XML. How do I do this? String unformattedXml = "<tag><..

Oracle Partition - Error ORA14400 - inserted partition key does not map to any partition

I'm trying to insert information in a partition table, but I don't know what I'm doing wrong! Show me this error: ORA-14400: inserted partition key does not map to any partition" The table dba_tab_pa..

Access Control Request Headers, is added to header in AJAX request with jQuery

I would like to add a custom header to an AJAX POST request from jQuery. I have tried this: $.ajax({ type: 'POST', url: url, headers: { "My-First-Header":"first value", ..

How to restart kubernetes nodes?

The status of nodes is reported as unknown "conditions": [ { "type": "Ready", "status": "Unknown", "lastHeartbeatTime": "2015-11-12T06:03:19Z", ..

MYSQL import data from csv using LOAD DATA INFILE

I am importing some data of 20000 rows from a CSV file into Mysql. Columns in the CSV are in a different order than MySQL table's columns. How to automatically assign columns corresponding to Mysql..

Setting SMTP details for php mail () function

I have been looking for an answer and tried many things to this problem. My script works fine on my webhost but when moving it to an other dedicated server the mail never gets delivered. Now i need t..

Get Memory Usage in Android

Is there any API by which we can get CPU or Memory usage of android? I have tried one code as below: package com.infostretch.mainactivity; import java.io.BufferedReader; import java.io.FileInputStr..

How to use Servlets and Ajax?

I'm very new to web apps and Servlets and I have the following question: Whenever I print something inside the servlet and call it by the webbrowser, it returns a new page containing that text. Is th..

Simplest code for array intersection in javascript

What's the simplest, library-free code for implementing array intersections in javascript? I want to write intersection([1,2,3], [2,3,4,5]) and get [2, 3] ..

How to add 'libs' folder in Android Studio?

I need help in creating the 'libs' folder in Android Studio for my project (It is not auto-generated in my project). When I want to create a folder, it gives me lots of options, like AIDL, Assets, JN..

If table exists drop table then create it, if it does not exist just create it

I'm stumped, I don't know how to go about doing this. Basically I just want to create a table, but if it exists it needs to be dropped and re-created, not truncated, but if it doesn't exist just crea..

What does "Error: object '<myvariable>' not found" mean?

I got the error message: Error: object 'x' not found Or a more complex version like Error in mean(x) : error in evaluating the argument 'x' in selecting a method for function 'mean..

How is the default max Java heap size determined?

If I omit the -Xmxn option from the Java command line then a default value will be used. According to Java documentation "the default value is chosen at runtime based on system configuration" W..

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

Date object to Calendar [Java]

I have a class Movie in it i have a start Date, a duration and a stop Date. Start and stop Date are Date Objects (private Date startDate ...) (It's an assignment so i cant change that) now I want to a..

Increment a Integer's int value?

How do I increment a Integer's value in Java? I know I can get the value with intValue, and I can set it with new Integer(int i). playerID.intValue()++; does not seem to work. Note: PlayerID is a ..

How to create a project from existing source in Eclipse and then find it?

I have created several .java files. All of them are located in one directory. I used a text editor to write these files. Now I want to switch to Eclipse. How can I do it? I have tried many ways. None ..

how to remove the dotted line around the clicked a element in html

I found that if there is a a link in the page which does not link to a new page,then when user click it,there will be a dotted line around the element,it will only disappear when user click anything e..

Get input value from TextField in iOS alert in Swift

I'm trying to make an alert message with input, and then get the value from the input. I've found many good tutorials how to make the input text field. but I can't get the value from the alert...

GIT commit as different user without email / or only email

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

Remove last character from C++ string

How can I remove last character from a C++ string? I tried st = substr(st.length()-1); But it didn't work...

How to validate Google reCAPTCHA v3 on server side?

I've just set up the new google recaptcha with checkbox, it's working fine on front end, however I don't know how to handle it on server side using PHP. I've tried to use the old code below but the fo..

R Error in x$ed : $ operator is invalid for atomic vectors

Here is my code: x<-c(1,2) x names(x)<- c("bob","ed") x$ed Why do I get the following error? Error in x$ed : $ operator is invalid for atomic vectors ..

How to get first character of a string in SQL?

I have a SQL column with a length of 6. Now want to take only the first char of that column. Is there any string function in SQL to do this?..

Is it safe to use Project Lombok?

In case you don't know Project Lombok helps with some of the annoyances of Java with stuff like generating getters and setters with annotations and even simple JavaBean like generation with @Data. It ..

Listening for variable changes in JavaScript

Is it possible to have an event in JS that fires when the value of a certain variable changes? JQuery is accepted...

Declare a dictionary inside a static class

How to declare a static dictionary object inside a static class? I tried public static class ErrorCode { public const IDictionary<string, string> ErrorCodeDic = new Dictionary<string, st..

How to sum array of numbers in Ruby?

I have an array of integers. For example: array = [123,321,12389] Is there any nice way to get the sum of them? I know, that sum = 0 array.each { |a| sum+=a } would work...

How can I insert into a BLOB column from an insert statement in sqldeveloper?

Is it possible to insert into a BLOB column in oracle using sqldeveloper? i.e. something like: insert into mytable(id, myblob) values (1,'some magic here'); ..

Could not load file or assembly 'System.Web.Mvc'

My new ASP.NET MVC Web Application works on my development workstation, but does not run on my web server... Server Error in '/' Application. Configuration Error Description: An error occurred ..

Can my enums have friendly names?

I have the following enum public enum myEnum { ThisNameWorks, This Name doesn't work Neither.does.this; } Is it not possible to have enums with "friendly names"?..

2 ways for "ClearContents" on VBA Excel, but 1 work fine. Why?

Good evening friends: I have in mind 2 ways for clearing a content in a defined range of cells of a VBA project (in MS Excel): Worksheets("SheetName").Range("A1:B10").ClearContents Worksheets("Shee..

How to diff a commit with its parent?

Aside from writing an alias or script, is there a shorter command for getting the diff for a particular commit? git diff 15dc8^..15dc8 If you only give the single commit id git diff 15dc8, it diffs..

How to set specific window (frame) size in java swing?

My code does not work: JFrame frame = new JFrame("mull"); mull panel = new mull(); // add panel to the center of window frame.getContentPane().add("Center", panel); frame.setSize(500, 300); // <..

strange error in my Animation Drawable

A strange error when trying to start Activity. i think the error in my Animation Drawable LogCat: 12-31 06:37:45.138: E/AndroidRuntime(922): FATAL EXCEPTION: main 12-31 06:37:45.138: E/Andr..

AngularJS multiple filter with custom filter function

I am trying to filter the list with multiple filters + with a custom filter function. The original working jsfiddle example is http://jsfiddle.net/ed9A2/1/ but now I want to change the way age are be..

IOError: [Errno 2] No such file or directory trying to open a file

I am very new to Python so please forgive the following basic code and problem, but I have been trying to figure out what is causing the error I am getting (I have even looked at similar threads on S...

How to convert byte array to string and vice versa?

I have to convert a byte array to string in Android, but my byte array contains negative values. If I convert that string again to byte array, values I am getting are different from original byte arr..

How can I get a specific field of a csv file?

I need a way to get a specific item(field) of a CSV. Say I have a CSV with 100 rows and 2 columns (comma seperated). First column emails, second column passwords. For example I want to get the passwor..

When to use @QueryParam vs @PathParam

I am not asking the question that is already asked here: What is the difference between @PathParam and @QueryParam This is a "best practices" or convention question. When would you use @PathParam vs..

How to return JSON with ASP.NET & jQuery

I cannot get how I can return JSON data with my code. JS $(function () { $.ajax({ type: "POST", url: "Default.aspx/GetProducts", data: "{}", contentType: "application..

How can I submit a form using JavaScript?

I have a form with id theForm which has the following div with a submit button inside: <div id="placeOrder" style="text-align: right; width: 100%; background-color: white;"..

How to split a string with angularJS

I wanted to know if I can split a string simply in angularJS. I have my $scope.test = "test1,test2"; in my controller and in my view, I wanted to do something like that {{test[0] | split(',')}} {..

With MySQL, how can I generate a column containing the record index in a table?

Is there any way I can get the actual row number from a query? I want to be able to order a table called league_girl by a field called score; and return the username and the actual row position of th..

Need to reset git branch to origin version

I was accidentally working on a branch I shouldn't have been for a while, so I branched off of it giving it the appropriate name. Now I want to overwrite the branch I shouldn't have been on to the ve..

Polymorphism: Why use "List list = new ArrayList" instead of "ArrayList list = new ArrayList"?

Possible Duplicate: Why should the interface for a Java class be prefered? When should I use List<Object> list = new ArrayList<Object>(); ArrayList inherits from List, so if..

Getting a directory name from a filename

I have a filename (C:\folder\foo.txt) and I need to retrieve the folder name (C:\folder) in unmanaged C++. In C# I would do something like this: string folder = new FileInfo("C:\folder\foo.txt").Dire..

Format numbers in thousands (K) in Excel

In MS Excel, I would like to format a number in order to show only thousands and with 'K' in from of it, so the number 123000 will be displayed in the cell as 123K It is easy to format to show only t..

Most concise way to test string equality (not object equality) for Ruby strings or symbols?

I always do this to test string equality in Ruby: if mystring.eql?(yourstring) puts "same" else puts "different" end Is this is the correct way to do this without testing object equality? I'm lo..

How to fetch the row count for all tables in a SQL SERVER database

I am searching for a SQL Script that can be used to determine if there is any data (i.e. row count) in any of the tables of a given database. The idea is to re-incarnate the database in case there a..

HTML5 Email input pattern attribute

I’m trying to make a html5 form that contains one email input, one check box input, and one submit input. I'm trying to use the pattern attribute for the email input but I don't know what to place i..

Convert JSON string to Javascript array

I have an array of arrays which I have planted in the DOM, so that I can reuse it at a later stage to transfer to the server: [["1","aaaaaa","1"],["2","bbb..

history.replaceState() example?

Can any one give a working example for history.replaceState? This is what w3.org says: history . replaceState(data, title [, url ] ) Updates the current entry in the session history to have..

Disable webkit's spin buttons on input type="number"?

I have a site which is primarily for mobile users but desktop too. On Mobile Safari, using <input type="number"> works great because it brings up the numerical keyboard on input fields which sh..

Opening popup windows in HTML

I am working with web apps, and I am wondering if there is a way to open a link in an app-type window using HTML? Something like this: <a href="link" target="_app">My App</a> ..

Is it safe to store a JWT in localStorage with ReactJS?

I'm currently building a single page application using ReactJS. I read that one of the reasons for not using localStorage is because of XSS vulnerabilities. Since React escapes all user input, would i..

How to unescape HTML character entities in Java?

Basically I would like to decode a given Html document, and replace all special chars, such as "&nbsp;" -> " ", "&gt;" -> ">". In .NET we can make use of HttpUtility.HtmlDecode. What's t..

"NoClassDefFoundError: Could not initialize class" error

When I run my project, I get numerous outputs of this error: Sep 9, 2009 8:22:23 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet Jersey threw exception ..

How to use JavaScript regex over multiple lines?

var ss= "<pre>aaaa\nbbb\nccc</pre>ddd"; var arr= ss.match( /<pre.*?<\/pre>/gm ); alert(arr); // null I'd want the PRE block be picked up, even though it spans over newline c..

Parse JSON in C#

I'm trying to parse some JSON data from the Google AJAX Search API. I have this URL and I'd like to break it down so that the results are displayed. I've currently written this code, but I'm pretty lo..

Angular2: How to load data before rendering the component?

I am trying to load an event from my API before the component gets rendered. Currently I am using my API service which I call from the ngOnInit function of the component. My EventRegister component..

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

How do I create a ListView with rounded corners in Android?

How do I create a ListView with rounded corners in Android?..

How to only find files in a given directory, and ignore subdirectories using bash

I'm running the find command to find certain files, but some files in sub-directories have the same name which I want to ignore. I'm interested in files/patterns like this: /dev/abc-scanner, /dev/abc-..

Is a URL allowed to contain a space?

Is a URI (specifically an HTTP URL) allowed to contain one or more space characters? If a URL must be encoded, is + just a commonly followed convention, or a legitimate alternative? In particular, ..

convert '1' to '0001' in JavaScript

Possible Duplicate: Is there a JavaScript function that can pad a string to get to a determined length? How can I convert convert '1' to '0001' in JavaScript without using any 3rd party lib..

Adding and removing style attribute from div with jquery

I've inherited a project I'm working on and I'm updating some jquery animations (very little practice with jquery). I have a div I need to add and remove the style attribute from. Here is the div: &..

error CS0103: The name ' ' does not exist in the current context

When my view loads, I need to check which domain the user is visiting, and based on the result, reference a different stylesheet and image source for the logo that appears on the page. This is my cod..

How to develop Android app completely using python?

I would like to develop a (rather simple) android app to be distributed via Play Store. I would like to do so completely in python. However, the online research hasn't quite enlightened me: most comme..

Accessing UI (Main) Thread safely in WPF

I have an application which updates my datagrid each time a log file that I'm watching gets updated (Appended with new text) in the following manner: private void DGAddRow(string name, FunctionType f..

Does Java have a complete enum for HTTP response codes?

I'm wondering if there is an enum type in some standard Java class library that defines symbolic constants for all of the valid HTTP response codes. It should support conversion to/from the correspond..

How to pass a list from Python, by Jinja2 to JavaScript

Let's say I have a Python variable: list_of_items = ['1','2','3','4','5'] and I pass it to Jinja by rendering HTML, and I also have a function in JavaScript called somefunction(variable). I am tryi..

HTML input arrays

<input name="foo[]" ... > I've used these before, but I'm wondering what it is called and if there is a specification for it? I couldn't find it in the HTML 4.01 Spec and results in various G..

Stack array using pop() and push()

I have a problem with 2 classes that I have created for a program the uses the stack. The first problem that I get is that when I try to run the program I get a run time error. Its kind of a difficul..

Add text to Existing PDF using Python

I need to add some extra text to an existing PDF using Python, what is the best way to go about this and what extra modules will I need to install. Note: Ideally I would like to be able to run this o..

Postgresql, update if row with some unique value exists, else insert

I have a URLs table. They contain (id int primary key, url character varying unique, content character varying, last analyzed date). I want to create trigger or something(rule may be), so each ..

How to fix error ::Format of the initialization string does not conform to specification starting at index 0::

I uploaded my site on godaddy shared host. I can access this database from my management studio. I can't access this database from my site. I get following error: Format of the initialization stri..

Differences between TCP sockets and web sockets, one more time

Trying to understand as best as I can the differences between TCP socket and websocket, I've already found a lot of useful information within these questions: fundamental difference between websocke..

C++ - struct vs. class

Possible Duplicates: C/C++ Struct vs Class What are POD types in C++? Hi, In the C++ In a Nutshell book, in chapter 6: classes, unders Access specifiers, mentioned the following: In ..

How should I choose an authentication library for CodeIgniter?

I see there are a few. Which ones are maintained and easy to use? What are their pros and cons? ..

Why am I getting InputMismatchException?

So far I have this: public double checkValueWithin(int min, int max) { double num; Scanner reader = new Scanner(System.in); num = reader.nextDouble(); while (..

JSON Stringify changes time of date because of UTC

My date objects in JavaScript are always represented by UTC +2 because of where I am located. Hence like this Mon Sep 28 10:00:00 UTC+0200 2009 Problem is doing a JSON.stringify converts the above ..

Paritition array into N chunks with Numpy

There is this How do you split a list into evenly sized chunks? for splitting an array into chunks. Is there anyway to do this more efficiently for giant arrays using Numpy?..

Redirecting from cshtml page

I want to redirect to a different view depending on the result of a dataset, but I keep getting returned to the page I am currently on, and can't work out why. I drop into the if statement the action ..

How do I include image files in Django templates?

I'm new to Django and I'm trying to learn it through a simple project I'm developing called 'dubliners' and an app called 'book'. The directory structure is like this: dubliners/book/ [includes mode..

MVC [HttpPost/HttpGet] for Action

I am using MVC C#. Can somebody give an example on why one would use [HttpPost/HttpGet] for an Action. How can an active have both - what is the practical use? ..

No module named Image

Sorry for my grammar, I don't speak English. After I set filebrowser, tinymce, and grappelli, I get this error: No module named Image try: from PIL import Image except ImportError: import Ima..

Escape double quote in VB string

I have used following piece of code to execute schtasks command from VB6. While executing it, ignores folder if they contains spaces. For example, "C:\program files\test\test.exe" will be converted ..

In Chrome 55, prevent showing Download button for HTML 5 video

I am getting this download button with <video> tags in Chrome 55, but not on Chrome 54: How can I remove this so no one can see the download button in Chrome 55? I have used <video> tag..

SQL Server - boolean literal?

How to write literal boolean value in SQL Server? See sample use: select * from SomeTable where PSEUDO_TRUE another sample: if PSEUDO_TRUE begin select 'Hello, SQL!' end Note: The query above..

Why am I seeing an "origin is not allowed by Access-Control-Allow-Origin" error here?

I am seeing the following error: Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin with this code: var http = new getXMLHttpRequestObject(); var url = "http://gdata.youtub..

I can't install intel HAXM

I installed Android Studio and I had no problems with that. However, when I tried to run the emulator, it said that Intel HAXM was not installed. So I found the installer, ran it, and it even though ..

Sequelize OR condition object

By creating object like this var condition= { where: { LastName:"Doe", FirstName:["John","Jane"], Age:{ gt:18 } } } and pass it in Student.findAll(condition) ...

Python Create unix timestamp five minutes in the future

I have to create an "Expires" value 5 minutes in the future, but I have to supply it in UNIX Timestamp format. I have this so far, but it seems like a hack. def expires(): '''return a UNIX style..

Java Enum return Int

I'm having trouble declaring an enum. What I'm trying to create is an enum for a 'DownloadType', where there are 3 download types (AUDIO, VIDEO, AUDIO_AND_VIDEO). I have implemented the code as follo..

How to write a switch statement in Ruby

How do I write a switch statement in Ruby?..

Reading a text file using OpenFileDialog in windows forms

I am new to the OpenFileDialog function, but have the basics figured out. What I need to do is open a text file, read the data from the file (text only) and correctly place the data into separate text..

Should I use int or Int32

In C#, int and Int32 are the same thing, but I've read a number of times that int is preferred over Int32 with no reason given. Is there a reason, and should I care?..

Git diff -w ignore whitespace only at start & end of lines

I love to use git diff -w to ignore whitespace differences. But, I just noticed that it ignores even whitespace differences in the middle of lines. How could I only ignore whitespace differences that ..

List of foreign keys and the tables they reference in Oracle DB

I'm trying to find a query which will return me a list of the foreign keys for a table and the tables and columns they reference. I am half way there with SELECT a.table_name, a.column_name..

Twitter Bootstrap inline input with dropdown

I'm trying to display a text input inline with a dropdown button. I can't figure out how to do this though. Here's the HTML I've tried (I've put all of it on a single line with no results): <div..

WCF Service Returning "Method Not Allowed"

In the process of developing my first WCF service and when I try to use it I get "Method not Allowed" with no other explanation. I've got my interface set up with the ServiceContract and OperationCo..

How can I format a nullable DateTime with ToString()?

How can I convert the nullable DateTime dt2 to a formatted string? DateTime dt = DateTime.Now; Console.WriteLine(dt.ToString("yyyy-MM-dd hh:mm:ss")); //works DateTime? dt2 = DateTime.Now; Console.Wr..

How can INSERT INTO a table 300 times within a loop in SQL?

I would like to insert a value retrieved from a counter in SQL and repeat it 300 times. Something like: DECLARE @Counter = 0; -- BEGIN Loop SET @Counter = @Counter + 1 INSERT INTO tblFoo ..

What does the 'u' symbol mean in front of string values?

Yes in short i would like to know why am I seeing a u in front of my keys and values. I am rendering a form. The form has check-box for the particular label and one text field for the ip address. I ..

How to convert seconds to HH:mm:ss in moment.js

How can I convert seconds to HH:mm:ss? At the moment I am using the function below render: function (data){ return new Date(data*1000).toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");; ..

What's the simplest way to list conflicted files in Git?

I just need a plain list of conflicted files. Is there anything simpler than: git ls-files -u | cut -f 2 | sort -u or: git ls-files -u | awk '{print $4}' | sort | uniq I guess I could set up ..

What does 'killed' mean when a processing of a huge CSV with Python, which suddenly stops?

I have a Python script that imports a large CSV file and then counts the number of occurrences of each word in the file, then exports the counts to another CSV file. But what is happening is that onc..

Find p-value (significance) in scikit-learn LinearRegression

How can I find the p-value (significance) of each coefficient? lm = sklearn.linear_model.LinearRegression() lm.fit(x,y) ..