plaintext

Golang html output is being interpreted as plain text instead of being received as html

馋奶兔 提交于 2019-11-30 21:58:17
I'm sure this is just something dumb I'm doing, but I'm new to Go, so not sure what's going on here. I have the following basic setup. requestHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { t := template.New("test") t, _ := template.ParseFiles("base.html") t.Execute(w, "") }) server := &http.Server{ Addr: ":9999", Handler: requestHandler, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, MaxHeaderBytes: 1 << 20, } log.Fatal(server.ListenAndServe()) The contents of base.html are as follows: <DOCTYPE html> <html> <body> base.html </body> </html> When I run

Detecting a file's content-type when using JavaScript's FileReader interface

本秂侑毒 提交于 2019-11-30 20:06:01
I've been setting up an import script for plain-text files in a web application. My script is as follows: function dataImport(files) { confirm("Are you sure you want to import the selected file? This will overwrite any data that is currently saved in the application workspace."); for (i = 0; i < files.length; i++) { file = files[i] console.log(file) var reader = new FileReader() ret = [] reader.onload = function(e) { window.localStorage.setItem("ApplicationData", e.target.result); } reader.onerror = function(stuff) { console.log("error", stuff) console.log (stuff.getMessage()) } reader

Golang html output is being interpreted as plain text instead of being received as html

馋奶兔 提交于 2019-11-30 18:15:30
问题 I'm sure this is just something dumb I'm doing, but I'm new to Go, so not sure what's going on here. I have the following basic setup. requestHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { t := template.New("test") t, _ := template.ParseFiles("base.html") t.Execute(w, "") }) server := &http.Server{ Addr: ":9999", Handler: requestHandler, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, MaxHeaderBytes: 1 << 20, } log.Fatal(server.ListenAndServe()) The

Alternative to CSV?

半世苍凉 提交于 2019-11-30 15:07:30
问题 I intend to build a RESTful service which will return a custom text format. Given my very large volumes of data, XML/JSON is too verbose. I'm looking for a row based text format. CSV is an obvious candidate. I'm however wondering if there isn't something better out there. The only I've found through a bit of research is CTX and Fielded Text. I'm looking for a format which offers the following: Plain text, easy to read very easy to parse by most software platforms column definition can change

Alternative to CSV?

拜拜、爱过 提交于 2019-11-30 13:30:45
I intend to build a RESTful service which will return a custom text format. Given my very large volumes of data, XML/JSON is too verbose. I'm looking for a row based text format. CSV is an obvious candidate. I'm however wondering if there isn't something better out there. The only I've found through a bit of research is CTX and Fielded Text . I'm looking for a format which offers the following: Plain text, easy to read very easy to parse by most software platforms column definition can change without requiring changes in software clients Fielded text is looking pretty good and I could

Best practice for resetting forgotten user passwords

老子叫甜甜 提交于 2019-11-30 05:06:44
As far as I can think, there are two reasonable ways to reset a user's forgotten password. Have the user enter their email address and a new plaintext password is sent to their email address. A link is sent to their email address which has a UID number in the URL. Clicking on this takes the user to a form on the website where they can choose there own new password. Which method is preferable and why? If method 1 is used, perhaps a third party could read the email and obtain the new password. If method 2 is used, what is to stop someone methodically going through UID codes to try and access the

Intent for editing plain text file with the installed file editor (if any)

若如初见. 提交于 2019-11-29 13:39:22
I want my app to open a plain text file with any of the file editors installed on my terminal, but I keep getting this exception: ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT dat=file:///sdcard/folder/file.txt } First I thought that I have no File editor installed, but if I use ASTRO file manager, I can get to open the file both with "File Editor" and "QuickOffice", so I think the problem is that I'm not using the right code... Here is the code Intent intent = new Intent(Intent.ACTION_EDIT); Uri uri = Uri.parse("file:///sdcard/folder/file.txt")

Pyparsing: Parsing semi-JSON nested plaintext data to a list

霸气de小男生 提交于 2019-11-29 08:13:00
I have a bunch of nested data in a format that loosely resembles JSON: company="My Company" phone="555-5555" people= { person= { name="Bob" location="Seattle" settings= { size=1 color="red" } } person= { name="Joe" location="Seattle" settings= { size=2 color="blue" } } } places= { ... } There are many different parameters with varying levels of depth--this is just a very small subset. It also might be worth noting that when a new sub-array is created that there is always an equals sign followed by a line break followed by the open bracket (as seen above). Is there any simple looping or

Best practice for resetting forgotten user passwords

穿精又带淫゛_ 提交于 2019-11-28 23:04:44
问题 As far as I can think, there are two reasonable ways to reset a user's forgotten password. Have the user enter their email address and a new plaintext password is sent to their email address. A link is sent to their email address which has a UID number in the URL. Clicking on this takes the user to a form on the website where they can choose there own new password. Which method is preferable and why? If method 1 is used, perhaps a third party could read the email and obtain the new password.

use xsl to output plain text

二次信任 提交于 2019-11-28 18:15:29
I needed to use XSL to generate simple plain text output from XML. Since I didn't find any good, concise example online, I decided to post my solution here. Any links referring to a better example would of course be appreciated: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" > <xsl:output method="text" omit-xml-declaration="yes" indent="no"/> <xsl:template match="/"> <xsl:for-each select="script/command" xml:space="preserve">at -f <xsl:value-of select="username"/> <xsl:value-of