Posts

Showing posts from January, 2002

Can You Catch All Errors Of A React.js App With A Try/catch Block?

Answer : React 16 introduced Error Boundaries and the componentDidCatch lifecycle method: class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } componentDidCatch(error, info) { // Display fallback UI this.setState({ hasError: true }); // You can also log the error to an error reporting service logErrorToMyService(error, info); } render() { if (this.state.hasError) { // You can render any custom fallback UI return <h1>Something went wrong.</h1>; } return this.props.children; } } Then you can use it as a regular component: <ErrorBoundary> <MyWidget /> </ErrorBoundary> Or you can wrap your root component with the npm package react-error-boundary, and set a fallback component and behavior. import {ErrorBoundary} from 'react-error-boundary'; const myErrorHandler = (error: Error, componentStack: string) => { //

Tailwind Css Animations Examples

Example: tailwind icon animation <span class= "flex h-3 w-3" > <span class= "animate-ping absolute inline-flex h-full w-full rounded-full bg-purple-400 opacity-75" ></span> <span class= "relative inline-flex rounded-full h-3 w-3 bg-purple-500" ></span> </span>

Converting Custom Object Arrays To String Arrays In Powershell

Answer : This will give you what you want: $strArray = $ms | Foreach {"$($_.Option)$($_.Title)"} Select-Object is kind of like an SQL SELECT. It projects the selected properties onto a new object (pscustomobject in v1/v2 and Selected.<orignalTypeName> in V3). Your second approach doesn't work, because $_.Option in a string will only "interpolate" the variable $_ . It won't evaluate the expression $_.Option . You can get double-quoted strings to evaluate expressions by using subexpressions, for example, " ( . . . ) " o r " (...)" or " ( ... ) " or " ($_.Option)".

Print Bits In C Code Example

Example: how to print int in c # include <stdio.h> int main ( ) { int number ; printf ( "Enter an integer: " ) ; scanf ( "%d" , & number ) ; printf ( "You entered: %d" , number ) ; return 0 ; }

Css Visibility Transition Delay Code Example

Example: css transition visibility .m-fadeOut { visibility : hidden ; opacity : 0 ; transition : visibility 0 s linear 300 ms , opacity 300 ms ; } .m-fadeIn { visibility : visible ; opacity : 1 ; transition : visibility 0 s linear 0 s , opacity 300 ms ; }

Responsive Css W3schools Code Example

Example 1: html responsive <meta name= "viewport" content= "width=device-width, initial-scale=1.0" > Example 2: responsive html @media ( max-width : 530 px ) { .CLASSHERE { padding : 10 px 110 px ; margin-left : 365 px ; margin-bottom : 30 px ; font-size : medium ; text-align : center ; } }

Gizmo Unity Code Example

Example: how to set a gizmo color unity void OnDrawGizmos ( ) { Gizmos . color = Color . red ; }

Windows Azure Storage Emulator Download Code Example

Example: azure storage emulator config Account name : devstoreaccount1 Account key : Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq / K1SZFPTOtr / KBHBeksoGMGw ==

Font: Outline Css Code Example

Example 1: css text outline /* You have 2 options The first is experimental */ /* text-stroke */ #example { font-size : 1 em ; -webkit-text-stroke : 1 px #000000 ; } /* Use 4 shadows Probably best to use this until the above is standardised */ #example { font-size : 1 em ; text-shadow : -1 px -1 px 0 #000 , 1 px -1 px 0 #000 , -1 px 1 px 0 #000 , 1 px 1 px 0 #000 ; } Example 2: how to apply outline to text in html css #example3 { color : black ; font-size : 34 px ; -webkit-text-stroke : 1 px black ; -webkit-text-fill-color : white ; }

Componentdidmount Example

Example 1: use effect like component did mount useEffect(() => { console.log('I am the new componentDidMount') }, []) // Don't forget the empty array at the end Example 2: component did update arguments componentDidUpdate(prevProps, prevState) { // only update chart if the data has changed if (prevProps.data !== this.props.data) { this.chart = c3.load({ data: this.props.data }); } } Example 3: react native class component constructor import React from 'react'; import { View, TextInput } from "react-native"; class App extends React.Component { constructor(props){ super(props); this.state = { name: "" } this.handleChange = this.handleChange.bind(this); } handleChange(text){ this.setState({ name: text }) console.log(this.props); } render() { return ( < View > <TextInput value={this.state.name} onChangeText={(text) =>this.handleChan

Conda Reinstall Specific Package Version Code Example

Example: conda import specific version conda install = #for example conda install matplotlib=1.4.3

Js Open A New Window Code Example

Example 1: javascript open new window <a onclick= "window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');" > Open New Window </a> Example 2: open new window javascript window. open ( "LINK-HERE" ) ; Example 3: open new window in java script <script type= "text/javascript" > var windowObjectReference = null ; // global variable function openRequestedPopup ( url , windowName ) { if ( windowObjectReference == null || windowObjectReference .closed ) { windowObjectReference = window. open ( url , windowName , "resizable,scrollbars,status" ) ; } else { windowObjectReference. focus ( ) ; } ; } </script> ( ... ) <p><a href= "http://www.spreadfirefox.com/" target= "PromoteFirefoxWindow" onclick= "openRequestedPopup(this.href, this.target); return false;" title= "This link will create a new

Button OnClick In Script Unity Code Example

Example 1: unity assign button onclick public Button yourButton ; void Start ( ) { Button btn = yourButton . GetComponent < Button > ( ) ; //Grabs the button component btn . onClick . AddListener ( TaskOnClick ) ; //Adds a listner on the button } void TaskOnClick ( ) { Debug . Log ( "You have clicked the button!" ) ; } Example 2: how to code button click unity using UnityEngine ; using UnityEngine . UI ; using System . Collections ; public class ClickExample : MonoBehaviour { public Button yourButton ; void Start ( ) { Button btn = yourButton . GetComponent < Button > ( ) ; btn . onClick . AddListener ( TaskOnClick ) ; } void TaskOnClick ( ) { Debug . Log ( "You have clicked the button!" ) ; } }

Can Zuul Edge Server Be Used Without Eureka / Ribbon

Answer : Yes, it is totally possible.You have to use @EnableZuulProxy on your config class and config it something like this : zuul: routes: yourService: path: /yourService/** serviceId: yourService ribbon: eureka: enabled: false yourService: ribbon: listOfServers: localhost:8080 A sample usage can be like this: shared.microservice.customer.service1.url=zttp://127.0.0.1:8080/shared/microservice/customer/ shared.microservice.customer.service2.url=zttp://127.0.0.1:8181/shared/microservice/customer/ ribbon.eureka.enabled = false zuul.routes.customer-micro-service.path: /shared/microservice/customer/** zuul.routes.customer-micro-service.serviceId: customers customers.ribbon.listOfServers = zttp://ip:port1/shared/microservice/customer/,zttp://ip2:port2/shared/microservice/customer/

2d Matrix Vector C++ Code Example

Example 1: initializing 2d vector vector < vector < int > > vec ( n , vector < int > ( m , 0 ) ) ; Example 2: 2d vector #include <bits/stdc++.h> using namespace std ; int main ( ) { int rows = 2 ; int cols = 2 ; int val = 1 ; vector < vector < int > > v ( rows , vector < int > ( cols , val ) ) ; /*creates 2d vector “v[rows][cols]” and initializes all elements to “val == 1” (default value is 0)*/ v [ 0 ] [ 0 ] = 5 ; v [ 1 ] [ 1 ] = 4 ; cout << v [ 0 ] [ 0 ] << endl ; //Output: 5cout << v[1][0] << endl; //Output: 1return 0;}

(CSS) Make A Background Image Scroll Slower Than Everything Else

Answer : I stumbled upon this looking for more flexibility in my parallax speed that I have created with pure CSS and I just want to point out that all these people are wrong and it is possible with pure CSS It is also possible to control the height of your element better. You will probably have to edit your DOM/HTML a bit to have some container elements, in your case you are applying the background to the body which will restrict you a lot and doesn't seem like a good idea. http://keithclark.co.uk/articles/pure-css-parallax-websites/ Here is how you control the height with Viewport-percentage lenghts based on screen size: https://stanhub.com/how-to-make-div-element-100-height-of-browser-window-using-css-only/ .forefront-element { -webkit-transform: translateZ(999px) scale(.7); transform: translateZ(999px) scale(.7); z-index: 1; } .base-element { -webkit-transform: translateZ(0); transform: translateZ(0); z-index: 4; } .background-element {

Place Text Over Image Bootstrap Code Example

Example: css text image background-image : url ( pathToImage ) ; background-size : 100 % ; color : transparent ; -webkit-background-clip : text ;

Bootstrap Input Textbox Code Example

Example 1: input with bootstrap <form> <div class= "form-group" > <label for= "exampleInputEmail1" >Email address</label> <input type= "email" class= "form-control" > <small id= "emailHelp" class= "form-text text-muted" >Hello , World</small> </div> </form> Example 2: bootstrap input tagsinput <select multiple data-role= "tagsinput" > <option value= "Amsterdam" >Amsterdam</option> <option value= "Washington" >Washington</option> <option value= "Sydney" >Sydney</option> <option value= "Beijing" >Beijing</option> <option value= "Cairo" >Cairo</option> </select> Example 3: bootsrap textbox <form> <div class= "form-group" > <label for= "exampleFormControlInput1" >Emai

Create Trigger Before Insert In Sql Server Code Example

Example 1: trigger before insert sql code DELIMITER $$ CREATE TRIGGER before_workcenters_insert BEFORE INSERT ON WorkCenters FOR EACH ROW BEGIN DECLARE rowcount INT ; SELECT COUNT ( * ) INTO rowcount FROM WorkCenterStats ; IF rowcount > 0 THEN UPDATE WorkCenterStats SET totalCapacity = totalCapacity + new . capacity ; ELSE INSERT INTO WorkCenterStats ( totalCapacity ) VALUES ( new . capacity ) ; END IF ; END $$ DELIMITER ; Example 2: trigger before insert sql code CREATE TRIGGER trigger_name BEFORE INSERT ON table_name FOR EACH ROW trigger_body ;