h = gca()
p = h.children
c = p.children
c.data
Copied!
Cheers!
Imam
Imam
h = gca()
p = h.children
c = p.children
c.data
Copied!
# define object for holding a set of temperature data
class TempData():
def __init__(self):
self.day = [] # list of days
self.temp = [] # list of temperature
csv_imported_data = TempData() # create object for holding csv file temperature data
processed_data = TempData() # create object for holding processed datacsv_file = open('data.csv', 'r') # open the csv file for reading
reader = csv.reader(csv_file) # pass the file to csv reader object for extracting data
for row in reader: # get the row data from the csv file
csv_imported_data.day.append(float(row[0])) # get the first column data
csv_imported_data.temp.append(float(row[1])) # get the second column data
csv_file.close() # close the csv file# print temperature data from the temperature object
for i in range(len(csv_imported_data.day)):
print(csv_imported_data.day[i], csv_imported_data.temp[i])# show average temperature from the temperature object
print('Average temperature for', len(csv_imported_data.day), 'days was', sum(csv_imported_data.temp)/len(csv_imported_data.temp))# find difference between temperatures and store in temperature data object
for i in range(len(csv_imported_data.day)):
if (i == 0): # no difference for first data
processed_data.day.append(csv_imported_data.day[i])
processed_data.temp.append(0)
else:
processed_data.day.append(abs(csv_imported_data.day[i] - csv_imported_data.day[i-1]))
processed_data.temp.append(abs(csv_imported_data.temp[i] - csv_imported_data.temp[i-1]))# print temperature difference data from the temperature object
for i in range(len(processed_data.day)):
print(processed_data.day[i], processed_data.temp[i])csv_file = open('processed_temp_data.csv', 'w', newline='') # create a new csv file for writing
csv_writer = csv.writer(csv_file) # pass the file to csv writer object for writing data
for row in zip(processed_data.day, processed_data.temp): # create the row data from the the temperature object
csv_writer.writerow(row)
csv_file.close()<link rel="stylesheet" <?php echo "href=\"style1.css?v=" . sha1_file('style1.css') . "\"" ?>><script <?php echo "src=\"load.js?v=" . sha1_file('load.js') . "\"" ?>></script>int signal = 1110;int signal = 1 << 3 | 1 << 2 | 1 << 1;[Desktop Entry]
Name=Install
GenericName=Package Installer
Comment=Copy package files to your system
Exec=Install.sh
Terminal=false
Type=Application
Encoding=UTF-8
class MainWindow : public Gtk::Window
{
protected:
Gtk::Frame video_frame;
VideoArea video_area;
public:
MainWindow ();
virtual ~MainWindow();
};class VideoArea : public Gtk::DrawingArea
{
protected:
cv::VideoCapture cv_cap;
bool cv_opened;
virtual bool on_draw (const Cairo::RefPtr<Cairo::Context> &cr);
bool on_timeout ();
public:
VideoArea ();
virtual ~VideoArea();
};
VideoArea::VideoArea() : cv_opened(false)
{
cv_cap.open(0);
if (cv_cap.isOpened() == true) {
cv_opened = true;
Glib::signal_timeout().connect(sigc::mem_fun(*this, &VideoArea::on_timeout), 50);
}
}bool VideoArea::on_timeout()
{
Glib::RefPtr<Gdk::Window> win = get_window();
if (win) {
Gdk::Rectangle r(0, 0, get_allocation().get_width(), get_allocation().get_height());
win->invalidate_rect(r, false);
}
return true;
}
bool VideoArea::on_draw(const Cairo::RefPtr<Cairo::Context> &cr)
{
if (!cv_opened) return false;
cv::Mat cv_frame, cv_frame1;
cv_cap.read(cv_frame);
if (cv_frame.empty()) return false;
cv::cvtColor (cv_frame, cv_frame1, CV_BGR2RGB);
Gdk::Cairo::set_source_pixbuf (cr, Gdk::Pixbuf::create_from_data(cv_frame1.data, Gdk::COLORSPACE_RGB, false, 8, cv_frame1.cols, cv_frame1.rows, cv_frame1.step));
cr->paint();
return true;
}#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "imamll.h"
struct Person {
char name[24];
double age;
double weight;
double height;
};
struct imamLL *People_list = NULL; /* Pointer to hold list */
struct imamLL_element *person = NULL; /* Pointer to hold individual element */
unsigned long c;
int main (int argc, char* argv[])
{
printf ("Allocating memory for list\n");
People_list = imamLL_list_create();
if (People_list == NULL) {
printf ("Can not create the list\n");
exit (1);
}
if ((person = imamLL_element_add (People_list, sizeof(struct Person), AT_END)) == NULL) {
printf ("Can not add element");
printf ("Freed list, returned %d\n", imamLL_list_destroy (People_list));
exit (1);
}
strcpy (((struct Person *)person->data)->name, "Md Imam Hossain");
((struct Person *)person->data)->age = 27.0;
((struct Person *)person->data)->height = 180.0;
((struct Person *)person->data)->weight = 67.0;
printf ("Allocated: %lu Bytes\n", People_list->size);
if ((person = imamLL_element_add (People_list, sizeof(struct Person), AT_END)) == NULL) {
printf ("Can not add element");
printf ("Freed list, returned %d\n", imamLL_list_destroy (People_list));
exit (1);
}
strcpy (((struct Person *)person->data)->name, "Md Salim Hossain");
((struct Person *)person->data)->age = 22.0;
((struct Person *)person->data)->height = 182.0;
((struct Person *)person->data)->weight = 75.0;
printf ("Allocated: %lu Bytes\n", People_list->size);
while (1) {
person = imamLL_element_get_next (People_list);
if (person == NULL) break;
printf ("*Person*\n");
printf ("Name: %s\n", ((struct Person *)person->data)->name);
printf ("Age: %lf\n", ((struct Person *)person->data)->age);
printf ("Height: %lf\n", ((struct Person *)person->data)->height);
printf ("Weight: %lf\n", ((struct Person *)person->data)->weight);
}
printf ("Freed: %d elements\n", imamLL_list_free (People_list));
printf ("Freed list, returned %d\n", imamLL_list_destroy (People_list));
return (EXIT_SUCCESS);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <imamll.h> /*header for imamLL */
struct imamLL *num_list = NULL;
struct imamLL_element *element = NULL;
int main (int argc, char** argv)
{
num_list = imamLL_list_create();
if ( num_list == NULL) {
printf ("Can not create the list\n");
exit (EXIT_FAILURE);
}
element = imamLL_element_add (num_list, sizeof (int), 0);
if (element == NULL) printf ("Error allocating memory for an integer element\n");
else *((int *)element->data) = 10;
element = imamLL_element_add (num_list, sizeof (int), 0);
if (element == NULL) printf ("Error allocating memory for an integer element\n");
else *((int *)element->data) = 20;
element = imamLL_element_add (num_list, sizeof (int), 0);
if (element == NULL) printf ("Error allocating memory for an integer element\n");
else *((int *)element->data) = 30;
imamLL_list_rewind (num_list);
while ((element = imamLL_element_get_next(num_list)) != NULL) {
printf ("%d\n", *((int *)element->data));
}
imamLL_list_destroy (num_list);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main (int argc, char *argv[])
{
pid_t child_id;
child_id = fork ();
if (child_id == -1) {
printf ("Creating new process by fork() failed!\n");
return 1;
}
else if (child_id == 0) {
/* code block for child process */
int count;
for (count = 1; count < 10; count++) {
printf ("Child counting: %d\n", count);
sleep (1);
}
_exit (0);
}
else {
/* code block for parent process */
int child_exit_status;
int count;
printf ("Child process id: %d\n", child_id);
for (count = 1; count < 5; count++) {
printf ("Parent counting: %d\n", count);
sleep (1);
}
printf ("Waiting for child to end\n");
wait (&child_exit_status);
printf ("Child exited with %d\n", child_exit_status);
}
return EXIT_SUCCESS;
}