Posts

Showing posts from September, 2003

Angular 4 - Conditional CSS Classes

Answer : You can do this using the class binding: <input type="email" class="form-control" [class.error-field]="error"> yeah there's a better way using ngClass attribute like this: <input type="email" [ngClass]="{'form-control': true, 'error-field': error}" /> I believe you are looking for NgClass or NgStyle: https://angular.io/api/common/NgClass https://angular.io/api/common/NgStyle

Android And Android Sdk Versions Code Example

Example: android get sdk version if(android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.LOLLIPOP){ // Code For Android Version higher equal to LOLLIPOP(21) } else if(android.os.Build.VERSION.SDK_INT > 21){ // Code For Android Version higher than LOLLIPOP(21) } else{ // Code For Android Version lower than LOLLIPOP(21) }

Check If Player Has Item, If So Remove It

Image
Answer : Try this, By using /clear , you can scan people for items. If you want to remove certain items, use /clear @p(or <playername>) <itemid> For example, on a server that doesn't want griefing you could have a clock connected to a command block set to /clear @p minecraft:flint_and_steel , you can also specify how much of an item to remover by doing /clear @p minecraft:flint_and_steel 3 , this would clear three Flint and Steel. I'm a little late to this, but this is what I've had work for me: In Minecraft 1.8+ we have the /testfor command, you can use this to scan the players Inventory slots (all of them, or specific) for items: example: diamond /testfor @p {Inventory:[{id:"minecraft:diamond"}]} to test for an exact amount of the required item include: ,Count:#b within the confines of the "id" brackets however, this will only search for players with a stack of the exact number you select, anything more or less will not

Cannot Resolve Symbol Google API Client In Android Studio

Answer : For the benefit of searchers: If you are following the android tutorial that relates to this, you can add the dependency via the UI. In Android Studio, go to File > Project Structure. Go to the dependencies tab. On the right hand side add a 'Library Dependency'. Type "com.google.android.gms:play-services" into the searchbox and pick the appropriate dependency. Then follow @Dmac's answer Even though not officially listed in the tutorial, you must use the following imports: import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks; import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener; import com.google.android.gms.location.LocationListener; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; I had to do the following

Can't Start Hostednetwork

Answer : This happen after you disable via Control Panel -> network adapters -> right click button on the virtual connection -> disable To fix that go to Device Manager ( Windows-key + x + m on windows 8, Windows-key + x then m on windows 10), then open the network adapters tree , right click button on Microsoft Hosted Network Virtual Adapter and click on enable. Try now with the command netsh wlan start hostednetwork with admin privileges. It should work. Note: If you don't see the network adapter with name 'Microsoft Hosted Network Virtual Adapter' try on menu -> view -> show hidden devices in the Device Manager window. Let alone enabling the network adapter under Device Manager may not help. The following helped me resolved the issue. I tried Disabling and Enabling the Wifi Adapter (i.e. the actual Wifi device adapter not the virtual adapters) in Control Panel -> Network and Internet -> Network Connections altogether worked

Alternatives To JSP For Spring MVC View Layer

Answer : I recently discovered Thymeleaf. It looks to be a complete replacement for JSPs and has integration with Spring MVC. The template approach looks more like HTML and may be more palatable to your UI designers. They have a small write-up that compares the two solutions side-by-side. In the standard Java EE API, the only alternative to JSP is Facelets. As far now (2010) JSF is the only MVC framework which natively supports Facelets. Spring MVC supports out of the box only JSP, but it has a configurable view resolver which allows you to use Facelets anyway. Other candiates are 3rd party templating frameworks such as Velocity, Freemarker, and Thymeleaf which can be configured as a view technology for Spring MVC. Spring documentation has integration examples with Velocity and Freemarker. I recently started going with plain HTML and jQuery for presentation with Spring MVC only creating a JSON view. So far it's going quite well and even though I have to do the javascri

Android Notifications Triggered By Alarm Manager Not Firing When App Is In Doze Mode

Answer : Adding an intent Flag FLAG_RECEIVER_FOREGROUND https://developer.android.com/reference/android/content/Intent#FLAG_RECEIVER_FOREGROUND prior to calling the broadcast receiver should do the trick Intent intent = new Intent(context, ScheduleAllReceiver.class); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); PendingIntent scheduleAllPendingIntent = PendingIntent.getBroadcast(context, SCHEDULER_DAILY_ALL, intent, PendingIntent.FLAG_UPDATE_CURRENT); I have faced the similar problems. I tried with work manager but the result was same. When phone is locked and is in doze mode the event are not triggered. But for triggering event at exact time you need to use alarm manager only. It should work even in doze mode. Method to register alarm manger (use set exact time instead of repeating) public static void registerAlarm(Context context){ final int FIVE_MINUTES_IN_MILLI = 300000; final int THIRTY_SECOND_IN_MILLI = 30000; long launchTime = System.currentTimeMill

Backslash In Latex Code Example

Example 1: how to make a backslash in latex \symbol{92} Example 2: latex backslash $\setminus$ \setminus % in math env

API For Trust.salesforce.com

Answer : I've set up IFTTT to monitor the trust RSS feed and text me when there are issues. Sometimes I get alerts after the degradation is over because IFTTT runs in batches every 15 or 30 minutes. It still works pretty well to let me know when there is an issue. It makes me look smart when someone asks "is there a problem with Salesforce?" Try this modifying this recipe: https://ifttt.com/recipes/169172-performance-degradation-on-salesforce-na13 There is a public facing API: https://api.status.salesforce.com/v1/docs/ You can make a request such as the following to obtain parseable json with status information, degradation, outage, etc, info: $ curl https://api.status.salesforce.com/v1/instances/NA48/status You can also install SalesforceA for either Android or iOS to get access to the latest status, view user information, unlock, freeze/unfreeze, activate/deactivate, reset passwords, etc, from your mobile phone. Salesforce just released a native port of th

Background Image Css W3school Code Example

Example 1: css background image background-image : url ( "image.png" ) ; background-position : center ; background-repeat : no-repeat ; background-size : cover ; Example 2: adding background image body { background-image : url ( "paper.gif" ) ; }

Any Idea On H2 (Oracle MODE) "Syntax Error : SELECT NEXTVAL FROM[*] DUAL"?

Answer : Please ensure the sequence is created. If it is created, then it works for me: create sequence SQ_PERSON_ID; select SQ_PERSON_ID.nextval from dual; If it is not created, then the same error message is thrown as you got. I was working on h2 with Oracle mode but all the above solutions mentioned above didn't work for me. Although after some research I found that this query will work fine for fetching the next value in the sequence. select nextval('SchemaName', 'SequenceName') ; Check if you use the same schema under which the sequence is created. If not, insert a schema prefix before sequence name, such is MYUSER.MY_SEQ.

Benefits Of Exception Handling In Java Code Example

Example: advantages of Exception handling in java 1 ) Separating normal code from exception handling code to avoid abnormal termination of program . 2 ) Categorizing in to different types of Exceptions so that rather than handling all exceptions with Exception root class we can handle with specific exceptions . It is recommended to handle exceptions with specific Exception instead of handling with Exception root class . 3 ) Call stack mechanism : If a method throws an exception and it is not handled immediately , then that exception is propagated or thrown to the caller of that method . This propogation continues till it finds an appropriate exception handler , if it finds handler it would be handled otherwise program terminates abruptly .

35 Minute Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds

3 Columns Html Code Example

Example 1: html list over three columns ul { -webkit-column-count: 3; -moz-column-count: 3; column-count: 3; } Example 2: how to make three column in a row in html <! DOCTYPE html > < html > < head > < meta name = " viewport " content = " width=device-width, initial-scale=1 " > < style > * { box-sizing : border-box ; } /* Create three equal columns that floats next to each other */ .column { float : left ; width : 33.33 % ; padding : 10 px ; height : 300 px ; /* Should be removed. Only for demonstration */ } /* Clear floats after the columns */ .row :after { content : "" ; display : table ; clear : both ; } </ style > </ head > < body > < h2 > Three Equal Columns </ h2 > < div class = " row " > < div class = " column " style = " background-color : #aaa ; " > < h2 &g

Binary Cross Entropy Loss Tensorflow Code Example

Example: tensorflow binary cross entropy loss tf.keras.losses.BinaryCrossentropy(from_logits=False, label_smoothing=0, reduction=losses_utils.ReductionV2.AUTO, name='binary_crossentropy' )

Browse Image In Html Code Example

Example 1: html upload image < input type = " file " accept = " image/* " /> Example 2: accept vedio pdf files upload html < input type = " file " accept = " video/* " />