Posts

Showing posts from February, 2014

Correct Way To Declare Multiple Scope For Maven Dependency?

Answer : The runtime scope also makes the artifact available on the test classpath. Just use runtime. (See the Maven documentation.) To avoid having the dependency resolved transitively, also make it optional with <optional>true</optional> : <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback</artifactId> <version>0.5</version> <scope>runtime</scope> <optional>true</optional> </dependency> You can only define one scope value per <scope/> tag. I'm afraid what you'd like to do cannot be achieved by merely using a scope. If you define a scope of test , it will only be available during tests; if you define a scope of provided, that would mean that you would expect that dependency for your project to be resolved and used during both compilation and tests, but it will not be included in your WAR file. Either way, it's not what you would want. Therefore, I would r

Alternative Segmentation Techniques Other Than Watershed For Soil Particles In Images

Image
Answer : You could try using Connected Components with Stats already implemented as cv2.connectedComponentsWithStats to perform component labeling. Using your binary image as input, here's the false-color image: The centroid of each object can be found in centroid parameter and other information such as area can be found in the status variable returned from cv2.connectedComponentsWithStats . Here's the image labeled with the area of each polygon. You could filter using a minimum threshold area to only keep larger polygons Code import cv2 import numpy as np # Load image, Gaussian blur, grayscale, Otsu's threshold image = cv2.imread('2.jpg') blur = cv2.GaussianBlur(image, (3,3), 0) gray = cv2.cvtColor(blur, cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1] # Perform connected component labeling n_labels, labels, stats, centroids = cv2.connectedComponentsWithStats(thresh, connectivity=4) # Create fal

Convert From Mbr To Gpt Cmd Code Example

Example: convert mbr to gpt cmd Step 1. Open an elevated Command Prompt: press Win+R on your keyboard to open Run dialogue, in which type cmd and hit on Enter. Step 2. In the elevated Command Prompt window, type diskpart and press Enter to launch DiskPart Windows. And execute following commands in sequence. list disk (display all the online disks) select disk n (n represents the number of the target MBR disk) clean (remove all partitions on the target disk if there are) convert gpt

Angular Select Option With Selected Attribute Not Working

Answer : When you use ngModel, the state is handled internally and any explicit change to it just gets ignored. In your example, you are setting the selected property of option , but you are also providing a (void) ngModel to your select , so Angular expects that the state of the select is provided within the ngModel. Briefly, you should leverage on your ngModel instead than setting the selected property: <select name="rate" #rate="ngModel" [(ngModel)]="yourModelName" required> <option value="hr">hr</option> <option value="yr">yr</option> </select> And: yourModelName: string; constructor() { this.yourModelName = 'hr'; } If you don't wish to have a two-way binding, you can set ngModel to the 'default' value and with the template local variable get the selected value: <select #rate ngModel="hr"> <option se

How To Add Color Text In Discord Code Example

Example 1: css discord color guide Default : # 839496 ``` NoKeyWordsHere ``` Quote : # 586e75 ```brainfuck NoKeyWordsHere ``` Solarized Green : # 859900 ```CSS NoKeyWordsHere ``` Solarized Cyan : # 2 aa198 ```yaml NoKeyWordsHere ``` Solarized Blue : # 268 bd2 ```md NoKeyWordsHere ``` Solarized Yellow : #b58900 ```fix NoKeyWordsHere ``` Solarized Orange : #cb4b16 ```glsl NoKeyWordsHere ``` Solarized Red : #dc322f ```diff - NoKeyWordsHere ``` Example 2: css discord color guide And here is the escaped Default : # 839496 ``` This is a for statement ``` Quote : # 586e75 ```bash # This is a for statement ``` Solarized Green : # 859900 ```diff + This is a for statement ``` //Second Way to do it ```diff ! This is a for statement ``` Solarized Cyan : # 2 aa198 ```cs "This is a for statement" ``` ```cs 'This is a for statement' ``` Solarized Blue : # 268 bd2 ```ini [ This is a for statement ] ``` //Second Way to do it ```asciido

Longest Common Subsequence Gatevidyalay Code Example

Example 1: longest common subsequence class Solution : def longestCommonSubsequence ( self , text1 : str , text2 : str ) -> int : "" " text1 : horizontally text2 : vertically "" " dp = [ [ 0 for _ in range ( len ( text1 ) + 1 ) ] for _ in range ( len ( text2 ) + 1 ) ] for row in range ( 1 , len ( text2 ) + 1 ) : for col in range ( 1 , len ( text1 ) + 1 ) : if text2 [ row - 1 ] == text1 [ col - 1 ] : dp [ row ] [ col ] = 1 + dp [ row - 1 ] [ col - 1 ] else : dp [ row ] [ col ] = max ( dp [ row - 1 ] [ col ] , dp [ row ] [ col - 1 ] ) return dp [ len ( text2 ) ] [ len ( text1 ) ] Example 2: longest common subsequence int maxSubsequenceSubstring ( char x [ ] , char y [ ] , int n , int m ) { int dp [ MAX ] [ MAX ] ;

Can I Connect A SATA Disk On A SAS Connector On The Motherboard?

Image
Answer : Can I connect SATA drives to SAS connectors? Yes , well known question / answer Does the 6 Gb/s transfer rate means that I'll get an equivalent of SATA 3 (which is important if I use SATA 3 SSDs)? Yes . They will negotiate the speed, slower device wins (12G sas ctrl will lower speed to sata 2 drive if needed) or drive will lower speed to older SAS controller. MSM software (or BIOS) can show you negotiated speeds. Are there drawbacks using SAS connectors instead of SATA 3 ones for SATA 2 and SATA 3 drives? In other words, if the motherboard has both SATA 3 and SAS connectors, what is the reason, if any, to use SATA 3 connectors for SATA drives? Use SAS . Usually SATA connector are part of Intel southbridge. Tests I've done show throughput drops proportionally to number of SATA drives connected to southbridge and results were horrific for 6 drives used simultaneously on Intel southbridge. SAS controller on your motherboard is probably LSI using

Copy Multiple Files From S3 Bucket

Answer : Also one can use the --recursive option, as described in the documentation for cp command. It will copy all objects under a specified prefix recursively. Example: aws s3 cp s3://folder1/folder2/folder3 . --recursive will grab all files under folder1/folder2/folder3 and copy them to local directory. There is a bash script which can read all the filenames from a file filename.txt . #!/bin/bash set -e while read line do aws s3 cp s3://bucket-name/$line dest-path/ done <filename.txt You might want to use "sync" instead of "cp". The following will download/sync only the files with the ".txt" extension in your local folder: aws s3 sync --exclude="*" --include="*.txt" s3://mybucket/mysubbucket .

ANALYZE TABLE..VALIDATE STRUCTURE Runs Forever

Answer : UPDATE: What Worked... So after reading the link from @Raj and reading @ora-600's answer I tried to validate the database with the RMAN command backup check logical validate database; . While this worked fine, it was also clear that it was not looking at everything that the ANALYZE INDEX command would. After trying many different variations, I finally discovered that this command would work: ANALYZE TABLE .. VALIDATE STRUCTURE CASCADE offline; Yep, just switching to OFFLINE appears to fix it. And that eventually led me to this bug# 5752105 on this page: http://www.eygle.com/case/10204_buglist.htm. I am not in a position to prove it right now (cannot apply any patches for the time being), but I strongly suspect that this is what I was running into. So while the question is not fully answered, I am going to mark @ora-600's very helpful answer as correct so that he can collect Paul White's very generous bounty. I think the article Raj quoted (https:

Build React Native App For Android Apk Code Example

Example 1: build apk react native After run this in cmd react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ cd android && ./gradlew assembleDebug then you can get apk app/build/outputs/apk/debug/app-debug.apk Example 2: react-native android build apk cd android ./gradlew assembleRelease Example 3: export app react native mkdir -p android/app/src/main/assets react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res cd android && ./gradlew assembleRelease -x bundleReleaseJsAndAssets - Your APK will be present in the folder < project > /android/app/build/outputs/apk/release Example 4: how to make apk in android studio reac native ... android { ... defaultConfig { ... } signingConfigs { releas

Add Views In UIStackView Programmatically

Image
Answer : Stack views use intrinsic content size, so use layout constraints to define the dimensions of the views. There is an easy way to add constraints quickly (example): [view1.heightAnchor constraintEqualToConstant:100].active = true; Complete Code: - (void) setup { //View 1 UIView *view1 = [[UIView alloc] init]; view1.backgroundColor = [UIColor blueColor]; [view1.heightAnchor constraintEqualToConstant:100].active = true; [view1.widthAnchor constraintEqualToConstant:120].active = true; //View 2 UIView *view2 = [[UIView alloc] init]; view2.backgroundColor = [UIColor greenColor]; [view2.heightAnchor constraintEqualToConstant:100].active = true; [view2.widthAnchor constraintEqualToConstant:70].active = true; //View 3 UIView *view3 = [[UIView alloc] init]; view3.backgroundColor = [UIColor magentaColor]; [view3.heightAnchor constraintEqualToConstant:100].active = true; [view3.widthAnchor constraintEqualToConstant

Update Multiple Columns Sql Code Example

Example 1: update column sql server UPDATE table_name SET column1 = value1 , column2 = value2 , . . . WHERE condition ; Example 2: add multiple columns to table sql //Example ALTER TABLE employees ADD last_name VARCHAR ( 50 ) , first_name VARCHAR ( 40 ) ; Example 3: sql update multiple columns from another table -- Oracle UPDATE table2 t2 SET ( VALUE1 , VALUE2 ) = ( SELECT COL1 AS VALUE1 , COL1 AS VALUE2 FROM table1 t1 WHERE t1 . ID = t2 . ID ) ; -- SQL Server UPDATE table2 t2 SET t2 . VALUE1 = t1 . COL1 , t2 . VALUE2 = t1 . COL2 FROM table1 t1 INNER JOIN t2 ON t1 . ID = t2 . ID ; -- MySQL UPDATE table2 t2 INNER JOIN table1 t1 USING ( ID ) SET T2 . VALUE1 = t1 . COL1 , t2 . VALUE2 = t1 . COL2 ; Example 4: sql server update multiple columns at once UPDATE Person . Person Set FirstName = 'Kenneth' , LastName = 'Smith' WHERE BusinessEntityID = 1 Example 5: update multi

Disable Iplut From Mouse And Keyboard Unity Code Example

Example: disable mouse unity Cursor . lockState = CursorLockMode . locked ; Cursor . visible = false ;

Angular: How To Download A File From HttpClient?

Answer : Blobs are returned with file type from backend. The following function will accept any file type and popup download window: downloadFile(route: string, filename: string = null): void{ const baseUrl = 'http://myserver/index.php/api'; const token = 'my JWT'; const headers = new HttpHeaders().set('authorization','Bearer '+token); this.http.get(baseUrl + route,{headers, responseType: 'blob' as 'json'}).subscribe( (response: any) =>{ let dataType = response.type; let binaryData = []; binaryData.push(response); let downloadLink = document.createElement('a'); downloadLink.href = window.URL.createObjectURL(new Blob(binaryData, {type: dataType})); if (filename) downloadLink.setAttribute('download', filename); document.body.appendChild(downloadLink); downloadLink.click(); }

3d Plot Matlab Code Example

Example: 3D plot matplotlib import matplotlib . pyplot as plt from mpl_toolkits . mplot3d import Axes3D fig = plt . figure ( ) ax = fig . add_subplot ( 111 , projection = '3d' )

How To Use Laravel Resource Route Code Example

Example 1: laravel route resources // Implicit Model Binding Routes can be created with one line using either: Route :: resource ( 'photos' , PhotoController :: class ) ; // OR Route :: resources ( [ 'photos' = > PhotoController :: class , 'posts' = > PostController :: class , ] ) ; php artisan make : controller PhotoController -- resource -- model = Photo // makes a controller with stubouts for methods: // index // create // store // show // edit // update // destroy Example 2: how to named route resource laravel Route :: resource ( 'faq' , 'ProductFaqController' , [ 'names' = > [ 'index' = > 'faq' , 'store' = > 'faq.new' , // etc... ] ] ) ; Example 3: Route::resource php artisan make : controller PhotoController -- resource Example 4: Route::resource Route :: resource ( 'photos' , Phot

Cool Cursors Css Code Example

Example 1: css cursor pointer hover .pointer { cursor : pointer ; } Example 2: cursor as image css You can use own image or emoji as cursor <style > a { cursor : url ( "custom.gif" ) , url ( "custom.cur" ) , default ; } </style> <p>Place your mouse pointer <a href= "#" >over me</a> to reveal the custom cursor.</p> Example 3: change the cursor css /* All differents cursors */ /* See https://www.w3schools.com/cssref/playit.asp?filename=playcss_cursor */ /* to test them all */ cursor : alias cursor : all-scroll ; cursor : auto ; cursor : cell ; cursor : context-menu ; cursor : col-resize ; cursor : copy ; cursor : crosshair ; cursor : default ; cursor : e-resize ; cursor : ew-resize ; cursor : grab ; cursor : grabbing ; cursor : help ; cursor : move ; cursor : n-resize ; cursor : ne-resize ; cursor : nesw-resize ; cursor : ns-resize ; cursor : nw-resize ; cursor : nwse-r

Alphabetizing Methods In Visual Studio

Answer : While Resharper has many cool features it has a large impact in CPU and I/O usage and can be very complicated to use. It is also only available under commercial licensing unless you qualify for a few very specific free use licenses. Try CodeMaid. It is free for commercial use and has a much lower performance overhead. I find it easy to use and it is very good for alphabetizing methods. To sort your file, open the file via solution explorer: Right click the open file Code Maid menu (likely near the top of the right click menu) Click Reorganize Active Document Alternatively, using the default CodeMaid hotkeys CTRL + M , Z to sort your active file. Resharper has a Type Members Layout, which can order members by type, accessibility and alphabetically as well. You can also take a look into Ora , which presents a pane in visual studio that is ordered (even though your source may not be). Link's dead. The following answer goes much further than the OP asks,

How To Convert Int To String C] Code Example

Example: c int to string # include <stdio.h> int main ( ) { char number_str [ 10 ] ; int number = 25 ; sprintf ( number_str , "%d" , number ) ; printf ( "Converted to string : %s\n" , number_str ) ; return 0 ; }