Posts

Showing posts with the label c#

ASP.Net Meta Tags: Programmatically populate Title, Keywords and Description in Page Head Section from database

Image
ASP.Net Meta Tags: Programmatically populate Title, Keywords and Description in Page Head Section from database I'm trying to create search option in my ASP.net application to check Doctor details based on Location. If I try the below code, only home page is showing. http://example.com/Metatag/Home.aspx . I want the URL to be changed as per location. Example expected URL: http://example.com/Metatag/chennai/doctors/saidapet http://example.com/Metatag/Home.aspx http://example.com/Metatag/chennai/doctors/saidapet I'm new to this technology. Page Load protected void Page_Load(object sender, EventArgs e) { string page = Request.Url.Segments[Request.Url.Segments.Length - 1]; string location = Request.Url.Segments[Request.Url.Segments.Length - 1]; DataTable dtMeta = this.GetData(page,location); //Add Page Title this.Page.Title = dtMeta.Rows[0]["Title"].ToString(); //Add Keywords Meta Tag HtmlMeta keywords = new HtmlMeta(); keywords.Ht...

Optimize integer multiplication with +/-1

Optimize integer multiplication with +/-1 Is it possible to optimize multiplication of an integer with -1/1 without using any multiplication and conditionals/branches? Can it be done only with bitwise operations and integer addition? Edit : The final goal is to optimize a scalar product of two integer vectors, where one of the vectors has only -1/1 values. Like this: i = ~i + 1; ? – alk Jul 1 at 9:32 i = ~i + 1; your suggestion negates the number with 2's completement but where is the condition (1, -1) ? – Jean-François Fabre Jul 1 at 9:35 Reading yours comments, I feel I somehow did not got the question. – alk ...

Arduino static variable declaration with no datatype? [closed]

Arduino static variable declaration with no datatype? [closed] I am quite new to Arduino and try to understand the following variable declaration: static btn_state_t nav_btn, joy_btn; First, I would expect a datatype like integer or float or the like after "static". I only found one answer that the variable then would be assigned a default type? Second, I don't understand the following comma-separated "names" or other variables. In the programm, it looks like they can be both used for "btn_state_t". I couldn't find an answer to my question so far...or maybe someone can give me a hint on what search-words to look for? Thanks Steve for the profound and complete answer below! Compleatly answered my question and his guessing was right ...that even with quite some search, I didn't find that datatype and "typedef" was the right codeword. So solved for me. Please clarify your specific problem or add additional details to highlight exactly wh...

C# Printer APIs to get the printed page number in a document [on hold]

C# Printer APIs to get the printed page number in a document [on hold] I want to ask if there is any win API function that can help in detecting the printed page number in printer jobs queue. as I know, there is a function that returns the number of printed pages, what I need to know which of the document pages are printed? Thanks Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

Realize a console in a GTK3 GUI programming in C

Realize a console in a GTK3 GUI programming in C I realized a GUI with GTK3 that, essentially, generates an input text file for an exe program that with these inputs can do elaborations. This exe is put in executions in the GUI by mean of a System call ( system("exe input.dat &") ). This exe can print on screen message of information or error. What I want to do is redirect these message on a GtkTextView. The idea that I had is to redirect output and error on a file ( system("exe input.dat > output_file.txt 2>&1 &") ) and in the GUI read line by line this file and send this strings in the textView. I was not sure that 2 process can write and read the same file and to test this concept I used these 2 simple programs: the writer (used like ./writer > out_file.txt): #include <stdio.h> #include <unistd.h> main() { int a; while(1) { fprintf(stdout,"a=%dn",a); ...

QT QLabel setPixmap from QAbstractVideoSurface

QT QLabel setPixmap from QAbstractVideoSurface I'm implementing my own class for probing video frames from QCamera under windows. It's a subclass of QAbstractVideoSurface. So, my probe generates QPixmap which I tried to draw on QLabel (as viewfinder). And I've got segmentation fault on QLabel setPixmap call. I'm sure my Qpixmap is well made, because I can save it on the disk with a save(). My QLabel is inititalized and works well, because I can load QPixmap from the disk and set it to QLabel. I guess there is problem with a format of a pixmap, but can't clue how to correct it :( My code frameprobe.h #ifndef FRAMEPROBE_H #define FRAMEPROBE_H #include <QAbstractVideoSurface> #include <QList> #include <QPixmap> class FrameProbe : public QAbstractVideoSurface { Q_OBJECT public: explicit FrameProbe(QObject *parent = 0); QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const;...

C++ QThread and connect causing crashes

C++ QThread and connect causing crashes My QThread counter crashes giving odd results for what the number should be as the Thread counts properly but in the SetLabel function I get a different number to whats in the QThread ands it then crashes after 3 seconds and the label doesnt seem to update. QThread* CountThread = new QThread; Counter* Count = new Counter(); Count->moveToThread(CountThread); connect(CountThread, SIGNAL(started()), Count, SLOT(Process())); connect(Count, &Counter::SecondsUpdate, this, [=]{ SetLabel(Count->Seconds) ;}); connect(Count, SIGNAL(finished()), CountThread, SLOT(quit())); CountThread->start(); void Counter::Process() { int secs = 0; while (secs < 1000) { qDebug() << "hello" << secs; secs += 1; Sleep(1000); emit SecondsUpdate(); } emit finished(); } void BaseWindow::SetLabel(int Seconds) { qDebug() << Seconds; this->Test->setText(QString("Seconds: " + QString::number(Seconds))); } c...

Why isn't my solution to K&R exercise 2-3 working?

Why isn't my solution to K&R exercise 2-3 working? I'm trying to solve exercise 2-3 in the book The C Programming Language , but my solution isn't working and I can't find out what I did wrong. The exercise says to write a function that takes a string containing a hexadecimal number and returns that number as an int . int Here is my code: #include <stdio.h> #include <ctype.h> #include <math.h> int htoi(char *s); int main() { char s[5]; scanf("%s", s); printf("%d", htoi(s)); } int htoi(char *s) { int length, num = 0, i; char c = 'A'; for (length = 0; c >= '0' && c <= '9' || c >= 'A' && c <= 'F'; length++) c = toupper(s[length]); for (i = 0; i <= length; i++) { c = toupper(s[i]); if (c >= '0' && c <= '9') num += (c - '0') * pow(16, length - i); else if...

Query string properties stored as XML

Query string properties stored as XML I am using Entity Framework to query a db which is defined by a model: inside this model I have several classes having a #region dynamic values : #region dynamic values [DataContract] public class Job : AbstractEntity, IJob { [DataMember] public virtual Guid Id { get; set; } ... #region dynamic values [DataMember] public virtual string MetadataValue { get; set; } [DataMember] public virtual string ParametersValue { get; set; } [DataMember] public virtual string AttributesValue { get; set; } #endregion #region links ... #endregion } AttributesValue , MetadataValue and ParametersValue are declared as string but are stored inside the db as XML documents. I am aware that this is not consistent with the model and should be changed, but for some reasons it has been managed this way and I am not allowed to modify it. I have created a Unit Test in order to better handle the problem, and here is the ...

How can I use openmp and AVX2 simultaneously with perfect answer?

How can I use openmp and AVX2 simultaneously with perfect answer? I wrote the Matrix-Vector product program using OpenMP and AVX2. However, I got the wrong answer because of OpenMP. The true answer is all of the value of array c would become 100. My answer was mix of 98, 99, and 100. The actual code is below. I compiled Clang with -fopenmp, -mavx, -mfma. #include "stdio.h" #include "math.h" #include "stdlib.h" #include "omp.h" #include "x86intrin.h" void mv(double *a,double *b,double *c, int m, int n, int l) { int k; #pragma omp parallel { __m256d va,vb,vc; int i; #pragma omp for private(i, va, vb, vc) schedule(static) for (k = 0; k < l; k++) { vb = _mm256_broadcast_sd(&b[k]); for (i = 0; i < m; i+=4) { va = _mm256_loadu_pd(&a[m*k+i]); vc = _mm256_loadu_pd(&c[i]); vc = _mm256_fmadd_pd(vc, va, vb); _mm...