Posts

Showing posts from October, 2006

How To Add Icon Button In Flutter Code Example

Example: flutter change the icon of icon button on pressed bool selected = true ; //... Widget build ( BuildContext context ) { return Scaffold ( body : Center ( child : IconButton ( icon : Icon ( selected ? Icons . celebration : Icons . title ) , onPressed : ( ) { setState ( ( ) { selected = ! selected ; } ) ; } , ) , //IconButton ) , //Center ) ; //Scaffold }

Tonumber Javascript Code Example

Example 1: how to convert string to int js let string = "1" ; let num = parseInt ( string ) ; //num will equal 1 as a int Example 2: Javascript string to int var myInt = parseInt ( "10.256" ) ; //10 var myFloat = parseFloat ( "10.256" ) ; //10.256 Example 3: string to number javascript // Method - 1 ### parseInt() ### var text = "42px" ; var integer = parseInt ( text , 10 ) ; // returns 42 // Method - 2 ### parseFloat() ### var text = "3.14someRandomStuff" ; var pointNum = parseFloat ( text ) ; // returns 3.14 // Method - 3 ### Number() ### Number ( "123" ) ; // returns 123 Number ( "12.3" ) ; // returns 12.3 Number ( "3.14someRandomStuff" ) ; // returns NaN Number ( "42px" ) ; // returns NaN Example 4: convert string to number javascript var myString = "869.99" var myFloat = parseFloat ( myString ) var myInt = parseInt ( myString ) Example

26 Inches To Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Bootstrap Horizontal Scrolling

Answer : It's okay to exceed 12 column units in a row. It causes the columns to wrap, but you can override the wrapping with flexbox. Bootstrap 4 uses flexbox, and the utility classes to get a horizontal scrolling layout.. <div class="container-fluid"> <div class="row flex-row flex-nowrap"> <div class="col-3"> .. </div> <div class="col-3"> .. </div> <div class="col-3"> .. </div> <div class="col-3"> .. </div> <div class="col-3"> .. </div> <div class="col-3"> .. </div> <div class="col-3"> .. </div> <div class="col-3"> .. </div> </div> </div>

Azure VM Load Balancing Vs Traffic Manager

Image
Answer : James, I think you already have most of it figured out. VM load balancing: Works only with VMs that are in the same region Only does Round Robin Uses a hash-based algorithm for distribution of inbound flows Works at the TCP/UDP level, routing traffic between one or more private endpoints that sit behind a public endpoint https://www.windowsazure.com/en-us/manage/windows/common-tasks/how-to-load-balance-virtual-machines/ Traffic Manager is different in that: It can work across regions It offers traffic management policies other than round robin (e.g. failover, performance) It works at the DNS level, “routing”** traffic between one or more public endpoints that sit behind a common DNS name https://azure.microsoft.com/en-us/documentation/articles/traffic-manager-manage-profiles/ You can indeed use the Load Balancer and the Traffic Manager in tandem, you hit the nail on the head there. -- Vlad ** Traffic manager does not actually route traffic, it

Cloud Function To Export Firestore Backup Data. Using Firebase-admin Or @google-cloud/firestore?

Answer : The way you're accessing the admin client is correct as far as I can tell. const client = new admin.firestore.v1.FirestoreAdminClient({}); However, you probably won't get any TypeScript/intellisense help beyond this point since the Firestore library does not actually define detailed typings for v1 RPCs. Notice how they are declared with any types: https://github.com/googleapis/nodejs-firestore/blob/425bf3d3f5ecab66fcecf5373e8dd03b73bb46ad/types/firestore.d.ts#L1354-L1364 Here is an implementation I'm using that allows you to do whatever operations you need to do, based on the template provided by firebase here https://firebase.google.com/docs/firestore/solutions/schedule-export In my case I'm filtering out collections from firestore I don't want the scheduler to automatically backup const { Firestore } = require('@google-cloud/firestore') const firestore = new Firestore() const client = new Firestore.v1.FirestoreAdminClient() const bu

Circular Avatar Is In Square Flutter Code Example

Example: how to make an image contained in circle avatar in flutter CircleAvatar( radius: 30.0, backgroundImage: NetworkImage("${snapshot.data.hitsList[index].previewUrl}"), backgroundColor: Colors.transparent, )

Cin Char In C++ Code Example

Example 1: input a string in c++ string fullName ; cout << "Type your full name: " ; getline ( cin , fullName ) ; cout << "Your name is: " << fullName ; Example 2: cin syntax in c++ cin >> varName ;

Can You Just Update A Partial View Instead Of Full Page Post?

Answer : Not without jQuery. What you would have to do is put your Partial in a div, something like: <div id="partial"> @Html.Partial("YourPartial") </div> Then, to update (for example clicking a button with the id button ), you could do: $("#button").click(function () { $.ajax({ url: "YourController/GetData", type: "get", data: $("form").serialize(), //if you need to post Model data, use this success: function (result) { $("#partial").html(result); } }); }) Then your action would look something like: public ActionResult GetData(YourModel model) //that's if you need the model { //do whatever return View(model); } Actually, if your Partial has a child action method, you can post (or even use an anchor link) directly to the child action and get an Ajax-like affect. We do this in several Views. The syntax is @Html.Action

Python Logging To File And Stdout Code Example

Example 1: python logging to file import logging import sys logger = logging . getLogger ( ) logger . setLevel ( logging . INFO ) formatter = logging . Formatter ( '%(asctime)s | %(levelname)s | %(message)s' , '%m-%d-%Y %H:%M:%S' ) stdout_handler = logging . StreamHandler ( sys . stdout ) stdout_handler . setLevel ( logging . DEBUG ) stdout_handler . setFormatter ( formatter ) file_handler = logging . FileHandler ( 'logs.log' ) file_handler . setLevel ( logging . DEBUG ) file_handler . setFormatter ( formatter ) logger . addHandler ( file_handler ) logger . addHandler ( stdout_handler ) Example 2: python logging to file import logging "" " DEBUG INFO WARNING ERROR CRITICAL "" " # asctime : time of the log was printed out # levelname : name of the log # datefmt : format the time of the log # give DEBUG log logging . basicConfig ( format = '%(asctime)s %(levelnam

36 Inches To Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Blazor Project Structure / Best Practices

Image
Answer : I just created a new ASP .NET Core 3.1 project with 3 web apps: MVC, Razor Pages and Blazor. NetLearner: https://github.com/shahedc/NetLearnerApp I’m developing all 3 in parallel so that you can see similar functionality in all of them. I’ve extracted common items into a Shared Library for easy sharing. The shared library includes: Core items (Models and Services) Infrastructure items (Db context and Migrations) Here’s the corresponding blog writeup, which will be followed by an A-Z weekly series, which will explore 26 different topics in the next 6 months. blog post: https://wakeupandcode.com/netlearner-on-asp-net-core-3-1/ Hope the current version is useful for what you’re asking for. Stay tuned and feel free to make suggestions or provide feedback on the project structure. So I was diving into looking for more example projects and I came across a SPA Server Side Dapper application (https://www.c-sharpcorner.com/article/create-a-blazor-server-spa-wit

Add Css Using Jquery Code Example

Example 1: jquery add style //revising Ankur's answer //Syntax: $ ( selector ) . css ( { property - name : property - value } ) ; //Example: $ ( '.bodytext' ) . css ( { 'color' : 'red' } ) ; Example 2: jquery css $ ( '#element' ) . css ( 'display' , 'block' ) ; /* Single style */ $ ( '#element' ) . css ( { 'display' : 'block' , 'background-color' : '#2ECC40' } ) ; /* Multiple style */ Example 3: jquery add css $ ( '#start' ) . css ( { 'font-weight' : 'bold' } ) ; Example 4: set css using jquery $ ( '.name' ) . css ( 'color' : 'blue' ) ; Example 5: add css file through jquery $ ( 'head' ) . append ( '<link rel="stylesheet" href="style2.css" type="text/css" />' ) ; Example 6: edit css jquery $ ( '.ama' ) . css ( 'color' , 'red' ) ;
Answer : The announcement of systemd-timesyncd in the systemd NEWS file does a good job of explaining the differences of this tool in comparison with Chrony and tools like it. (emphasis mine): A new "systemd-timesyncd" daemon has been added for synchronizing the system clock across the network. It implements an SNTP client . In contrast to NTP implementations such as chrony or the NTP reference server this only implements a client side, and does not bother with the full NTP complexity, focusing only on querying time from one remote server and synchronizing the local clock to it . Unless you intend to serve NTP to networked clients or want to connect to local hardware clocks this simple NTP client should be more than appropriate for most installations. [...] This setup is a common use case for most hosts in a server fleet. They will usually get synchronized from local NTP servers, which themselves get synchronized from multi
Note This module is part of ansible-base and included in all Ansible installations. In most cases, you can use the short module name include even without specifying the collections: keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name. New in version 0.6: of ansible.builtin Synopsis Parameters Notes See Also Examples Synopsis Includes a file with a list of plays or tasks to be executed in the current playbook. Files with a list of plays can only be included at the top level. Lists of tasks can only be included where tasks normally run (in play). Before Ansible 2.0, all includes were ‘static’ and were executed when the play was compiled. Static includes are not subject to most directives. For example, loops or conditionals are applied instead to each inherited task. Since Ansible 2.0, task includes are dynamic and behave more like real

Changing Image Size In Markdown

Answer : You could just use some HTML in your Markdown: <img src="drawing.jpg" alt="drawing" width="200"/> Or via style attribute ( not supported by GitHub ) <img src="drawing.jpg" alt="drawing" style="width:200px;"/> Or you could use a custom CSS file as described in this answer on Markdown and image alignment ![drawing](drawing.jpg) CSS in another file: img[alt=drawing] { width: 200px; } With certain Markdown implementations (including Mou and Marked 2 (only macOS)) you can append =WIDTHxHEIGHT after the URL of the graphic file to resize the image. Do not forget the space before the = . ![](./pic/pic1_50.png =100x20) You can skip the HEIGHT ![](./pic/pic1s.png =250x) The accepted answer here isn't working with any Markdown editor available in the apps I have used till date like Ghost, Stackedit.io or even in the StackOverflow editor. I found a workaround here in the StackEdit.io iss

Big Square Bracket Latex Code Example

Example: brackets equation latex \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} D_{it} = \begin{cases} 1 & \text{if bank $i$ issues ABs at time $t$}\\ 2 & \text{if bank $i$ issues CBs at time $t$}\\ 0 & \text{otherwise} \end{cases} \end{equation} \end{document}

'charmap' Codec Can't Encode Character '\u200b' In Position 2252: Character Maps To Code Example

Example: charmap' codec can't encode character '\u010d' in position 97: character maps to import io with io . open ( fname , "w" , encoding = "utf-8" ) as f : f . write ( html )

10101 Binary To Decimal Code Example

Example 1: binary to decimal double binaryToDecimal ( char binary [ DIM ] ) { char binary2 [ DIM ] = "" , floa [ DIM ] = "" ; double decimal = 0 , negDec = 0 , flo = 0 ; int count = 0 , j = 0 , i = 0 , f = 0 , g = 0 , h = 0 , count1 = 0 , d = 0 , k = 0 ; while ( binary [ d ] != '\0' && binary [ d ] != '.' ) { d ++ ; } d -- ; if ( binary [ 0 ] == '-' ) { while ( binary [ k ] != '\0' ) { binary [ k ] = binary [ k + 1 ] ; k ++ ; } k = 0 ; while ( binary [ k ] == '0' ) { d -- ; k ++ ; } negDec = pot ( 2.000 , d * 1.000 , 1 ) ; } while ( binary [ i ] != '\0' && binary [ i ] != '.' ) { i ++ ; } i -- ; count = i ; h = i ; while ( binary [ h ] != '\0' ) { floa [ g ] = binary [ h + 2 ] ; g ++ ; h ++ ; } g -- ; count1 = g ; w

Angular 5 NgHide NgShow [hidden] Not Working

Answer : If you want to just toggle visibility and still keep the input in DOM: <input class="txt" type="password" [(ngModel)]="input_pw" [style.visibility]="isHidden? 'hidden': 'visible'"> The other way around is as per answer by rrd, which is to use HTML hidden attribute. In an HTML element if hidden attribute is set to true browsers are supposed to hide the element from display, but the problem is that this behavior is overridden if the element has an explicit display style mentioned. .hasDisplay { display: block; } <input class="hasDisplay" hidden value="shown" /> <input hidden value="not shown"> To overcome this you can opt to use an explicit css for [hidden] that overrides the display; [hidden] { display: none !important; } Yet another way is to have a is-hidden class and do: <input [class.is-hidden]="isHidden"/> .is-hidden {

Bootstrap 3 W3schools Code Example

Example: bootstrap < nav class = "navbar navbar-expand-lg navbar-light bg-light" > < a class = "navbar-brand" href = "#" > Navbar < / a > < button class = "navbar-toggler" type = "button" data - toggle = "collapse" data - target = "#navbarSupportedContent" aria - controls = "navbarSupportedContent" aria - expanded = "false" aria - label = "Toggle navigation" > < span class = "navbar-toggler-icon" > < / span > < / button > < div class = "collapse navbar-collapse" id = "navbarSupportedContent" > < ul class = "navbar-nav mr-auto" > < li class = "nav-item active" > < a class = "nav-link" href = "#" > Home < span class = "sr-only" > ( current ) < / span > < / a > < / li

Add SATA Port To Motherboard?

Answer : You can download the free hwinfo32 app and run it. Look under motherboard, and the SATA ports that are live and supported will be listed. If there is a label next to the solder ports (like "SATA 1, SATA 2, etc.), then you can see if that port is active. If it is, you are good to go (as long as you are as good at soldering as you think you are). I disagree with the naysayers above. While SATA connectors themselves are extremely cheap, many laptop manufacturers contract out the assembly of their motherboards, and they are charged by the component or by the solder joint. In those terms the cost of the connector is less trivial, and it makes a bit more sense to not include it. Motherboard layout is expensive enough that computer companies will use the same layout for multiple versions of a board, just without adding all the components to all of them, so those motherboard traces almost certainly lead to the SATA chip. There's no reason in principle this wouldn