The following code doesn't have any error but it won't run. There's just a flash on the screen when I run it. It doesn't provide any output. what do I have to do?
#include<graphics.h>
#include<conio.h>
void main()
{
int gd = DETECT, gm;
initgraph (&gd, &gm, "");
setbkcolor (15);
setcolor (0);
settextjustify (1,1);
settextstyle (3,0,12);
outtextxy (getmaxx()/2, 1, "BATAAN PENINSULA STATE UNIVERSITY");
outtextxy(getmaxx()/2, 3, "MAIN CAMPUS");
settextstyle (3,0,10);
outtextxy (getmaxx()/2, 5, "College of Engineering and Architecture");
outtextxy (getmaxx()/2, 7, "Bachelor of Science in Civil Engineering(BSCE)");
settextstyle (3,0,15);
outtextxy (getmaxx()/2, getmaxy()/2, "COMPUTERIZED TUTORIAL SYSTEM");
outtextxy (getmaxx()/2, 30, "(CORRECTION IN TAPING)");
settextstyle (3,0,10);
outtextxy (getmaxx()/2, getmaxy(), "Programmed by: BSCE-3A Group 8");
getch();
closegraph();
}
In initgrapgh, your "" are empty. They should have the path to the bgi library.
It should look something like this:
initgraph(&gd, &gm, "C:\\TC\\BGI");
Related
Dear Groovy specialists,
I stumbled upon a phenomenon in Groovy which I would describe as follows:
Given a list of maps that share some common keys, it is possible to access the Map values directly via the List.
Example:
ArrayList people = [
["height": 172, "age": 42],
["height": 180, "age": 66],
["height": 180, "age": null],
["height": 180],
["age": 10]
]
println "people.height: " + people.height
println "people.age: " + people.age
Output:
people.height: [172, 180, 180, 180, null]
people.age: [42, 66, null, null, 10]
Does this syntax (e.g. people.height / people.age) have a name?
Thanks in advance!
PS: This answer would be another example of the mentioned syntax
Does this syntax (e.g. people.height / people.age) have a name?
That is Groovy's syntax for property access.
(Note that a property is a different thing than a field and Groovy has a bunch of special dynamic stuff that happens during property access.)
I am writing a LoadTestShape Class. I want to be able to set number of transaction per minute. If I try to set it by specifying user_count it doesn't work because the RPS will vary cpu to cpu .
If say I want to set 1000 transaction per minute, how can we achieve that in locust?
The only way to "achieve" this in Locust is implementing Pacing, the logic is:
You know how much time one iteration takes for one user
If user manages to finish faster - you need to introduce some "think time" so your thread "sleeps" till the desired time
If iteration is slower - no sleep is required.
This answer shows how you can create a custom load shape
Alternatively you can consider switching to a load testing tool which provides such functionality, i.e. Apache JMeter with Constant Throughput Timer
for this timing that's enough to add a LoadTestShape class to locustfile.py like the below code which I use for one of my tests you can change the number of users or other parameters as you want(I write a full docstring that describes each parameter in that):
class StagesShape(LoadTestShape):
"""
A simply load test shape class that has different user and spawn_rate at
different stages.
Keyword arguments:
stages -- A list of dicts, each representing a stage with the following keys:
duration -- When this many seconds pass the test is advanced to the next stage
users -- Total user count
spawn_rate -- Number of users to start/stop per second
stop -- A boolean that can stop that test at a specific stage
stop_at_end -- Can be set to stop once all stages have run.
"""
stages = [
{"duration": 60, "users": 3, "spawn_rate": 0.05},
{"duration": 60, "users": 6, "spawn_rate": 0.05},
{"duration": 60, "users": 9, "spawn_rate": 0.05},
{"duration": 60, "users": 12, "spawn_rate": 0.05},
{"duration": 60, "users": 15, "spawn_rate": 0.05},
{"duration": 60, "users": 18, "spawn_rate": 0.05},
{"duration": 60, "users": 21, "spawn_rate": 0.05},
{"duration": 60, "users": 24, "spawn_rate": 0.05},
{"duration": 60, "users": 27, "spawn_rate": 0.05},
{"duration": 60, "users": 30, "spawn_rate": 0.05},
]
def tick(self):
run_time = self.get_run_time()
for stage in self.stages:
if run_time < stage["duration"]:
tick_data = (stage["users"], stage["spawn_rate"])
return tick_data
return None
I ended up using constant_throughput to control the number of requests per second.
For different time of the day I'd use a different throughput value.
Simply set the wait_time = constant_throughput(0.1). Based on RPS you want you can either set the value low for less number of requests and more for more RPS.
I want to use tpm nvstore for writing and reading.When program run to"Tspi_NV_Definespace",it comes "general failure".I want to find how I can solve it.
Tspi_Context_Create(&hContext);
Tspi_Context_Connect(hContext, NULL);//connect to local host
Tspi_Context_GetTPMObject(hContext, &hTPM);//get handle
Tspi_GetPolicyObject(hTPM, TSS_POLICY_USAGE, &hOwnerPolicy);
Tspi_Policy_SetSecret(hOwnerPolicy, TSS_SECRET_MODE_PLAIN, strlen(secret), secret);//set secret
Tspi_Context_CreateObject(hContext, TSS_OBJECT_TYPE_NV, 0, &hNvStore);//create nvram object
Tspi_SetAttribUint32(hNvStore, TSS_TSPATTRIB_NV_INDEX, 0, 1);
Tspi_SetAttribUint32(hNvStore, TSS_TSPATTRIB_NV_PERMISSIONS, 0, TPM_NV_PER_AUTHWRITE);//permit to write
Tspi_SetAttribUint32(hNvStore, TSS_TSPATTRIB_NV_DATASIZE, 0, dataLen);
result = Tspi_NV_DefineSpace(hNvStore, 0, 0);
I am following this tutorial, but I am doing a very basic version where I just want to print something out.
All the pins and hardware specification are followed as per that tutorial.
Below is my app.js code:
var five = require('johnny-five');
var board = new five.Board();
var lcd;
board.on('ready', function() {
lcd = new five.LCD({
// LCD pin name RS EN DB4 DB5 DB6 DB7
// Arduino pin # 12, 11, 5, 4, 3, 2
pins: [12, 11, 5, 4, 3, 2],
rows: 2,
cols: 16
});
lcd.clear().print("Hello NJ");
this.repl.inject({
lcd: lcd
});
});
The problem is, when I connect my arduino to my laptop the lcd screen lits up, however when I run the code it does not show anything on the screen. I also followed this tutorial and the result is same.
Even if I remove the print command and do something like
lcd.noBacklight();
it does not work.
Even if I write the lcd.print("hello world") command in the console, it does not get printed on the lcd (however it does not show me any error on the console).
I have uploaded the Standard Firmata using my Arduino IDE. The johnny-five module works cause I tried their led examples and it was working.
Is my lcd device messed up or is it my code or is it my hardware connections?
I am confused.
Trying to plot a ConvexHull Using PlanarGraphPlot from the ComputationalGeometry package, it does not work when used in graphics.
Any Idea on how to plot the ConvexHull using Graphics ?
Needs["ComputationalGeometry`"]
pts = RandomReal[{0, 10}, {60, 2}];
Graphics[
{
Point#pts,
FaceForm[], EdgeForm[Red],
Polygon#pts[[ConvexHull[pts]]]
}
]
or
cpts = pts[[ConvexHull[pts]]];
AppendTo[cpts, cpts[[1]]];
Graphics[
{
Point#pts,
Red,
Line#cpts
}
]
Not sure exactly what is wanted. Maybe the code below will get you started.
pts = RandomReal[{-10, 10}, {20, 2}]
(*
Out[1]= {{1.7178, -1.11179}, {-7.10708, -8.1637},
{8.74461, -2.42551}, {6.64129, -2.87008}, {9.9008, 6.47825},
{8.27081, 9.94116}, {9.97325, 7.61094}, {-2.7876, 9.70449},
{-3.69357, 0.0253506}, {-0.503817, -1.98649}, {6.3056, -1.16892},
{-4.69983, -1.93242}, {-6.09983, 7.49229}, {8.08545, 6.67951},
{-6.91195, 8.34752}, {-2.63136, 6.0506}, {-0.130006, 2.10929},
{1.64401, 3.32165}, {0.611335, -8.11364}, {-2.03548, -9.37277}}
*)
With[{hull = pts[[Graphics`Mesh`ConvexHull[pts]]]},
Graphics[Line[Append[hull, First[hull]]]]]