text
How do I know if my PostgreSQL server is using the “C” locale?
Currently some locale [docs] support can only be set at initdb time, but I think the one relevant to _pattern_ops can be modified via SET at runtime, LC_COLLATE. To see the set values you can use the SHOW command. For example: SHOW LC_COLLATE _pattern_ops indexes are useful in columns that use pattern matching constructs, like … Read more
How to make text stroke in SwiftUI?
Here is a 100% SwiftUI solution. Not perfect, but it works and it gives you full SwiftUI control of the resulting view. import SwiftUI struct SomeView: View { var body: some View { StrokeText(text: “Sample Text”, width: 0.5, color: .red) .foregroundColor(.black) .font(.system(size: 12, weight: .bold)) } } struct StrokeText: View { let text: String let … Read more
Extract text from HTML while preserving block-level element newlines
Consider: /** * Returns the style for a node. * * @param n The node to check. * @param p The property to retrieve (usually ‘display’). * @link http://www.quirksmode.org/dom/getstyles.html */ this.getStyle = function( n, p ) { return n.currentStyle ? n.currentStyle[p] : document.defaultView.getComputedStyle(n, null).getPropertyValue(p); } /** * Converts HTML to text, preserving semantic newlines for … Read more
What is a cross platform regex for removal of line breaks?
Fletcher – this did get asked once before. Here you go: Regular Expression to match cross platform newline characters Spoiler Alert! The regex I use when I want to be precise is “\r\n?|\n”.
Text on image mouseover?
This is using the :hover pseudoelement in CSS3. HTML: <div id=”wrapper”> <img src=”http://placehold.it/300×200″ class=”hover” /> <p class=”text”>text</p> </div> CSS: #wrapper .text { position:relative; bottom:30px; left:0px; visibility:hidden; } #wrapper:hover .text { visibility:visible; } Demo HERE. This instead is a way of achieving the same result by using jquery: HTML: <div id=”wrapper”> <img src=”http://placehold.it/300×200″ class=”hover” /> <p … Read more
How can I clean up misaligned columns in text?
Presumably you are using printf to output the columns in the first place. You can use extra modifiers in your format string to make sure things get aligned. To print a column of a specific width (right-justified), add the width before the formatting flag, e.g., “%10s” will print a column of width 10. If your … Read more
How to read a file from a jar file?
If your jar is on the classpath: InputStream is = YourClass.class.getResourceAsStream(“1.txt”); If it is not on the classpath, then you can access it via: URL url = new URL(“jar:file:/absolute/location/of/yourJar.jar!/1.txt”); InputStream is = url.openStream();
Border around UITextView
#import <QuartzCore/QuartzCore.h> Import the above framework and include these lines in your class where textview is defined. [[self.textview layer] setBorderColor:[[UIColor grayColor] CGColor]]; [[self.textview layer] setBorderWidth:2.3]; [[self.textview layer] setCornerRadius:15]; Swift solution. self.textview.layer.borderColor = UIColor.gray.cgColor self.textview.layer.borderWidth = 2.3 self.textview.layer.cornerRadius = 15