Posts

Showing posts from October, 2012

Collections Sort List Java Code Example

Example: how to sort collection in java // Use Collections.sort() import java . util . * ; ArrayList < String > al = new ArrayList < String > ( ) ; al . add ( "teach" ) ; al . add ( "sleep" ) ; al . add ( "geek" ) ; Collections . sort ( al ) ; //just pass any collection object reference System . out . println ( al ) ; //output :- [geek,sleep,teach] or /* ArrayList<Integer> intal = new ArrayList<Integer>(); al.add(4); al.add(8); al.add(2); Collections.sort(intal); System.out.println(intal);//output :- [2,4,8] */

Add NOT NULL Constraint To Large Table Without Table Scan

Answer : Is there a way to prevent a full table scan during the alter table statement? At this time there is no supported, safe way to do that with PostgreSQL. Some kind of ALTER TABLE ... ADD CONSTRAINT ... CONCURRENTLY would be nice, but nobody's implemented it. Same with the alternative of adding a NOT VALID constraint that still affects new rows, and that you then VALIDATE later - it'd be good, and it's something everyone knows is needed but nobody's had the time or funding to add yet. In theory you could directly modify the system catalogs to add the constraint if you know it is true and valid. In practice, well, it's generally not a great idea. So no, there isn't really a way. One potential alternative is to create a check constraint using NOT VALID , then validating the check constraint later. This method requires holding an ACCESS EXCLUSIVE lock only for the duration to create the constraint, which should be on the order of millisecon

Azure DevOps - Compare Two Commits Right In The Web UI?

Image
Answer : If you go to the list of branches for a repository, you can click on ... (More Actions) on one of the branches and choose Compare branches This will take you to a URL in the form: https://dev.azure.com/{organisation}/{project}/_git/{repository}/branches?baseVersion=GB{baseBranch}&targetVersion=GB{targetBranch}&_a=files You can then change the baseVersion and targetVersion parameters in the query string. These can take the following forms, and can be mixed and matched: GB{branchName} GC{commitHash} GT{tagName} Just in case that link gets broken, clicking "View Merge Changes" on a pull request takes you to the same page but with a slightly different URL https://dev.azure.com/{organisation}/{project}/_git/{repository}/branchCompare?baseVersion=GC{baseCommit}&targetVersion=GC{targetCommit}&_a=files I'm not sure if there's a nicer way of comparing commits from the UI, as it only shows branches and tags, but if you do it this wa

108 F To C Code Example

Example 1: c to f let f = c * ( 9 / 5 ) + 32 ; let c = ( f - 32 ) * ( 5 / 9 ) ; Example 2: 14 f to c 14 ° F = - 10 ° C

Android Toolbar Center Title And Custom Font

Image
Answer : To use a custom title in your Toolbar all you need to do is remember is that Toolbar is just a fancy ViewGroup so you can add a custom title like so: <android.support.v7.widget.Toolbar android:id="@+id/toolbar_top" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="@color/action_bar_bkgnd" app:theme="@style/ToolBarTheme" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toolbar Title" android:layout_gravity="center" android:id="@+id/toolbar_title" /> </android.support.v7.widget.Toolbar> This means that you can style the TextView however you would like because it's just a regular TextView . So in your activity you can access the title

BootStrap CSS Margin 0 Auto Not Center

Answer : Bootstrap 4 use Use text-center or mx-auto or container-fluid You could use this hack text-center (this does not only apply for text) Or use the exact boostrap4 class mx-auto example class="text-center" or class="mx-auto" in context <div class="btn-group text-center"> or <div class="btn-group mx-auto"> TRY NOT TO USE inline styles (bad practice) <div class="btn-group" style="margin:0 auto"> References here: text-center => https://getbootstrap.com/docs/4.0/utilities/text/ mx-auto => https://getbootstrap.com/docs/4.0/utilities/spacing/#horizontal-centering You don't need to use inline styles, just apply the class "text-center" which is already included in bootstrap EDIT: Guillemo Mansilla's answer is better. Same technique but better use of existing Bootstrap classes. You can set text-align: center on the .container . No need for the

Azure CDN Microsoft Standard Rules Engine Rewrite URL For Single-page-application

Answer : I finally got a working answer from Microsoft Support on this. They said that the Microsoft CDN Rules Engine does not support URL file extension Not Any and instead I should check for the length of the file extension. Condition: URL file extension Operator = Not greater than Extension = 0 Case Transform = No transform Action: URL rewrite Source Pattern = / Destination = /index.html Preserve unmatched path = No This solution works for me. Make sure to purge your cdn cache before testing. If none of your page URLs contain a dot, you can set a rule as follows: Condition: 'URL file extension' = Not Any (i.e. there is no extension) Action: 'URL rewrite', source = / destination = index.html Preserve umatched path = No This will rewrite any URL without a dot in the trailing section to index.html.

Cara Update Node Js 12 Ke Versi 14 Windows Code Example

Example 1: ubuntu update nodejs # Using Ubuntu curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - sudo apt-get install -y nodejs # Using Debian, as root curl -sL https://deb.nodesource.com/setup_13.x | bash - apt-get install -y nodejs Example 2: how to update node in ubuntu 18.04 sudo npm cache clean -f sudo npm install -g n sudo n stable

Can I Recover Unstaged Changes After Reset Hard In Git ? Code Example

Example 1: what to do with unstaged changes after reset git reset --hard Example 2: what to do with unstaged changes after reset git rm --cached -r .

Change Button Background Color Through MVVM Pattern In WPF

Answer : You could bind the control's Background to a property on the viewmodel, the trick is to use an IValueConverter to return a Brush with the color you require. Here's an example that converts a boolean value from the viewmodel to a color: public class BoolToBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return Brushes.Transparent; return Convert.ToBoolean(value) ? Brushes.Red : Brushes.Transparent; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } with a binding expression like "{Binding Reviewed, Converter={StaticResource BoolToBrushConverter}}" where Reviewed is your boolean viewmodel property. Using triggers: <Button> <Button.Style> <Style Target

43 Inches To Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Center Align Button Bootstrap 4 Code Example

Example 1: button center bootstrap < div class = " text-center " > < button type = " button " class = " btn btn-primary " > My button </ button > </ div > Example 2: bootstrap button center < div class = " container my-4 " > < p class = " font-weight-bold " > You can align the button to the center by simply adding alignment class to the parent div. See the examples. </ p > < p > < strong > Detailed documentation and more examples you can find in our < a href = " https://mdbootstrap.com/docs/jquery/utilities/horizontal-align/ " target = " _blank " > Bootstrap Horizontal alignment Docs </ a > </ p > < hr > < p class = " font-weight-bold " > Basic example </ p > < p > Add class < code > .text-center </ code &

Change Popcorn Time Download Folder Code Example

Example: where is popcorn time media stored on pc C:\Users\ < USERNAME > \AppData\Local\Temp

Change Border Color In TextBox C#

Image
Answer : To change border color of TextBox you can override WndProc method and handle WM_NCPAINT message. Then get the window device context of the control using GetWindowDC because we want to draw to non-client area of control. Then to draw, it's enough to create a Graphics object from that context, then draw border for control. To redraw the control when the BorderColor property changes, you can use RedrawWindow method. Code Here is a TextBox which has a BorderColor property. The control uses BorderColor if the property values is different than Color.Transparent and BorderStyle is its default value Fixed3d . using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; public class MyTextBox : TextBox { const int WM_NCPAINT = 0x85; const uint RDW_INVALIDATE = 0x1; const uint RDW_IUPDATENOW = 0x100; const uint RDW_FRAME = 0x400; [DllImport("user32.dll")] static extern IntPtr GetWi

Access Part Of Duple Python Code Example

Example: make a tuple of any object in python # tuple repitition works like this print ( ( 'Hi!' , ) * 4 ) # output: ('Hi!', 'Hi!', 'Hi!', 'Hi!')

Bootstrap Code Example

Example 1: how to change the color of the hr tag in html <style > hr { height : 1 px ; background-color : #ccc ; border : none ; } </style> Example 2: html horizontal line style <!-- HTML --> <!-- You can change the style of the horizontal line like this : --> <hr style= "width:50%" , size= "3" , color= black > <!-- Or like this : --> <hr style= "height:2px; width:50%; border-width:0; color:red; background-color:red" > Example 3: how to style an hr tag /* Red border */ hr .new1 { border-top : 1 px solid red ; } /* Dashed red border */ hr .new2 { border-top : 1 px dashed red ; } /* Dotted red border */ hr .new3 { border-top : 1 px dotted red ; } /* Thick red border */ hr .new4 { border : 1 px solid red ; } /* Large rounded green border */ hr .new5 { border : 10 px solid green ; border-radius : 5 px

Amazon Video Login Code Example

Example: prime video This platform is addictive as hell. Stay away if you wanna be productive

46 Inches To Cm Code Example

Example: inch to cm 1 inch = 2.54 cm