Posts

Showing posts from May, 2017

How To Match Exact String In Regex Code Example

Example 1: regex match exact string you want to achieve a case insensitive match for the word "rocket" surrounded by non-alphanumeric characters. A regex that would work would be: \ W* (( ? i ) rocket ( ? - i )) \ W* Example 2: regex exact match use ^ and $ to match the start and end of your string ^matchmeexactly$

Com.google.code.gson Code Example

Example: gson dependency android dependencies { implementation 'com.google.code.gson:gson:2.8.6' } < dependency > < groupId > com.google.code.gson </ groupId > < artifactId > gson </ artifactId > < version > 2.8.6 </ version > </ dependency >

Background Image React Code Example

Example 1: how to add background image in react css import React from 'react' ; import car from './images/car.png' function App ( ) { return ( < div styles = { { backgroundImage : ` url( ${ car } ) ` } } > < h1 > This is red car < / h1 > < / div > ) ; } export default App ; Example 2: react background image style = { { backgroundImage : "url(" + "https://images.pexels.com/photos/34153/pexels-photo.jpg?auto=compress&cs=tinysrgb&h=350" + ")" , backgroundPosition : 'center' , backgroundSize : 'cover' , backgroundRepeat : 'no-repeat' } } Example 3: Setting a background Image With React Inline Styles backgroundImage : ` url( ${ Background } ) ` Example 4: how to import background image in inline css in react style = { { backgroundImage : ` url( ${ pencil } ) ` } }

Can I Use MySQL Workbench To Create MariaDB?

Answer : From my experience -- Sure, you can use MySQL Workbench with MariaDB. However, I have tried basic functionalities only, like queries, schema design etc. Not sure about compatibility of advanced features. Just to list a few other options: MySQL Workbench Heidi Sql SQLyog So my experiences are, yes you can use MySQL Workbench for MariaDB database designs. However I needed to change the "Default Target MySQL Version" to 5.7 . This can be done by going to: Edit->Preferences in the menu. And finally to Modeling->MySQL. Since the latest MySQL version, v8.x, the SQL statements are not compatible with MariaDB statements (like creating an index). MariabDB creating an index on a table: INDEX `fk_rsg_sub_level_rsg_top_level1_idx` (`rgs_top_level_id` ASC) vs MySQL: INDEX `fk_rsg_sub_level_rsg_top_level1_idx` (`rgs_top_level_id` ASC) VISIBLE MariaDB can't handle this VISIBLE keyword in this example. Using an old MySQL Version, MySQL Workbench

Android: GetContext().getContentResolver() Sometimes Gets NullPointerException

Answer : If you look in the source of ContentProvider (just hold SHIFT and click on the classname in Android Studio) then you will find that the implementation is holding an object of type Context as mContext. Your solution is just the same, which means if mContext of ContentProvider is null, your reference will also be null. So there is no need for this. To help you out, this is just a warning of your IDE if make such a construct yourself. But in this case there will always be context, because the ContentProvider is generated by your system. To avoid the error in your IDE just write @SuppressWarnings("ConstantConditions") above your class definition like: ... @SuppressWarnings("ConstantConditions") public class NoteProvider extends ContentProvider { ... If you can make sure that getContext() can never be null then you can simply ignore this warning. I think the warning even disappears of you just check for null: if (getContext() != null) { getCon

Class-validator - Validate Array Of Objects

Answer : Add @Type(() => AuthParam) to your array and it should be working. Type decorator is required for nested objects(arrays). Your code becomes import { IsArray, ValidateNested, ArrayMinSize, ArrayMaxSize } from 'class-validator'; import { AuthParam } from './authParam.model'; import { Type } from 'class-transformer'; export class SignInModel { @IsArray() @ValidateNested({ each: true }) @ArrayMinSize(2) @ArrayMaxSize(2) @Type(() => AuthParam) authParameters: AuthParam[]; } Be careful if you are using any exception filter to modify the error reponse. Make sure you understand the structure of the class-validator errors. You can use the following: validator.arrayNotEmpty(array); // Checks if given array is not empty. validator.arrayMinSize(array, min); // Checks if array's length is at least `min` number. (https://github.com/typestack/class-validator#manual-validation) You may want to consider writing custom validator w

Ahref Onclick Javascript Code Example

Example: on click in a tag < a onclick = ' newwin() ' > Anchor </ a >

Axios Cdn Example

Example 1: axios cdn < script src = " https://unpkg.com/axios/dist/axios.min.js " > </ script > Example 2: axios cdn < script src = " https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js " > </ script > Example 3: AXIOS CDN < script src = " https://unpkg.com/axios/dist/axios.min.js " > </ script > Example 4: axios cdn const FormData = require('form-data'); const form = new FormData(); form.append('my_field', 'my value'); form.append('my_buffer', new Buffer(10)); form.append('my_file', fs.createReadStream('/foo/bar.jpg')); axios.post('https://example.com', form, { headers: form.getHeaders() })

Apache, Problem Failed To Start LSB: Apache2 Web Server

Answer : There are two errors: 1. For some reason your /etc/apache2/envvars is missing: from journalctl -xe : Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 1: /etc/apache2/envvars: envvars: not found Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /etc/init.d/apache2: 49: /etc/apache2/envvars: envvars: not found ... Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not found Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 49: /etc/apache2/envvars: envvars: not found from systemctl status apache2.service : Jan 11 02:30:46 aleksandr-VirtualBox apache2[8177]: /usr/sbin/apache2ctl: 1: /etc/apache2/envvars: envvars: not fo

Android Set Transparent Background Programmatically Code Example

Example 1: how to make background image transparent in android studio android:backgroundTint="#80FFFFFF" android:backgroundTintMode="src_over" >>for setting background as transparent in android studio(only bg) android:alpha="0.4" >>for all views Example 2: android java transparent background 100% — FF 95% — F2 90% — E6 85% — D9 80% — CC 75% — BF 70% — B3 65% — A6 60% — 99 55% — 8C 50% — 80 45% — 73 40% — 66 35% — 59 30% — 4D 25% — 40 20% — 33 15% — 26 10% — 1A 5% — 0D 0% — 00

Bootstrap 4 Modal Popup Full Screen Code Example

Example 1: bootstrap modal popup < button type = "button" class = "btn btn-info btn-lg" data - toggle = "modal" data - target = "#myModal" > Open Modal < / button > < ! -- Modal -- > < div id = "myModal" class = "modal fade" role = "dialog" > < div class = "modal-dialog" > < ! -- Modal content -- > < div class = "modal-content" > < div class = "modal-header" > < button type = "button" class = "close" data - dismiss = "modal" > & times ; < / button > < h4 class = "modal-title" > Modal Header < / h4 > < / div > < div class = "modal-body" > < p > Some text in the modal . < / p > < / div > < div class = "modal-footer" > <

Raised Button Color Flutter Code Example

Example 1: flutter raisedbutton example RaisedButton ( child: Text ( "Rock & Roll" ) , onPressed: _changeText, color: Colors.red, textColor: Colors.yellow, padding: EdgeInsets.fromLTRB ( 10 , 10 , 10 , 10 ) , splashColor: Colors.grey, ) Example 2: flutter elevated button ElevatedButton ( onPressed: ( ) { } , child: Text ( 'Submit' ) , ) ; Example 3: raisedbutton background color List < bool > _list = [ true, false, true, false ] ; @override Widget build ( BuildContext context ) { return Scaffold ( appBar: AppBar ( title: Text ( "Title" )) , body: ListView ( children: _buildButtons ( )) , ) ; } List < Widget > _buildButtons ( ) { List < Widget > listButtons = List.generate ( _list.length, ( i ) { return RaisedButton ( color: _list [ i ] ? Colors.green : Colors.red, onP

Bootstrap 4 Footer W3schools Code Example

Example: html footer <footer> <!-- Footer links --> <nav> <a href= "some-url" target= "_blank" >Footer link</a> <!-- opens in new tab --> <a href= "some-url" >Footer link</a> <a href= "some-url" >Footer link</a> </nav> <!-- Copyright footnote --> &copy ; 2020 Some copyright message. <!-- Contact link --> <address> Contact <a href= "mailto:me@mailservice.com" >me</a> </address> </footer>

Android Bottom Navigation Bar With Drop Shadow

Answer : You can draw your own shadow just above the bottom bar using simple View and its background: <View android:layout_width="match_parent" android:layout_height="4dp" android:layout_above="@id/bottom_bar" android:background="@drawable/shadow"/> drawable/shadow.xml: <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#1F000000" android:endColor="@android:color/transparent" android:angle="90" /> </shape> Also, there are no compatibility issues if use this approach. You can use elevation to add shadows to any view <TextView android:id="@+id/myview" ... android:elevation="2dp" android:background="@drawable/myrect" /> Refer this for more information For those using a CoordinatorLayout with the Bottom Navigation Bar (or BottomAppBar ), you can