Posts

Showing posts from February, 2016

Can I Use HttpClientFactory In A .NET.core App Which Is Not ASP.NET Core?

Answer : According to the documentation HttpClientFactory is a part of .Net Core 2.1, so you don't need ASP.NET to use it. And there some ways to use are described. The easiest way would be to use Microsoft.Extensions.DependencyInjection with AddHttpClient extension method. static void Main(string[] args) { var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider(); var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>(); var client = httpClientFactory.CreateClient(); } Thanks for replies. So it is possible to use in console app. There are a few ways to do this, depending on what way you want to go. Here are 2: Directly add to ServiceCollection e.g. services.AddHttpClient() Use Generic host e.g. Add httpclientFactory in .ConfigureServices() method See here for blog post using in console app As one of the answers suggests, you do not need ASP.NET to use it However, you need a bit of work to ge

Set Cursor Size Css Code Example

Example: css cursor size cursor : url ( one.svg ) , url ( two.svg ) 5 5 , progress ;

All The Whitespace Characters? Is It Language Independent?

Answer : Whether a particular character is categorized as a whitespace character or not should depend on the character set being used. That said, it is not impossible that a programming language can make its own definition of what constitutes whitespace. Most modern languages use the Unicode Character set, which does have a definition for space separator characters . Any character in the Zs category is a space separator . You can see the complete list here. In addition you can grep for ;Zs; in the official Unicode Character Database to see those characters. Note that the number of characters in this category may grow as new Unicode versions come into existence, so I will not say how many such characters exist, nor even attempt to list them. In addition to the Zs Unicode category , Unicode also defines character properties . Among the properties defined by Unicode is a Whitespace property. As of Unicode 7.0, characters with this property include all of the characters wi

Creating Two Columns In Beamer

Image
Answer : You forgot to give the mandatory width to the second column, and you included an unnecessary width= in the width for the first column. \documentclass[demo]{beamer} \begin{document} \begin{frame} \frametitle{explanation} \begin{columns} \begin{column}{0.5\textwidth} some text here some text here some text here some text here some text here \end{column} \begin{column}{0.5\textwidth} %%<--- here \begin{center} \includegraphics[width=0.5\textwidth]{image1.jpg} \end{center} \end{column} \end{columns} \end{frame} \end{document} Also note that the graphics need not be scaled down as much in the second column. The column becomes a minipage , so \textwidth is already adjusted to its width. \documentclass[demo]{beamer} \begin{document} \begin{frame} \frametitle{explanation} \begin{columns} \begin{column}{0.5\textwidth} some text here some text here some text here some text here some text here \end{column} \begin{column}{0.5\textwidth} \begin{center}

Add Onclick Event Handler To Button Using Jquery Code Example

Example 1: on click jquery $ ( " #target " ) .click ( function ( ) { alert ( "Handler for .click() called." ) ; } ) ; Example 2: set onclick jquery $ ( elem ) . click ( myFunc ( ) ) ;

Byg Minecraft Mod Code Example

Example: what is a minecraft mod A Minecraft mod is a .jar type file, when used in combination with a Modloader like forge that mod will have the power to add/remove/edit features of the default game, EG a horse mod could add many new breeds of horse A space mod (galacticraft is EPIC) could add new planets and spaceships

CSS Font "Helvetica Neue"

Answer : It's a default font on Macs, but rare on PCs. Since it's not technically web-safe, some people may have it and some people may not. If you want to use a font like that, without using @font-face, you may want to write it out several different ways because it might not work the same for everyone. I like using a font stack that touches on all bases like this: font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; This recommended font-family stack is further described in this CSS-Tricks snippet Better Helvetica which uses a font-weight: 300; as well. This font is not standard on all devices. It is installed by default on some Macs, but rarely on PCs and mobile devices. To use this font on all devices, use a @font-face declaration in your CSS to link to it on your domain if you wish to use it. @font-face { font-family: Delicious; src: url('Delicious-Rom

Get The Size Of An Array Python Code Example

Example 1: size array python size = len ( myList ) Example 2: python get array length # To get the length of a Python array , use 'len()' a = arr . array ( ‘d’ , [ 1.1 , 2.1 , 3.1 ] ) len ( a ) # Output : 3

How To Print Binary Value Of An Integer In C Code Example

Example: print binary in c # include <iostream> using namespace std ; int main ( ) { long n , d , r , binary = 0 ; n = 10 ; d = n ; int temp = 1 ; while ( n != 0 ) { r = n % 2 ; n = n / 2 ; binary = binary + r * temp ; temp = temp * 10 ; } printf ( "%ld" , binary ) ; return 0 ; }

Convert Ipynb To Pdf In Jupyter

Answer : A simple and surprisingly good solution is to print the notebook to pdf through the browser with ctrl+p . Just make sure your plots and figures are not on interactive mode otherwise they will not be displayed (set them to %matplotlib inline ). Exporting jupyter notebooks through latex is quite troublesome and takes a lot of tinkering to get something remotely close to publish ready. When I absolutely need publication quality I do it on a latex editor, but this tutorial goes in great length about doing it on jupyter. A few useful tips to get better results: Higher resolution plots Hide your code-cells from the pdf Take a look at these extensions to improve your jupyter documents For Mac OS X, the solution for me was to install MacTex first and then export the path to find it: ### TeX export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH" You can add this to your .bash_profile or similar config file to load it every time. See more here

Time Complexity Of Sorting Algorithms Code Example

Example: what is time complexity of insertion sort Time Complexity is : If the inversion count is O ( n ) , then the time complexity of insertion sort is O ( n ) . Some Facts about insertion sort : 1. Simple implementation : Jon Bentley shows a three - line C version , and a five - line optimized version [ 1 ] 2. Efficient for ( quite ) small data sets , much like other quadratic sorting algorithms 3. More efficient in practice than most other simple quadratic ( i . e . , O ( n2 ) ) algorithms such as selection sort or bubble sort 4. Adaptive , i . e . , efficient for data sets that are already substantially sorted : the time complexity is O ( kn ) when each element in the input is no more than k places away from its sorted position 5. Stable ; i . e . , does not change the relative order of elements with equal keys 6. In - place ; i . e . , only requires a constant amount O ( 1 ) of additional memory space Online ; i . e . , can sort a list a

Access To XMLHttpRequest At 'http://localhost:8081/api/v1/plans' From Origin 'http://localhost:4200' Has Been Blocked By CORS Policy: Request Header Field Content-type Is Not Allowed By Access-Control-Allow-Headers In Preflight Response. Code Example

Example: Access to XMLHttpRequest at 'http://localhost/MySQL_pracs/InsertUser.php' from origin 'http://localhost:4200' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. //Access to XMLHttpRequest at 'http://localhost/[api path].php' from origin 'http://localhost:4200' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. //The error is simply saying that "Content-Type" is missing from "Access-Control-Allow-Headers". //Therefore we need to add "Content-Type" to "Access-Control-Allow-Headers". < ? php header ( 'Access-Control-Allow-Headers: Content-Type' ) ; -- -- - ? >

Add Ripple Effect To My Button With Button Background Color?

Answer : Here is another drawable xml for those who want to add all together gradient background, corner radius and ripple effect: <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/colorPrimaryDark"> <item android:id="@android:id/mask"> <shape android:shape="rectangle"> <solid android:color="@color/colorPrimaryDark" /> <corners android:radius="@dimen/button_radius_large" /> </shape> </item> <item android:id="@android:id/background"> <shape android:shape="rectangle"> <gradient android:angle="90" android:endColor="@color/colorPrimaryLight" android:startColor="@color/colorPrimary"

Bootstrap Input File Upload Code Example

Example 1: bootstrap input file <div class= "custom-file" > <input type= "file" class= "custom-file-input" id= "inputGroupFile01" > <label class= "custom-file-label" for= "inputGroupFile01" >Choose file</label> </div> Example 2: bootstrap file upload <form> <div class= "form-group" > <label for= "exampleFormControlFile1" >Example file input</label> <input type= "file" class= "form-control-file" id= "exampleFormControlFile1" > </div> </form>

Convert Unsigned Char To Int C++ Code Example

Example 1: converting char to integer c++ int x = '9' - 48 ; // x now equals 9 as an integer Example 2: converting char to int in c++ # include <sstream> using namespace std ; int main ( ) { stringstream str ; str << "1" ; double x ; str >> x ; }

C# Split String Word Delimiter Code Example

Example 1: split using string c# //Split using a string delimiter instead of a char data . Split ( new string [ ] { "xx" } , StringSplitOptions . None ) ; Example 2: parse strings into words C# string text = "Hello World!" string [ ] textSplit = text . Split ( ) ;

Convert String To Int64 Golang Code Example

Example 1: golang convert string to int64 s := "97" n , err := strconv . ParseInt ( s , 10 , 64 ) if err == nil { fmt . Printf ( "%d of type %T" , n , n ) } Example 2: int to int64 golang var i int = 32 j := int64 ( i )

Ajax - JSON Doesnt Get Sent In PATCH Only

Answer : First, check that you use latest version of jQuery library: Older versions directly restrict unknown methods (PATCH is new one). I've tested on jQuery 1.7 - PATCH method working without problems. Second, not all browsers supports PATCH method using XMLHttpRequest: Like, IE 7,8 (9+ works okay) have XMLHttpRequest, but it throws an error on PATCH: new XMLHttpRequest().open('PATCH', '/'); //Illegal argument To fix this, you may force jQuery to use the old proprietary ActiveXObject xhr, like so: $.ajax({ url : 'http://127.0.0.1:8001/api/v1/pulse/7/', data : data, type : 'PATCH', contentType : 'application/json', xhr: function() { return window.XMLHttpRequest == null || new window.XMLHttpRequest().addEventListener == null ? new window.ActiveXObject("Microsoft.XMLHTTP") : $.ajaxSettings.xhr(); } }); A bit late, but this worked for me when I got

Does Cmath Pow Have Limit Code Example

Example 1: pow c++ # include <iostream> # include <cmath> using namespace std ; int main ( ) { double base , exponent , result ; base = 3.4 ; exponent = 4.4 ; result = pow ( base , exponent ) ; cout << base << "^" << exponent << " = " << result ; return 0 ; } Example 2: c++ power /* pow example */ # include <stdio.h> /* printf */ # include <math.h> /* pow */ int main ( ) { printf ( "7 ^ 3 = %f\n" , pow ( 7.0 , 3.0 ) ) ; printf ( "4.73 ^ 12 = %f\n" , pow ( 4.73 , 12.0 ) ) ; printf ( "32.01 ^ 1.54 = %f\n" , pow ( 32.01 , 1.54 ) ) ; return 0 ; }

Css Font Smoothing Antialiased Code Example

Example: what css font smoothing The font-smooth CSS property controls the application of anti-aliasing when fonts are rendered. This feature is non-standard and is not on a standards track. It depends on the browser used and the system specifications ; thus , it may not work for every user.

Get Child With Name Unity Code Example

Example 1: find child of gameobject unity gameObject . transform . Find ( "ChildGameObject" ) . gameObject ; //This insures that you are finding the child instead of finding another //GameObject's Child. Example 2: unity get child GameObject Child ; Child = transform . GetChild ( 0 ) . gameObject ; Example 3: unity how to get a child from a gameobject //For unity engine GameObject . transform . GetChild ( The child index ) . transform ; Example 4: unity get child gameobject //Instantiate Prefab GameObject originalGameObject = Instantiate ( prefab ) ; //To find `child1` which is the first index(0) GameObject child2 = originalGameObject . transform . GetChild ( 0 ) . gameObject ; //To find `child2` which is the second index(1) GameObject child2 = originalGameObject . transform . GetChild ( 1 ) . gameObject ; //To find `child3` which is the third index(2) GameObject child3 = originalGameObject . transform . GetChild ( 2 ) . gameObject ; Example 5: get gameobje