Problem serving local files with vweb (V-lang's default server) - server

Description of the problem
According to V's doc, using vweb, in order to serve static files one just has to add the following line to a server:
app.mount_static_folder_at(os.resource_abs_path('dist'), '/content')
So, for instance: the following server is supposed to serve the content of the local directory ./dist at the address: http://localhost:8080/content
The complete code being :
import vweb
import os
struct App {
vweb.Context
}
fn main() {
mut app := &App{}
println(os.resource_abs_path('dist'))
app.mount_static_folder_at(os.resource_abs_path('dist'), '/content')
vweb.run(app, 8080)
}
["/"]
fn (mut app App) root() vweb.Result {
return app.text('Hello from root')
}
Expected Behavior
The server is supposed to serve the content of the local directory ./dist at the address: http://localhost:8080/content
Current Behavior
404 Not Found
Reproduction Steps
println(os.resource_abs_path('dist')) yields
C:\Users\serge\Documents\vue-tests\vue-tests-nomodules\v2\dist
Which is correct, plus:
ls lists
---- ------------- ------ ----
d----- 2/11/2023 6:45 PM dist
d----- 2/11/2023 6:45 PM src
-a---- 2/11/2023 5:53 PM 139 .editorconfig
-a---- 2/11/2023 5:53 PM 148 .gitattributes
-a---- 2/11/2023 5:53 PM 237 .gitignore
-a---- 2/11/2023 6:06 PM 85 v.mod
-a---- 2/12/2023 12:56 PM 2037248 v2.exe
PS C:\Users\serge\Documents\vue-tests\vue-tests-nomodules\v2> ls .\dist\
Directory: C:\Users\serge\Documents\vue-tests\vue-tests-nomodules\v2\dist
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2/11/2023 6:32 PM 295 app.html
-a---- 2/11/2023 6:42 PM 295 index.html
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.3.3 90591eb
Environment details (OS name and version, etc.)
Windows 11

Related

Pivot table in PostgreSQL repeating values in columns

Having the following data in a table:
ID --------- Category --------- Value
1234 -------- Cat01 ----------- V001
1234 -------- Cat02 ----------- V002
1234 -------- Cat03 ----------- V003
1234 -------- Cat03 ----------- V004
1234 -------- Cat03 ----------- V005
I want to have the following output:
ID --------- Cat01 --------- Cat02 --------- Cat03
1234 ------- V001 ---------- V002 ---------- V003
1234 ------- V001 ---------- V002 ---------- V004
1234 ------- V001 ---------- V002 ---------- V005
How can it be done in PostgreSQL. As you can see, the value in Cat01 and Cat02 columns are repeated for each entry in Cat03 column
Many thanks for your help!
How about something like this:
SELECT a.val AS cat01, b.val AS cat02, c.val AS cat03
FROM
test_pivot AS a,
test_pivot AS b,
test_pivot AS c
WHERE
a.category = 'Cat01'
AND
b.category = 'Cat02'
AND
c.category = 'Cat03'

Unable to write to parque file using fullSet.repartition(1).saveAsParquetFile("swift://notebooks.spark/tweetsFull.parquet")

I am trying build application using apache spark using IBM bluemix. (Ref https://developer.ibm.com/clouddataservices/sentiment-analysis-of-twitter-hashtags/). I am using streaming API's to stream data and have successfully created the SQL table using spark SQL. Then I have read the data using SQL select *, but when I am unable to write the data to paraque file in the object storage space on the IBM Bluxmix platform.Following is the sample code
.
.
.
var df = sqlContext.createDataFrame( workingRDD, schemaTweets )
df.registerTempTable("tweets_table")
df.printSchema()
root
|-- author: string (nullable = true)
|-- date: string (nullable = true)
|-- lang: string (nullable = true)
|-- text: string (nullable = true)
val results = sqlContext.sql("select * from tweets_table limit 5")
results.show
+--------------------+--------------------+----+--------------------+
| author| date|lang| text|
+--------------------+--------------------+----+--------------------+
| abc ?|Sun Nov 29 03:30:...| en|RT #fdfds: W........|
| fdsfsdf ?|Sun Nov 29 03:30:...| en|#NewsIndofsdfM R...|
| .fsdfdsf |Sun Nov 29 03:30:...| en|RT #Lsfddsfds. ..|
| Wsfsfd |Sun Nov 29 03:30:...| en|My gfsdfsdfdshtps...|
| Ffsdfsdf |Sun Nov 29 03:30:...| en|RT #Ayfsdfsdf : W...|
+---------------------+--------------------+----+--------------------+
results.repartition(1).saveAsParquetFile("swift://notebooks.spark/tweets_1.parquet")
Here in the object storage seeing that the file tweets_1.parquet is created, But its showing as 0 bytes. Can any one let me know where I did a mistake ?
When I ran through this same example my Parquet file is saved in Object Storage but is broken up into several files in a subdirectory with the same name:
tweetsFull.parquet 12/02/2015 1:48 PM 0 KB
tweetsFull.parquet/part-r-00000-c3709e95-8f23-4ec5-bdf0-f0940b2cd94b.gz.parquet 12/02/2015 1:49 PM 16 KB
tweetsFull.parquet/_common_metadata 12/02/2015 1:49 PM 1 KB
tweetsFull.parquet/_metadata 12/02/2015 1:49 PM 3 KB
tweetsFull.parquet/_SUCCESS 12/02/2015 1:49 PM 0 KB
It works if I read from this file. Is that what you are seeing?
Sorry. I was mistaken by the folder name tweets_1.parquet, which is showing as 0 bytes.I thought tweets_1.parquet is the only file which must be created. But its a folder and under that I can able to see all the files which are valid.

SSRS 2008: Line chart Y-Axis scale issue

After search of one week, finally decided to put my question in front of you all. Hope I will get some outcome from it.
Currently I am working on Line Chart. Following is the data which I need to bind to line chart.
JobStartDate JobStartTime JobEndTime
1/1/2015 01.00 02.30
1/2/2015 01.02 03.20
1/3/2015 01.01 03.40
1/4/2015 01.05 02.00
1/5/2015 22.03 23.30
1/6/2015 22.05 23.40
So, In above scenario Line chart looks like:
11.00 PM | /////////
10.00 PM | ..........
........ |
04.00 AM | /
03.00 AM | / /
02.00 AM | / /
01.00 AM | .....................
12.00 AM |______________________________________________
1/1/15 1/2/15 1/3/15 1/4/15 1/5/15 1/6/15
But it should be like :
04.00 AM | /
03.00 AM | / /
02.00 AM | / /
01.00 AM | .....................
12.00 AM |
11.00 PM | /////////////
10.00 PM | ............
09.00 PM |______________________________________________
1/1/15 1/2/15 1/3/15 1/4/15 1/5/15 1/6/15
(Sorry As cant upload the image. So, Tried to show as above.)
In above figure (.) is StartTime and (/) is EndTime.
You can see that I am facing the problem of Y-Axis scaling.
Hope everyone understand my problem. Please let me know for more explanation.

Whoosh groupping by time interval

I have the following structure and is indexed using Whoosh.
timestamp name count(b.name)
------------------- ---- -------------
2010-11-16 10:32:22 John 2
2010-11-16 10:35:12 John 7
2010-11-16 10:36:34 John 1
2010-11-16 10:37:45 John 2
2010-11-16 10:48:26 John 8
2010-11-16 10:55:00 John 9
2010-11-16 10:58:08 John 2
I want to make a query to get the following structures, so it displays name frequency every 5 mins
timestamp name count(b.name)
------------------- ---- -------------
2010-11-16 10:30:00 John 2
2010-11-16 10:35:00 John 10
2010-11-16 10:40:00 John 0
2010-11-16 10:45:00 John 8
2010-11-16 10:50:00 John 0
2010-11-16 10:55:00 John 11
One of the possible solutions is to introduce additional field into index e.g. timestamp_trimmed, trim timestamp to 5min interval and save into timestamp_trimmed field and perform search with grouped by timestamp_trimmed field.

Including uncovered files in Devel::Cover reports

I have a project setup like this:
bin/fizzbuzz-game.pl
lib/FizzBuzz.pm
test/TestFizzBuzz.pm
test/TestFizzBuzz.t
When I run coverage on this, using
perl -MDevel::Cover=-db,/tmp/cover_db test/*.t
... I get the following output:
----------------------------------- ------ ------ ------ ------ ------ ------
File stmt bran cond sub time total
----------------------------------- ------ ------ ------ ------ ------ ------
lib/FizzBuzz.pm 100.0 100.0 n/a 100.0 1.4 100.0
test/TestFizzBuzz.pm 100.0 n/a n/a 100.0 97.9 100.0
test/TestFizzBuzz.t 100.0 n/a n/a 100.0 0.7 100.0
Total 100.0 100.0 n/a 100.0 100.0 100.0
----------------------------------- ------ ------ ------ ------ ------ ------
That is: the totally-uncovered file bin/fizzbuzz-game.pl is not included in the results.
How do I fix this?
Have you checked the documentation? The section on Selecting which files to cover seems most helpful. :) It looks like the +select option is the one you are looking for.
I figured out a work-around for this.
The core of this problem is that the uncovered code in the main file (fizzbuzz-game.pl) is not included in the coverage report, hence the overall percentage is wrong. The underlying problem is that substantial logic resides in the main file instead of testable modules. This is a smell (don't know which, but I'm pretty sure there is a name for "lots of logic in main()").
By getting rid of this smell, eg. moving all substatial code from bin/fizzbuzz-game.pl to lib/FizzBuzzGame.pm, the code can theoretically be tested, and can definitively be included in the test run.
The coverage report after this becomes:
----------------------------------- ------ ------ ------ ------ ------ ------
File stmt bran cond sub time total
----------------------------------- ------ ------ ------ ------ ------ ------
lib/FizzBuzz.pm 100.0 100.0 n/a 100.0 0.0 100.0
lib/FizzBuzzGame.pm 75.0 n/a n/a 75.0 100.0 75.0
Total 87.5 100.0 n/a 83.3 100.0 88.9
----------------------------------- ------ ------ ------ ------ ------ ------