Posts

Showing posts from October, 2006

CSS Grid: Is It Possible To Apply Color To Grid Gaps?

Image
Answer : Sadly, there is currently no way in the CSS Grid spec to style grid-gap . I came up with a solution that works well though that involves just html and css: show border grid lines only between elements For instance: if one has a 5x5 grid of squares, is the only way to get colored grid lines to fill the grid with 25 elements and apply borders to those same elements? You could do that, but grid borders do not collapse the same way that table borders can with the border-collapse property, and unlike grid gaps they'll be applied to the perimeter of your grid along with the inner borders, which may not be desired. Plus, if you have a grid-gap declaration, the gaps will separate your grid item borders much like border-collapse: separate does with table borders. grid-gap is the idiomatic approach for spacing grid items, but it's not ideal since grid gaps are just that: empty space, not physical boxes. To that end, the only way to color these gaps is to apply a backgr

Matplotlib Color Documentation Code Example

Example: matplotlib color Alias Color 'b' blue 'g' green 'r' red 'c' cyan 'm' magenta 'y' yellow 'k' black 'w' white

Angular Firebase Npm Code Example

Example 1: npm install @angular/fire firebase –save npm install firebase @angular / fire Example 2: install angular fire ng add @angular / fire

Angular Typescript Class Constant Code Example

Example: create constant in class typescript private static readonly myPrivateConstant : number = 5 ;

Toggle Buttons In Bootstrap 4 With List Code Example

Example 1: bootstarp btn colors <button type= "button" class= "btn btn-primary" > Blue </button> <button type= "button" class= "btn btn-secondary" > Grey </button> <button type= "button" class= "btn btn-success" > Green </button> <button type= "button" class= "btn btn-danger" > Red </button> <button type= "button" class= "btn btn-warning" > Yellow </button> <button type= "button" class= "btn btn-info" >Ligth blue </button> <button type= "button" class= "btn btn-light" > White </button> <button type= "button" class= "btn btn-dark" > Black </button> <button type= "button" class= "btn btn-link" > White with blue text</button> Example 2: bootstrap button drak <button type= "button"

3 Foot In Cm Code Example

Example: foot to cm 1 foot = 30.48 cm

Algorithm Package Latex Code Example

Example: using latex to write algorithm \begin{program} \mbox{A fast exponentiation procedure:} \BEGIN \\ % \FOR i:=1 \TO 10 \STEP 1 \DO |expt|(2,i); \\ |newline|() \OD % \rcomment{This text will be set flush to the right margin} \WHERE \PROC |expt|(x,n) \BODY z:=1; \DO \IF n=0 \THEN \EXIT \FI; \DO \IF |odd|(n) \THEN \EXIT \FI; \COMMENT{This is a comment statement}; n:=n/2; x:=x*x \OD; \{ n>0 \}; n:=n-1; z:=z*x \OD; |print|(z) \ENDPROC \END \end{program}

Bulma Full Height Sidebar Code Example

Example: bulma fullheight < section class = " hero is-success is-fullheight " > < div class = " hero-body " > < div class = " container " > < h1 class = " title " > Fullheight title </ h1 > < h2 class = " subtitle " > Fullheight subtitle </ h2 > </ div > </ div > </ section >

Add Key Value To Javascript Object Code Example

Example 1: js add key to object // given const obj = { key1 : value1 , key2 : value2 } ; // add pair obj [ "key3" ] = value3 ; obj . key4 = value4 ; Example 2: how to add field to object in js // original object { key1: "a", key2: "b"} var obj = { key1 : "a" , key2 : "b" } ; // adding new filed - you can use 2 ways obj . key3 = "c" ; // static // or obj [ "key3" ] = "c" ; // dynamic - 'key3' can be a variable console . log ( obj ) // {key1: "a", key2: "b", key3: "c" } Example 3: javascript add to object var element = { } , cart = [ ] ; element . id = id ; element . quantity = quantity ; cart . push ( element ) ; // Array of Objects in form {element: {id: 10, quantity: 10} } var element = { } , cart = [ ] ; element . id = id ; element . quantity = quantity ; cart . push ( { element : element

Decrypt Sha512 Code Example

Example 1: c# sha512 salt static byte [ ] GenerateSaltedHash ( byte [ ] plainText , byte [ ] salt ) { HashAlgorithm algorithm = new SHA256Managed ( ) ; byte [ ] plainTextWithSaltBytes = new byte [ plainText . Length + salt . Length ] ; for ( int i = 0 ; i < plainText . Length ; i ++ ) { plainTextWithSaltBytes [ i ] = plainText [ i ] ; } for ( int i = 0 ; i < salt . Length ; i ++ ) { plainTextWithSaltBytes [ plainText . Length + i ] = salt [ i ] ; } return algorithm . ComputeHash ( plainTextWithSaltBytes ) ; } Example 2: c# sha512 salt using RandomNumberGenerator ; using System ; using System . Collections . Generic ; using System . Linq ; using System . Security . Cryptography ; using System . Text ; using System . Threading . Tasks ; namespace HashingAlgos { public class PasswordWithSaltHasher { public HashWithSaltResult HashWithSalt ( string password , int saltLength , Ha

Hover Over Js Code Example

Example 1: javascript hover event element .onmouseover = function ( ) { //Hovering } Example 2: hover con js // Creamos el evento mouseover para cada imagen imagenes [ i ] .addEventListener ( "mouseover" , function ( e ) { document. getElementById ( "mostrar" ) .style.backgroundImage= "url('" +e.target.currentSrc+ "')" ; } ) ; // Creamos el evento mouseout para cada imagen imagenes [ i ] .addEventListener ( "mouseout" , function ( e ) { document. getElementById ( "mostrar" ) .style.backgroundImage= "" ; } ) ; Example 3: on hover event onmouseover event

Rounded Button Bootstrap 3 Code Example

Example: round button css .btn { display : block ; height : 300 px ; width : 300 px ; border-radius : 50 % ; border : 1 px solid red ; }

Angular 4+ NgOnDestroy() In Service - Destroy Observable

Answer : OnDestroy lifecycle hook is available in providers. According to the docs: Lifecycle hook that is called when a directive, pipe or service is destroyed. Here's an example: @Injectable() class Service implements OnDestroy { ngOnDestroy() { console.log('Service destroy') } } @Component({ selector: 'foo', template: `foo`, providers: [Service] }) export class Foo implements OnDestroy { constructor(service: Service) {} ngOnDestroy() { console.log('foo destroy') } } @Component({ selector: 'my-app', template: `<foo *ngIf="isFoo"></foo>`, }) export class App { isFoo = true; constructor() { setTimeout(() => { this.isFoo = false; }, 1000) } } Notice that in the code above Service is an instance that belongs to Foo component, so it can be destroyed when Foo is destroyed. For providers that belong to root injector this will happen on application destroy, t

Void Value Not Ignored As It Ought To B\ Code Example

Example: void value not ignored as it ought to be you ' re trying to capture the return value of a function for which the return type is void .

Convert NSData To String?

Answer : Objective-C You can use (see NSString Class Reference) - (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding Example: NSString *myString = [[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding]; Remark : Please notice the NSData value must be valid for the encoding specified (UTF-8 in the example above), otherwise nil will be returned: Returns nil if the initialization fails for some reason (for example if data does not represent valid data for encoding). Prior Swift 3.0 String(data: yourData, encoding: NSUTF8StringEncoding) Swift 3.0 Onwards String(data: yourData, encoding: .utf8) See String#init(data:encoding:) Reference Prior Swift 3.0 : String(data: yourData, encoding: NSUTF8StringEncoding) For Swift 4.0: String(data: yourData, encoding: .utf8) I believe your "P" as the dataWithBytes param NSData *keydata = [NSData dataWithBytes:P length:len]; should be "buf" NSData *keydata = [NSData dataWithBytes:buf length:len]; sin

Round Checkbox Css Code Example

Example: css circle checkbox .checkbox-round { width : 1.3 em ; height : 1.3 em ; background-color : white ; border-radius : 50 % ; vertical-align : middle ; border : 1 px solid #ddd ; -webkit-appearance : none ; outline : none ; cursor : pointer ; } .checkbox-round :checked { background-color : gray ; }

Switch Case Range Arduino Code Example

Example: arduino switch case switch ( var ) { case label1 : // statements break ; case label2 : // statements break ; default : // statements break ; }

Std String Find Character C++ Code Example

Example 1: c++ string contains if ( string1 . find ( string2 ) != std :: string :: npos ) { std :: cout << "found!" << '\n' ; } Example 2: std string find character c++ // string::find # include <iostream> // std::cout # include <string> // std::string int main ( ) { std :: string str ( "There are two needles in this haystack with needles." ) ; std :: string str2 ( "needle" ) ; // different member versions of find in the same order as above: std :: size_t found = str . find ( str2 ) ; if ( found != std :: string :: npos ) std :: cout << "first 'needle' found at: " << found << '\n' ; found = str . find ( "needles are small" , found + 1 , 6 ) ; if ( found != std :: string :: npos ) std :: cout << "second 'needle' found at: " << found << '\n'

AddEntityFrameworkStores Can Only Be Called With A Role That Derives From IdentityRole In .NET Core 2.0

Answer : Long time since I asked this question, but here's how I deal with nowadays: Startup.cs services.AddIdentity<User, Role>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); services.AddScoped<RoleManager<Role>>(); Entites: public class User : IdentityUser<int> { } public class Role : IdentityRole<int> { } For same issue, you can look at this:https://github.com/aspnet/Identity/issues/1364

C++ Cout Variable Code Example

Example 1: how to print a string to console in c++ // Just some basic format # include <iostream> # include <string> using namespace std ; int main ( ) { cout << "Print a String" << endl ; } Example 2: how to grab all of user input c++ // cin with strings # include <iostream> # include <string> using namespace std ; int main ( ) { string mystr ; cout << "What's your name? " ; getline ( cin , mystr ) ; cout << "Hello " << mystr << ".\n" ; cout << "What is your favorite team? " ; getline ( cin , mystr ) ; cout << "I like " << mystr << " too!\n" ; return 0 ; } Example 3: cout value c++ # include <iostream> using namespace std ; int main ( ) { int a , b ; char str [ ] = "Hello Programmers" ; /* Single insertion operat

Format Date In Javascript Dd/mm/yyyy Code Example

Example 1: javascript date today dd mm yyyy var today = new Date ( ) ; var dd = String ( today . getDate ( ) ) . padStart ( 2 , '0' ) ; var mm = String ( today . getMonth ( ) + 1 ) . padStart ( 2 , '0' ) ; //January is 0! var yyyy = today . getFullYear ( ) ; today = mm + '/' + dd + '/' + yyyy ; document . write ( today ) ; Example 2: javascript format date yyyy-mm-dd let today = new Date ( ) today . toISOString ( ) . split ( 'T' ) [ 0 ] Example 3: javascript format date to dd-mm-yyyy function pad2 ( n ) { return ( n < 10 ? '0' : '' ) + n ; } var date = new Date ( ) ; var month = pad2 ( date . getMonth ( ) + 1 ) ; //months (0-11) var day = pad2 ( date . getDate ( ) ) ; //day (1-31) var year = date . getFullYear ( ) ; var formattedDate = day + "-" + month + "-" + year ; alert ( formattedDate ) ; //28-02-2021 Example 4: javascript date parse yyyy-mm-dd var da

Angular Material Dropdown Code Example

Example 1: angular material dropdown menu < mat-menu #animals = " matMenu " > < button mat-menu-item [matMenuTriggerFor] = " vertebrates " > Vertebrates </ button > < button mat-menu-item [matMenuTriggerFor] = " invertebrates " > Invertebrates </ button > </ mat-menu > < mat-menu #vertebrates = " matMenu " > < button mat-menu-item [matMenuTriggerFor] = " fish " > Fishes </ button > < button mat-menu-item [matMenuTriggerFor] = " amphibians " > Amphibians </ button > < button mat-menu-item [matMenuTriggerFor] = " reptiles " > Reptiles </ button > < button mat-menu-item > Birds </ button > < button mat-menu-item > Mammals </ button > </ mat-menu > Example 2: how to add dropdown with filter in angular material < mat-autocomplete #auto = " matAutocomplete "

Angular 5 Mat-grid List Responsive

Answer : You have to set the cols attribute of the mat-grid-list dynamically depending on the screen width. You'd have to decide on which width breakpoint will the mat-grid-list render the 1-column version. HTML: <mat-grid-list [cols]="breakpoint" rowHeight="2:0.5" (window:resize)="onResize($event)"> <mat-grid-tile>1</mat-grid-tile> <mat-grid-tile>2</mat-grid-tile> <mat-grid-tile>3</mat-grid-tile> <mat-grid-tile>4</mat-grid-tile> <mat-grid-tile>5</mat-grid-tile> <mat-grid-tile>6</mat-grid-tile> </mat-grid-list> TS: ngOnInit() { this.breakpoint = (window.innerWidth <= 400) ? 1 : 6; } onResize(event) { this.breakpoint = (event.target.innerWidth <= 400) ? 1 : 6; } Stackblitz demo here Hope this helps! I liked Altus answer, but I would like to have more breakpoints. So I've created a simple method with some breakpoints using F