Posts

Showing posts from July, 2004

Binary Searcht Ree Code Example

Example: binary tree search /* This is just the seaching function you need to write the required code. Thank you. */ void searchNode ( Node * root , int data ) { if ( root == NULL ) { cout << "Tree is empty\n" ; return ; } queue < Node * > q ; q . push ( root ) ; while ( ! q . empty ( ) ) { Node * temp = q . front ( ) ; q . pop ( ) ; if ( temp -> data == data ) { cout << "Node found\n" ; return ; } if ( temp -> left != NULL ) q . push ( temp -> left ) ; if ( temp -> right != NULL ) q . push ( temp -> right ) ; } cout << "Node not found\n" ; }

Cast From VARCHAR To INT - MySQL

Answer : As described in Cast Functions and Operators: The type for the result can be one of the following values: BINARY[(N)] CHAR[(N)] DATE DATETIME DECIMAL[(M[,D])] SIGNED [INTEGER] TIME UNSIGNED [INTEGER] Therefore, you should use: SELECT CAST(PROD_CODE AS UNSIGNED) FROM PRODUCT For casting varchar fields/values to number format can be little hack used: SELECT (`PROD_CODE` * 1) AS `PROD_CODE` FROM PRODUCT`

Android SQLite Auto Increment

Answer : Make it INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL . Here's what the docs say: If a column has the type INTEGER PRIMARY KEY AUTOINCREMENT then... the ROWID chosen for the new row is at least one larger than the largest ROWID that has ever before existed in that same table. The behavior implemented by the AUTOINCREMENT keyword is subtly different from the default behavior. With AUTOINCREMENT, rows with automatically selected ROWIDs are guaranteed to have ROWIDs that have never been used before by the same table in the same database. And the automatically generated ROWIDs are guaranteed to be monotonically increasing. SQLite AUTOINCREMENT is a keyword used for auto incrementing a value of a field in the table. We can auto increment a field value by using AUTOINCREMENT keyword when creating a table with specific column name to auto incrementing it. The keyword AUTOINCREMENT can be used with INTEGER field only. Syntax: The basic usage of AU

Check If Strings Are Equals And Ternary Operator In Ansible

Answer : Solved! service_type: "{{ 'NodePort' if expose_service == 'true' else 'ClusterIP' }}" In your example you are applying the ternary filter to the 'true' string. Effectively you are comparing the value of expose_service with the string 'NodePort' and always get false in result. You need to enclose the equality operator-clause in parentheses: - include: deploy_new.yml vars: service_type: "{{ (expose_service == true) | ternary('NodePort', 'ClusterIP') }}" when: service_up|failed The other other two points addressed in this answer: you use the string 'true' instead of Boolean when directive is on wrong indentation level (you effectively pass the variable called when )

Binary Alphabet Code Example

Example 1: alphabet binary code Alphabet table Letter ASCII Code Binary Letter ASCII Code Binary a 097 0110 0001 A 065 0100 0001 b 098 0110 0010 B 066 0100 0010 c 099 0110 0011 C 067 0100 0011 d 100 0110 0100 D 068 0100 0100 e 101 0110 0101 E 069 0100 0101 f 102 0110 0110 F 070 0100 0110 g 103 0110 0111 G 071 0100 0111 h 104 0110 1000 H 072 0100 1000 i 105 0110 1001 I 073 0100 1001 j 106 0110 1010 J 074 0100 1010 k 107 0110 1011 K 075 0100 1011 l 108 0110 1100 L 076 0100 1100 m 109 0110 1101 M 077 0100 1101 n 110 0110 1110 N 078 0100 1110 o 111 0110 1111 O 079 0100 1111 p 112 0111 0000 P 080 0101 0000 q 113 0111 0001 Q 081 0101 0001 r 11

Android: API Level VS. Android Version

Image
Answer : Well, API is for development, so the changes in new API version are more "inside". But new version of Android usually adds more features for users, that are "visible". Check this page http://developer.android.com/guide/appendix/api-levels.html, there is a table that shows relations between versions and API levels. Multiple versions of Android can have the same API level but the API as an integer allows developers to more easily target devices. The chart below will give you an idea of their relationship but only the documentation contains exhaustive listings of the API levels and how they differ from each other. Source: developer.android.com. Because this data is gathered from the new Google Play Store app, which supports Android 2.2 and above, devices running older versions are not included. However, in August, 2013, versions older than Android 2.2 accounted for about 1% of devices that checked in to Google servers (not those that actually vi

Can You Make A Travel Region Polygon With With Google Maps API?

Image
Answer : Google's tools do not provide any way to do this kind of thing built in. While you might be able to do this by routing to a sufficient number of locations and checking the time, another tool that you might be interested in is Graphserver. GraphServer is a multimodal trip planner, which can take data from OpenStreetMap and other data sources. Some of the gallery images show growing shortest-path distance routing, and this is based on a similar metric. The Google Group would be the appropriate place to discuss the possibilities of using this tool. Note that this is not a pre-baked tool; it will likely require some investigation and work to get it to solve your problem, but the tool can be used to do it. Take a look at the Mapnificent API. Mapnificent provides dynamic public transport travel time maps for many cities in the US and some world wide. You can use the Mapnificent API to augment your Google Maps application with public transport travel time

Can I Limit The Length Of An Array In JavaScript?

Answer : You're not using splice correctly: arr.splice(4, 1) this will remove 1 item at index 4. see here I think you want to use slice: arr.slice(0,5) this will return elements in position 0 through 4. This assumes all the rest of your code (cookies etc) works correctly The fastest and simplest way is by setting the .length property to the desired length: arr.length = 4; This is also the desired way to reset/empty arrays: arr.length = 0; Caveat: setting this property can also make the array longer than it is: If its length is 2, running arr.length = 4 will add two undefined items to it. Perhaps add a condition: if (arr.length > 4) arr.length = 4; Alternatively: arr.length = Math.min(arr.length, 4); arr.length = Math.min(arr.length, 5)

How To Calculate 1000 Factorial In C++ Code Example

Example: program to calculate factorial of number in c++ # include <iostream> using namespace std ; int main ( ) { unsigned int n ; unsigned long long factorial = 1 ; cout << "Enter a positive integer: " ; cin >> n ; for ( int i = 1 ; i <= n ; ++ i ) { factorial *= i ; } cout << "Factorial of " << n << " = " << factorial ; return 0 ; }

Can I Force Pip To Reinstall The Current Version?

Answer : pip install --upgrade --force-reinstall <package> When upgrading, reinstall all packages even if they are already up-to-date. pip install -I <package> pip install --ignore-installed <package> Ignore the installed packages (reinstalling instead). You might want to have all three options: --upgrade and --force-reinstall ensures reinstallation, while --no-deps avoids reinstalling dependencies. $ sudo pip install --upgrade --no-deps --force-reinstall <packagename> Otherwise you might run into the problem that pip starts to recompile Numpy or other large packages. If you want to reinstall packages specified in a requirements.txt file, without upgrading, so just reinstall the specific versions specified in the requirements.txt file: pip install -r requirements.txt --ignore-installed

Maximum Value Of Int In Java Code Example

Example 1: java max integer Integer . MAX_VALUE //== 2147483647, once you increment past that, you //"wrap around" to Integer.MIN_VALUE Example 2: integer max value java //Integer.MAX_VALUE (MAX_VALUE Method In Integer Wrapper Class) - 2 , 147 , 483 , 648 //(Value) In Java , the integer ( long ) is also 32 bits , but ranges from - 2 , 147 , 483 , 648 to + 2 , 147 , 483 , 647. Example 3: java max int value public class Test { public static void main ( String [ ] args ) { System . out . println ( Integer . MIN_VALUE ) ; System . out . println ( Integer . MAX_VALUE ) ; System . out . println ( Integer . MIN_VALUE - 1 ) ; System . out . println ( Integer . MAX_VALUE + 1 ) ; } } Example 4: integer max value representation java Integer . MAX_VALUE Example 5: int java boolean result = true ; char capitalC = 'C' ; byte b = 100 ; short s = 10000 ; int i = 100000 ;

Can I Use Dispensers Or Droppers To Auto-replant Crops?

Answer : In vanilla Minecraft, wheat, carrots, and potatoes must be planted by hand, although they can be automatically harvested with water or pistons. You might be able to get the functionality you want with a mod, but I don't know of any. Sorry! No, dispenser nor droppers can plant seeds. However, as an alternative you can put a villager farmer there and he will automatically plant seeds.

Clear Command Window Matlab Code Example

Example: how to clear matlab command window clc //clear command window clear //clears all variables from current workspace close all //closes all figures

Azure CLI Vs Powershell?

Answer : Azure CLI is a PowerShell-like-tool available for all platforms. You can use the same commands no matter what platform you use: Windows, Linux or Mac. Now, there are two version Azure CLI. The Azure CLI 1.0 was written with Node.js to achieve cross-platform capabilities, and the new Azure CLI 2.0 is written in Python to offer better cross-platform capabilities. Both are Open Source and available on Github. However, for now, only certain PowerShell cmdlets support use on Linux. Is it targetted for the audience who want to manage Azure IAAS from Linux environment? I think the answer is yes. For a Linux or Mac developer, I think they more likely to use Azure CLI. Both, Azure CLI and the PowerShell package use the REST API of Azure. As one of our Microsoft contacts said: Use whatever you like and you prefer. There are some pros for Azure CLI: Open Source - which has many advantages. It might be developing faster in the future. You can view what is really in

Argb Color Picker Code Example

Example 1: rgb yellow color rgb(255,255,0) /* yellow*/ Hex #FFFF00 Example 2: dark blue rgb I like (0,0,205) but it isn't super dark Example 3: html color codes #1ca69d #e31ce0 #c13e72 #99b34d #3affb9 #6c7093 #b35ba0 #1b1452

Cdn Slick Slider Code Example

Example 1: slick slider cdn CSS < link rel = " stylesheet " type = " text/css " href = " cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css " /> JS < script type = " text/javascript " src = " cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js " > </ script > Example 2: slick slider cdn add latest version of slick slider css < link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css " integrity = " sha512-yHknP1/AwR+yx26cB1y0cjvQUMvEa2PFzt1c9LlS4pRQ5NOTZFWbhBig+X9G9eYW/8m0/4OXNx8pxJ6z57x0dw== " crossorigin = " anonymous " /> js < script src = " https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js " integrity = " sha512-XtmMtDEcNz2j7ekrtHvOVR4iwwaD6o/FUJe6+Zq+HgcCsk3kj4uSQQR8weQ2QVj1o0Pk6PwYLohm206ZzNfubg== " crossorigin = " anonymous

Cannot Login To SourceTree

Answer : Try quitting the SourceTree app and re-launching. I had a similar problem. My id.atlassian.com credentials worked online but repeatedly failed in SourceTree. It worked for me after a relaunch. Atlassian recommends sticking with the older version at the moment: https://twitter.com/sourcetree/status/699624992003244033 Update On Feb 22, Atlassian apologized and released SourceTree 2.2.2. However, some folks are still tweeting issues with the initial login on the release announcement.

Print Long Double In C Code Example

Example: print double in c # include <stdio.h> int main ( ) { double d = 123.32445 ; //using %f format specifier printf ( "Value of d = %f\n" , d ) ; //using %lf format specifier printf ( "Value of d = %lf\n" , d ) ; return 0 ; }

Latex \footnotesize Code Example

Example 1: latex font sizes \Huge \huge \LARGE \Large \large \ normalsize ( default ) \small \footnotesize \scriptsize \tiny Example 2: latex font sizes Change global font size : \documentclass [ 12 pt ] { report }

How To Find The Angle Of A Triangle Given 3 Sides Code Example

Example: how to find a point on a triangle with only sides known sides AB , BC , AC known points A ( x , y ) , B ( x , y ) unknown points C ( x , y ) AC² - BC² = ( ( Ax - Cx ) ² + ( Ay - Cy ) ² ) - ( ( Bx - Cx ) ² + ( By - Cy ) ² ) Goal : C . x = ? C . y = ?

ASP.NET Custom Error Page - Server.GetLastError() Is Null

Image
Answer : Looking more closely at my web.config set up, one of the comments in this post is very helpful in asp.net 3.5 sp1 there is a new parameter redirectMode So we can amend customErrors to add this parameter: <customErrors mode="RemoteOnly" defaultRedirect="~/errors/GeneralError.aspx" redirectMode="ResponseRewrite" /> the ResponseRewrite mode allows us to load the «Error Page» without redirecting the browser, so the URL stays the same, and importantly for me, exception information is not lost. OK, I found this post: http://msdn.microsoft.com/en-us/library/aa479319.aspx with this very illustrative diagram: (source: microsoft.com) in essence, to get at those exception details i need to store them myself in Global.asax, for later retrieval on my custom error page. it seems the best way is to do the bulk of the work in Global.asax, with the custom error pages handling helpful content rather than logic. A combination of w

Check Size Of Array Javascript Code Example

Example 1: array length javascript var arr = [ 10 , 20 , 30 , 40 , 50 ] ; //An Array is defined with 5 instances var len = arr . length ; //Now arr.length returns 5.Basically, len=5. console . log ( len ) ; //gives 5 console . log ( arr . length ) ; //also gives 5 Example 2: javascript size array let array = [ 1 , 2 , 3 ] ; console . log ( array . length ) ; Example 3: length of an array javascript array . length