Posts

Showing posts from August, 2008

Architecture Flask Vs FastAPI

Answer : This seemed a little interesting, so i ran a little tests with ApacheBench : Flask from flask import Flask from flask_restful import Resource, Api app = Flask(__name__) api = Api(app) class Root(Resource): def get(self): return {"message": "hello"} api.add_resource(Root, "/") FastAPI from fastapi import FastAPI app = FastAPI(debug=False) @app.get("/") async def root(): return {"message": "hello"} I ran 2 tests for FastAPI, there was a huge difference: gunicorn -w 4 -k uvicorn.workers.UvicornWorker fast_api:app uvicorn fast_api:app --reload So here is the benchmarking results for 5000 requests with a concurrency of 500: FastAPI with Uvicorn Workers Concurrency Level: 500 Time taken for tests: 0.577 seconds Complete requests: 5000 Failed requests: 0 Total transferred: 720000 bytes HTML transferred: 95000 bytes Requests per second: 8665.48 [#/sec]

Arduino Define Variable Code Example

Example: How do I define variables in arduino int variableName = 0;

88 Cm To Inches Code Example

Example: cm to inch 1 cm = 0.3937 inch

Change Margin Programmatically In WPF / C#

Answer : test.Margin = new Thickness(0, -5, 0, 0); Alignment, Margins and Padding Overview (MSDN) FrameworkElement.Margin (MSDN) test.Margin = new Thickness(0, 0, 0, 0); test.Margin = new Thickness(-5);

Change The Default Markdown Text Color In Jupyter Notebook Code Example

Example 1: jupyter markdown red color $\color{red}{\text{Text Message}}$ Example 2: python jupyter markdown color I am a < font color = ' red ' > red </ font > apple. # Warning : deprecated by HTML5, but the only one usable on a jupyter notebook.

Collapse Navbar Into Hamburger Menu Bootstrap Code Example

Example 1: bootstrap hamburger menu < script src = " https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js " > </ script > < script src = " https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js " > </ script > < link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css " > < nav class = " navbar navbar-inverse navbar-static-top " role = " navigation " > < div class = " container " > < div class = " navbar-header " > < button type = " button " class = " navbar-toggle collapsed " data-toggle = " collapse " data-target = " #bs-example-navbar-collapse-1 " > < span class = " sr-only " > Toggle navigation </ span > < s

Add Onclick Event To SVG Element

Answer : It appears that all of the JavaScript must be included inside of the SVG for it to run. I was unable to reference any external function, or libraries. This meant that your code was breaking at svgstyle = svgobj.getStyle(); This will do what you are attempting. <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='600' width='820'> <script type="text/ecmascript"><![CDATA[ function changerect(evt) { var svgobj=evt.target; svgobj.style.opacity= 0.3; svgobj.setAttribute ('x', 300); } ]]> </script> <rect onclick='changerect(evt)' style='fill:blue;opacity:1' x='10' y='30' width='100'height='100' /> </sv

Arrow Png Icon Code Example

Example: icon for right arrow <link rel= "stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css" > <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" ></script> <script src= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js" ></script> <span class= "glyphicon glyphicon-circle-arrow-right" ></span>

(413) Request Entity Too Large | UploadReadAheadSize

Answer : That is not problem of IIS but the problem of WCF. WCF by default limits messages to 65KB to avoid denial of service attack with large messages. Also if you don't use MTOM it sends byte[] to base64 encoded string (33% increase in size) => 48KB * 1,33 = 64KB To solve this issue you must reconfigure your service to accept larger messages. This issue previously fired 400 Bad Request error but in newer version WCF started to use 413 which is correct status code for this type of error. You need to set maxReceivedMessageSize in your binding. You can also need to set readerQuotas . <system.serviceModel> <bindings> <basicHttpBinding> <binding maxReceivedMessageSize="10485760"> <readerQuotas ... /> </binding> </basicHttpBinding> </bindings> </system.serviceModel> I was having the same issue with IIS 7.5 with a WCF REST Service. Trying to upload via POST any file above 65k

C++ Vector Pop Front Code Example

Example 1: c++ vector pop first element std :: vector < int > vect ; vect . erase ( vect . begin ( ) ) ; Example 2: vector erase specific element vector . erase ( vector . begin ( ) + 3 ) ; // Deleting the fourth element Example 3: delete from front in vector c++ // Deleting first element vector_name . erase ( vector_name . begin ( ) ) ; // Deleting xth element from start vector_name . erase ( vector_name . begin ( ) + ( x - 1 ) ) ; // Deleting from the last vector_name . pop_back ( ) ; Example 4: vector erase specific element template < typename T > void remove ( std :: vector < T > & vec , size_t pos ) { std :: vector < T > :: iterator it = vec . begin ( ) ; std :: advance ( it , pos ) ; vec . erase ( it ) ; }

All Bfb Assets Code Example

Example: all bfb assets Just a picture of the two together... c:Read More

ABSPATH Or __FILE__?

Answer : I would personally prefer dirname() as it is always guaranteed to give me the correct result, while the ABSPATH method relies on a fixed theme path and theme name that can both change. By the way, you can use __DIR__ instead of dirname(__FILE__) . The path to the "wp-content" directory and its subdirectories can be different in a particular WordPress installation. Also, using the WordPress internal constants (such as ABSPATH ) is not recommended. See the Determining Plugin and Content Directories WordPress Codex article. Since PHP 4.0.2, symlinks are being resolved for the __FILE__ and __DIR__ magic constants, so take that into account. Bottom line : To determine the absolute path to a theme directory, I would suggest to use the get_template_directory() function which also applies filters and internally combines get_theme_root() and get_template() . For my own projects I would choose dirname(__FILE__) , also there is a new constant in PHP: __DIR__

Alert Message In Php W3schools Code Example

Example: simple alert program in javascript alert("this is the alert")

Body-parser Is Deprecated 2021 Code Example

Example 1: body parser deprecated const express = require ( 'express' ) ; app . use ( express . urlencoded ( { extended : true } ) ) ; app . use ( express . json ( ) ) ; Example 2: body-parser deprecated app . use ( bodyParser . urlencoded ( ) ) ; app . use ( bodyParser . json ( ) ) ; Example 3: body parser deprecated const bodyParser = require ( 'body-parser' ) ; app . use ( bodyParser . urlencoded ( { extended : true } ) ) ; app . use ( bodyParser . json ( ) ) ;

Std::distance Include Code Example

Example: std distance // Calculates the number of elements between first and last. # include <iterator> // std::distance # include <vector> // std::vector # include <algorithm> // Just if you use std::find vector < int > arr = { 2 , 5 , 3 , 8 , 1 } ; int size = std :: distance ( arr . begin ( ) , arr . end ( ) ) ; // 5 auto it = std :: find ( arr . begin ( ) , arr . end ( ) , 8 ) ; int position = std :: distance ( arr . begin ( ) , it ) ; // 3

Format Specifier For Double Code Example

Example 1: format specifier fro float in printf printf ( "%0k.yf" float_variable_name ) Here k is the total number of characters you want to get printed . k = x + 1 + y ( + 1 for the dot ) and float_variable_name is the float variable that you want to get printed . Suppose you want to print x digits before the decimal point and y digits after it . Now , if the number of digits before float_variable_name is less than x , then it will automatically prepend that many zeroes before it . Example 2: what are format specifiers it is used during taking input and out put Int ( "%d" ) : Long ( "%ld" ) : Char ( "%c" ) : Float ( "%f" ) : Double ( "%lf" ) example : char ch = 'd' ; double d = 234.432 ; printf ( "%c %lf" , ch , d ) ; char ch ; double d ; scanf ( "%c %lf" , & ch , & d ) ; Example 3: double data type format in c % lf you can try

Angry Ip Scanner Mac Code Example

Example: Angry IP Scanner It's an IP Scanner to find open ports in the server and vulnerabelities

When We Implement Stack Using Linked List Then Insertion Of Node Is Done Code Example

Example 1: implement stack using link list in c # include <stdio.h> # include <stdlib.h> # define TRUE 1 # define FALSE 0 struct node { int data ; struct node * next ; } ; typedef struct node node ; node * top ; void initialize ( ) { top = NULL ; } void push ( int value ) { node * tmp ; tmp = malloc ( sizeof ( node ) ) ; tmp -> data = value ; tmp -> next = top ; top = tmp ; } int pop ( ) { node * tmp ; int n ; tmp = top ; n = tmp -> data ; top = top -> next ; free ( tmp ) ; return n ; } int Top ( ) { return top -> data ; } int isempty ( ) { return top == NULL ; } void display ( node * head ) { if ( head == NULL ) { printf ( "NULL\n" ) ; } else { printf ( "%d\n" , head -> data ) ; display ( head -> next ) ; } } int mai

C++ Random Number Generator 1-10 Code Example

Example: c++ random number between 1 and 10 cout << ( rand ( ) % 10 ) + 1 << " " ;