Posts

Showing posts from January, 2001

Arrays Left Rotation Hackerrank Solution In Python Code Example

Example: arrays left rotation hackerrank solution int n , d ; cin >> n ; int a [ n ] ; cin >> d ; for ( int i = 0 ; i < n ; cin >> a [ i ] , i ++ ) ; d = d % n ; for ( int i = d ; i < n ; i ++ ) cout << a [ i ] << " " ; for ( int i = 0 ; i < d ; i ++ ) cout << a [ i ] << " " ; return 0 ;

Html Css Border Font Code Example

Example 1: html font white text with black border h1 { color : yellow ; text-shadow : -1 px 0 black , 0 1 px black , 1 px 0 black , 0 -1 px black ; } <h1>Hello World</h1> Example 2: how to make border for letters in css h1 { -webkit-text-stroke : 2 px black ; /* width and color */ font-family : sans ; color : yellow ; }

Country Name Mashup Generator

Answer : Jelly, 74 73 bytes Já¹–XṬk⁸ḢḢFṪ;ƲƭF)jṪḢƭ€á¹€$$ ḢṖ; ṪḢṪ;ÆŠá¹­ Fe€Ã˜cá¹–TXṬkḢḢṪƭ) e€⁾ -k)ẈỊḄ‘ƲĿ Ḣ,2KƊÇE? Try it online! A full program that takes a list of two strings as its argument and implicitly outputs the mashed up country name. The handling of hyphens is relatively costly, particularly since they are included whichever side of the split they fall. Explanation Helper link 1 Handles case where both countries have multiple words ) | For each country: J | - Sequence along words á¹– | - Remove last X | - Pick one at random Ṭ | - Convert to a boolean list with a 1 at that index k⁸ | - Split list of words after that point Æ­ | - Alternate between: Ḣ | - Head (first set of words for the first country) Ʋ | - Following as a monad (for the second country) Ḣ | - Head (f

Angular Material Mat Icon Module Code Example

Example 1: properly import mat icon angular 10 // In Angular in style.css @import 'https://fonts.googleapis.com/icon?family=Material+Icons'; Example 2: material icons angular < mat-icon class = " mat-icon-rtl-mirror " svgIcon = " thumb-up " > </ mat-icon >

Angular Ngclass Example

Example 1: ng class [ ngClass ] = "{'text-success':person.country === 'UK'}" Example 2: angular ngclass content_copy < some - element [ ngClass ] = "'first second'" > ... < / some - element > < some - element [ ngClass ] = "['first', 'second']" > ... < / some - element > < some - element [ ngClass ] = "{'first': true, 'second': true, 'third': false}" > ... < / some - element > < some - element [ ngClass ] = "stringExp|arrayExp|objExp" > ... < / some - element > < some - element [ ngClass ] = "{'class1 class2 class3' : true}" > ... < / some - element > Example 3: ngclass angular < div [ ngClass ] = " { 'green' : number > 5 , 'red' : number <= 5 , } " > < / div > //if the number is over 5, the class 'green'

Container Box Decoration Flutter Code Example

Example 1: flutter decoration image Container ( width : 190.0 , height : 190.0 , decoration : new BoxDecoration ( shape : BoxShape . circle , image : new DecorationImage ( fit : BoxFit . fill , image : new NetworkImage ( "https://i.imgur.com/BoN9kdC.png" ) ) ) ) Example 2: container decoration box flutter new Container ( margin : const EdgeInsets . all ( 15.0 ) , padding : const EdgeInsets . all ( 3.0 ) , decoration : BoxDecoration ( border : Border . all ( color : Colors . blueAccent ) ) , child : Text ( "My Awesome Border" ) , ) Example 3: box decoration s flutter new Center ( child : new Container ( decoration : new BoxDecoration ( color : Colors . purple , gradient : new LinearGradient ( colors : [ Colors . red , Colors . cyan ] , begin : Alignment . centerRight , end : new Alignment ( - 1.0 , - 1.0 ) ) , ) , child : new FlutterLogo (

Trigger Kendo Dropdownlist Change Event Code Example

Example: trigger kendo dropdownlist change event var dropDownList = $ ( "#serviceAccounts" ) . getKendoDropDownList ( ) ; dropDownList. trigger ( "change" ) ;

Add Php Variable Inside Echo Statement As Href Link Address?

Answer : Try like HTML in PHP : echo "<a href='".$link_address."'>Link</a>"; Or even you can try like echo "<a href='$link_address'>Link</a>"; Or you can use PHP in HTML like PHP in HTML : <a href="<?php echo $link_address;?>"> Link </a> you can either use echo '<a href="'.$link_address.'">Link</a>'; or echo "<a href=\"$link_address\">Link</a>'; if you use double quotes you can insert the variable into the string and it will be parsed. Basically like this, <?php $link = ""; // Link goes here! print "<a href="'.$link.'">Link</a>"; ?>

Angular 2 Router No Base Href Set

Image
Answer : https://angular.io/docs/ts/latest/guide/router.html Add the base element just after the <head> tag. If the app folder is the application root, as it is for our application, set the href value exactly as shown here. The <base href="/"> tells the Angular router what is the static part of the URL. The router then only modifies the remaining part of the URL. <head> <base href="/"> ... </head> Alternatively add >= Angular2 RC.6 import {APP_BASE_HREF} from '@angular/common'; @NgModule({ declarations: [AppComponent], imports: [routing /* or RouterModule */], providers: [{provide: APP_BASE_HREF, useValue : '/' }] ]); in your bootstrap. In older versions the imports had to be like < Angular2 RC.6 import {APP_BASE_HREF} from '@angular/common'; bootstrap(AppComponent, [ ROUTER_PROVIDERS, {provide: APP_BASE_HREF, useValue : '/' }); ]); < RC.0

Android: StopService Doesn't Call OnDestroy

Answer : First, it's onDestroy, not OnDestroy . Second, you must use the @Override annotation for compile-time checking, so your Service code should look somewhat like this: @Override public void onDestroy(){ Log.v("SERVICE","Service killed"); player.stop(); super.onDestroy(); } First, you need to clarify how many types of services in Android. AFAIK, there are: Foreground service. Background service. Bound service. Intent service. These services stop in different ways. Foreground: only stop when you intentionally stop it by calling stopService() in activity or fragment where you start that service or call stopSelf() in its own service. And Please note only these methods trigger service's onDestroy() . Background: stopService() and stopSelf() do in the same way as foreground. Moreover, you should know this service is in the same thread with activity or fragment calling it, so if you destroy activity or fragment, this ser

Bullets Numbered Latex Code Example

Example 1: latex bullet points \begin{itemize} \item One entry in the list \item Another entry in the list \end{itemize} Example 2: list overleaf \begin{enumerate} \item The labels consists of sequential numbers. \begin{itemize} \item The individual entries are indicated with a black dot, a so-called bullet. \item The text in the entries may be of any length. \end{itemize} \item The numbers starts at 1 with every call to the enumerate environment. \end{enumerate}

What Does Scp Stand For Code Example

Example 1: using scp scp remote_username@ 10.10 .0 .2 : / remote / file . txt / local / directory Example 2: scp examples # With ssh key , verbose , and - r for whole directories . scp - v - i [ your private key path ] - r / my_dir [ server_user ] @ [ serverIP ] : / where / to / copy

Flex Bootstrap 4 Code Example

Example 1: align items center bootstrap <div class= "d-flex align-items-start" >...</div> <div class= "d-flex align-items-end" >...</div> <div class= "d-flex align-items-center" >...</div> <div class= "d-flex align-items-baseline" >...</div> <div class= "d-flex align-items-stretch" >...</div> Example 2: justify-content-between bootstrap 4 <div class= "d-flex justify-content-start" >...</div> <div class= "d-flex justify-content-end" >...</div> <div class= "d-flex justify-content-center" >...</div> <div class= "d-flex justify-content-between" >...</div> <div class= "d-flex justify-content-around" >...</div> Example 3: centralize div bootstrap <div class= "row align-items-center justify-content-center" > <div class= "col" >This will b

Font Awesome CDN 5 Code Example

Example 1: fontawesome cdn <link href= "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel= "stylesheet" > Example 2: font awesome cdn <link rel= "stylesheet" href= "https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity= "sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin= "anonymous" /> Example 3: font awesome 5 pro cdn link <link href= "https://pro.fontawesome.com/releases/v5.10.0/css/all.css" rel= "stylesheet" > Example 4: font awesome icons cdn To load all styles : <link rel= "stylesheet" href= "https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity= "sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin= "anonymous" /> Example 5: font-awesome cdn <link rel= "stylesheet" href= "https://stackp

Javascript Sortby Code Example

Example 1: sort javascript array var points = [ 40 , 100 , 1 , 5 , 25 , 10 ] ; points . sort ( ( a , b ) = > a - b ) Example 2: javascript orderby var items = [ { name : 'Edward' , value : 21 } , { name : 'Sharpe' , value : 37 } , { name : 'And' , value : 45 } , { name : 'The' , value : - 12 } , { name : 'Magnetic' , value : 13 } , { name : 'Zeros' , value : 37 } ] ; // sort by value items . sort ( function ( a , b ) { return a . value - b . value ; } ) ; // sort by name items . sort ( function ( a , b ) { var nameA = a . name . toUpperCase ( ) ; // ignore upper and lowercase var nameB = b . name . toUpperCase ( ) ; // ignore upper and lowercase if ( nameA < nameB ) { return - 1 ; } if ( nameA > nameB ) { return 1 ; } // names must be equal return 0 ; } ) ; Example 3: javascript sort var names = [

Control The Dashed Border Stroke Length And Distance Between Strokes

Image
Answer : The native dashed border property value does not offer control over the dashes themselves... so bring on the border-image property! Brew your own border with border-image Compatibility : It offers great browser support (IE 11 and all modern browsers). A normal border can be set as a fallback for older browsers. Let's create these These borders will display exactly the same cross-browser! Step 1 - Create a suitable image This example is 15 pixels wide by 15 pixels high and the gaps are currently 5px wide. It is a .png with transparency. This is what it looks like in photoshop when zoomed in: This is what it looks like to scale: Controlling gap and stroke length To create wider / shorter gaps or strokes, widen / shorten the gaps or strokes in the image. Here is an image with wider 10px gaps: correctly scaled = Step 2 - Create the CSS — this example requires 4 basic steps Define the border-image-source: border-image-source:url("http://i.stack.imgur.com/wLdVc.png&q

14 Factorial Code Example

Example 1: factorial of 8 function getFactorial ( $ int ) { $factorial = 1 ; for ( $i = $ int ; $i > 1 ; $i - - ) { $factorial *= $i ; } echo "The factorial of " . $ int . " is " . $factorial . '<br>' ; } Example 2: Factorial Number // METHOD ONE const factorialNumber = num = > { let factorials = [ ] for ( let i = 1 ; i <= num ; i + + ) factorials . push ( i ) return factorials . reduce ( ( acc , curr ) = > acc * curr , 1 ) } // METHOD TWO const factorialNumber = num = > { let factorial = 1 , i = 1 while ( i <= num ) { factorial *= i ; i + + } return factorial } // METHOD THREE function factorialNumber ( num ) { if ( num < 1 ) return 1 else return factorialNumber ( num - 1 ) * num }

How To Set Line Spacing In Css Code Example

Example 1: line spacing css line-height : 20 px ; /* 4px +12px + 4px */ /* OR */ line-height : 1.7 em ; /* 1em = 12px in this case. 20/12 == 1.666666 */ Example 2: css line spacing line-height : 1.5 ; /* Prefered */ line-height : 1.5 em ; line-height : 150 % ; line-height : 24 px ;

Copying List In Python Code Example

Example 1: copy a list python new_list = old_list . copy ( ) # or new_list = old_list [ : ] Example 2: python copy list # Performance analysis by River on Stack Overflow METHOD TIME TAKEN b = [ * a ] 2.75180600000021 b = a * 1 3.50215399999990 b = a [ : ] 3.78278899999986 # Python2 winner b = a . copy ( ) 4.20556500000020 b = [ ] ; b . extend ( a ) 4.68069800000012 b = a [ 0 : len ( a ) ] 6.84498999999959 * b , = a 7.54031799999984 b = list ( a ) 7.75815899999997 b = [ i for i in a ] 18.4886440000000 b = copy . copy ( a ) 18.8254879999999 # With `import copy` b = [ ] for item in a : b . append ( item ) 35.4729199999997 # NOTE: Only for shallow copies, use copy.deepcopy for nested lists Example 3: copy one list to another python thislist = [ "apple" , "banana" , "cherry" ] mylist = th

How To Transition Multiple Properties Css Code Example

Example 1: css transition select multiple attributes .myclass { /* ... */ transition : all 200 ms ease ; transition-property : box-shadow , height , width , background , font-size ; } Example 2: transition multiple properties .class-name { /* element transitions top and font-size for two seconds */ transition : height 2 s ease-in-out , font-size 2 s ease-in-out ; }

How To Remove Right Click Option In Websu=ite Code Example

Example: javascript disable right click document. addEventListener ( 'contextmenu' , event => event. preventDefault ( ) ) ;

Add A Quantity Field To Ajax Add To Cart Button On WooCommerce Shop Page

Answer : Updated on May 2020 For WooCommerce versions from 3.2 to 4+, Optimized jQuery code and Removed a quantity bug. The following custom function is hooked in woocommerce_loop_add_to_cart_link filter hook and adds a quantity input field to each product on WooCommerce archives pages and other product loops. We use here mostly the original WooCommerce code. A bit of jQuery code is necessary to update the data-quantity attribute on the add to cart button when customer changes the quantity. Some styling might be needed, depending on your client wishes (and on your theme) . An additional section to hide the "View cart" button is located at the end. The code: add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_loop_ajax_add_to_cart', 10, 2 ); function quantity_inputs_for_loop_ajax_add_to_cart( $html, $product ) { if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() &&am

^a-zA-Z0-9 Excluding Spaces?

Answer : You could also try with: /[^a-zA-Z0-9\s]/gi If you only want to exclude spaces use: [^ ]* Test the regex here if you want.

Add Rows To Wpf Datagrid Dynamically Code Example

Example: dynamically add rows to datagridview c# DataTable dt = new DataTable ( ) ; // first add your columns for ( int i = 0 ; i < count ; i ++ ) { dt . Columns . Add ( fromFileFields [ i ] ) ; } // and then add your rows for ( int i = 0 ; i < count ; i ++ ) { var row = dt . NewRow ( ) ; // Set values for columns with row[i] = xy dt . Rows . Add ( row ) ; } datagridview . DataSource = dt ;

60 Inch Cm Code Example

Example: inch to cm 1 inch = 2.54 cm