Posts

Showing posts from August, 2015

Online Cpp Shell Code Example

Example 1: c++ online compiler This two are good C ++ compilers : https : //www.onlinegdb.com/online_c++_compiler https : //www.programiz.com/cpp-programming/online-compiler/ Example 2: online compiler cpp Good cpp compilers : -- -- -- -- -- -- -- -- -- -- - repl . it / languages / cpp www . w3schools . com / cpp / trycpp . asp ? filename = demo_helloworld onlinegdb . com / online_c ++ _compiler programiz . com / cpp - programming / online - complier cpp . sh

Button Onclick Href Code Example

Example 1: href on a button < button onclick = "window.location.href='/page2'" > Continue < / button > Example 2: html button link < button > < a href = 'https://google.com' alt = 'Broken Link' > This is a button < / a > < / button > Example 3: buton html href < ! -- if you are on Window : -- > < button onclick = "window.location.href='page2.html'" > Button < / button > < ! -- if you are on linux or macOS : -- > < button onclick = "location.href='page2.html'" > Button < / button > Example 4: onclick href onclick = "location.href='http://www.hyperlinkcode.com/button-links.php'" Example 5: add link behind a button in html < ! DOCTYPE html > < html > < head > < title > Title of the document < / title > < / head > < body > < for

How To Check If A Tree Is Bst Code Example

Example 1: check if binary search tree is valid class BTNode { constructor ( value ) { this . value = value ; this . left = null ; this . right = null ; } } /** * * @param {BTNode} tree * @returns {Boolean} */ const isBinarySearchTree = ( tree ) = > { if ( tree ) { if ( tree . left && ( tree . left . value > tree . value || ! isBinarySearchTree ( tree . left ) ) ) { return false ; } if ( tree . right && ( tree . right . value <= tree . value || ! isBinarySearchTree ( tree . right ) ) ) { return false ; } } return true ; } ; Example 2: check for bst // C++ program to check if a given tree is BST. # include <bits/stdc++.h> using namespace std ; /* A binary tree node has data, pointer to left child and a pointer to right child */ struct Node { int data ; struct Node * left , * right ; } ; /

Android Button Drawable Tint

Image
Answer : You can achieve coloring the drawableleft on a button with this method: Step 1: Create a drawable resource file with bitmap as parent element as shown below and name it as ic_action_landscape.xml under the drawable folder <?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@android:drawable/ic_btn_speak_now" android:tint="@color/white" /> Step 2: Create your Button control in your layout as below <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:backgroundTint="@color/md_light_green_500" android:drawableLeft="@drawable/ic_action_landscape" android:drawablePadding="8dp" android:fontFamily="sans-serif" android:gravity="left|center_vertical" android:stateListAn

Converting Em To Px In Javascript (and Getting Default Font Size)

Answer : Edit: No, there isn't. To get the rendered font size of a given element, without affecting the DOM: parseFloat(getComputedStyle(parentElement).fontSize); This is based off the answer to this question. Edit: In IE, you would have to use parentElement.currentStyle["fontSize"] , but this is not guaranteed to convert the size to px . So that's out. Furthermore, this snippet won't get you the default font size of the element, but rather its actual font size, which is important if it has actually got a class and a style associated with it. In other words, if the element's font size is 2em , you'll get the number of pixels in 2 ems. Unless the font size is specified inline, you won't be able to get the conversion ratio right. I have a better answer. My code will store the length of 1em (in CSS pixel px units in the JavaScript variable em : Place this div anywhere in your HTML code <div id="div" style="height:0;width:0;outline

Button Onclick Href In Button Tag With Target Code Example

Example 1: href on a button < button onclick = " window.location.href= ' /page2 ' " > Continue </ button > Example 2: button as href < button onclick = " location.href= ' http://www.example.com ' " type = " button " > www.example.com </ button >

Html Select Placeholder W3schools Code Example

Example 1: placeholder select html <!DOCTYPE html> <head> </head> <body> <select name= "food" > <!-- The following line makes a placeholder --> <option value= "" disabled selected hidden>select food</option> <option value= "apple" >apple</option> <option value= "melon" >melon</option> </select> </body> Example 2: html select placeholder Placeholder attribute does not exist for the <select> tag. But there are some ways to make a placeholder for the select box. The easiest way of making a placeholder for the <select> element is using the disabled and selected attributes with the HTML5 hidden global attribute. <select name= "monthname" required> <option value= "" selected disabled hidden>Select Month</option> <option value= "Jan" >January</option> <option valu

Rotate Icon Using Css Code Example

Example: rotate element css div { width : 80 px ; height : 80 px ; background-color : skyblue ; } .rotated { transform : rotate ( 45 deg ) ; /* Equal to rotateZ(45deg) */ background-color : pink ; }

C Read File Line By Line Into Char Array Code Example

Example: c read lines from text file in to array FILE * fp ; // pointer to file char * file_name ; // file path char cur_char ; char * line = NULL ; // line array size_t len = 0 ; ssize_t read ; int counter = 0 ; //char content[MAX_NUM_LINES][MAX_LINE_LENGTH]; char strArray [ 150 ] [ 150 ] ; if ( optarg == 0 ) { printf ( "File could not be opened." ) ; return ; } // has file argument fp = fopen ( optarg , "r" ) ; if ( fp != NULL ) { while ( ( read = getline ( & line , & len , fp ) ) != - 1 ) // loop thru lines and add them to the strArray { // fgets(line, 100, fp); int i = 0 ; while ( line [ i ] != '\n' ) { // loop thru the characters in the current line strArray [ counter ] [ i ] = line [ i ] ; i ++ ; }

Angular 4 Pipe Filter

Answer : Here is a working plunkr with a filter and sortBy pipe. https://plnkr.co/edit/vRvnNUULmBpkbLUYk4uw?p=preview As developer033 mentioned in a comment, you are passing in a single value to the filter pipe, when the filter pipe is expecting an array of values. I would tell the pipe to expect a single value instead of an array export class FilterPipe implements PipeTransform { transform(items: any[], term: string): any { // I am unsure what id is here. did you mean title? return items.filter(item => item.id.indexOf(term) !== -1); } } I would agree with DeborahK that impure pipes should be avoided for performance reasons. The plunkr includes console logs where you can see how much the impure pipe is called. The transform method signature changed somewhere in an RC of Angular 2. Try something more like this: export class FilterPipe implements PipeTransform { transform(items: any[], filterBy: string): any { return items.filter(item =&

Git Pull To Remote Branch Code Example

Example 1: pull remote branches git fetch origin git checkout -- track origin / < remote_branch_name > Example 2: pull down remote branch git git fetch origin git checkout -- track origin / < branch_name > Example 3: how to pull remote branch into local branch git fetch origin < branch - name > Example 4: git pull a new branch froma remote repo git checkout -- track origin / daves_branch Example 5: how to pull from a branch in git git pull origin other - branch

Can An Optional Parameter Be Null In TypeScript?

Answer : To answer my own question after trying... The types null and undefined are handled as separate types. The optional type is special, also allowing arguments to be left out of function calls. 1. Without a union or optional, nothing except the type itself is allowed. function foo(bar: string) { console.info(bar); } foo("Hello World!"); // OK foo(null); // Error foo(undefined); // Error foo() // Error 2. To additionally allow null , a union with null can be made. function foo(bar: string | null) { console.info(bar); } foo("Hello World!"); // OK foo(null); // OK foo(undefined); // Error foo() // Error 3. Allowing undefined works similarly. Note that the argument cannot be left out or null . function foo(bar: string | undefined) { console.info(bar); } foo("Hello World!"); // OK foo(null); // Error foo(undefined); // OK foo() // Error 4. You can also allow both, but the argument MUST still be given. function foo(b

Convert Json Into Java Object Online Code Example

Example 1: How To Convert Json To Java Object I add GSON dependency in my POM -- > It’s a json parser . That is used to convert from java object to json and from json to java object SERIALIZATION : CONVERT JAVA OBJECT - > JSON DE - SERIALIZATION : CONVERT JSON - > JAVA OBJECT Example 2: how to convert json to java object Jackson Data - bind depdendency that take care of Converting between JSON to Java Object and Java Object to JSON < dependency > < groupId > com . fasterxml . jackson . core < / groupId > < artifactId > jackson - databind < / artifactId > < version > 2.12 .0 < / version > < / dependency >

Bottom Borders On WPF Grid

Answer : On a Border control You can do BorderThickness="0 0 0 1" to only have a bottom border shown. Top and bottom border thickness of 5, left and right border thickness of 0 BorderThickness="0 5" Top and bottom border thickness of 0, left and right border thickness of 5 BorderThickness="5 0" Border Thickness - Left: 1, Top: 2, Right:3, Bottom: 4 BorderThickness="1 2 3 4" Hope this helps!

What Is The Worst Case Time Complexity Of Merge Sort? * Code Example

Example: time complexity of merge sort O ( n * Log n ) : The time complexity of MergeSort is O ( n * Log n ) in all the 3 cases ( worst , average and best ) . As the mergesort always divides the array into two halves and takes linear time to merge two halves .

Cannot Connect To The Docker Daemon On MacOS

Answer : On a supported Mac, run: brew install --cask docker Then launch the Docker app. Click next. It will ask for privileged access. Confirm. A whale icon should appear in the top bar. Click it and wait for "Docker is running" to appear. You should be able to run docker commands now: docker ps Because docker is a system-level package, you cannot install it using brew install , and must use --cask instead. Note: This solution only works for Macs whose CPUs support virtualization, which may not include old Macs. On macOS the docker binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively in OS X. So you have to install docker-machine in order to create VM and attach to it. Install docker-machine on macOS If you don't have docker-machine command yet, install it by using one of the following methods: Using Brew command: brew install dock