Posts

Showing posts from March, 2018

Microsoft Azure Storage Emulator Download Code Example

Example: azure storage emulator config Account name : devstoreaccount1 Account key : Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq / K1SZFPTOtr / KBHBeksoGMGw ==

Abstract Keyword In Java Code Example

Example 1: abstract class in java Sometimes we may come across a situation where we cannot provide implementation to all the methods in a class . We want to leave the implementation to a class that extends it . In such case we declare a class as abstract . To make a class abstract we use key word abstract . Any class that contains one or more abstract methods is declared as abstract . If we don’t declare class as abstract which contains abstract methods we get compile time error . 1 ) Abstract classes cannot be instantiated 2 ) An abstarct classes contains abstract method , concrete methods or both . 3 ) Any class which extends abstarct class must override all methods of abstract class 4 ) An abstarct class can contain either 0 or more abstract method . Example 2: What are abstract methods in java An abstract method is the method which does’nt have any body . Abstract method is declared with keyword abstract a

Autoindent On Sublime Text

Answer : That's quite simple in Sublime. Just Ctrl+Shift+P (or Command+Shift+P on MacOS) to open the tools pallet, type reindent , and pick Indentation: Reindent Lines . It should reindent all the file you are in, just remember to save before running the command, or it may not appear. Auto-indenting on Sublime Text 3 - "Key Bindings" Just add this binding to your "Key Bindings - User" file: Preferences > Key Bindings - users {"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}} And adding this code between the square brackets. Now you can use Alt + Shift + f as your auto-indent shortcut You can also use the "reindent" feature through the command palette. Ctrl + Shift + P Ressources: Auto-indenting on Sublime Text 3 by Osvaldo Zonetti Create a Keybinding by Joe Lloyd You can use one of many plugins which do the thing you need, for ex

Angular's Ng-init Alternative In Angular 2

Answer : You can use a directive @Directive({ selector: 'ngInit', exportAs: 'ngInit' }) export class NgInit { @Input() values: any = {}; @Input() ngInit; ngOnInit() { if(this.ngInit) { this.ngInit(); } } } you can use it to pass a function to be called like <div [ngInit]="doSomething" or to make values available <div ngInit [values]="{a: 'a', b: 'b'}" #ngInit="ngInit"> <button (click)="clickHandler(ngInit.values.a)">click me</button> </div> ngInit addes the directive [values]="{a: 'a', b: 'b'}" sets some initial values #ngInit="ngInit" creates a reference for later use ngInit.values.a reads the a value from the created reference. See also Converting Angular 1 to Angular 2 ngInit function Another approach is by using the @Output decorator and EventEmitter: import {Directive, OnInit, Output, EventEmitter

Angular 2+ Attr.disabled Is Not Working For Div When I Try To Iterate NgFor Loop

Answer : Use [disabled] instead of [attr.disabled] This is because [attr.disabled]="false" will add disabled="false" to the element which in html, will still disable the element Syntax that will not disable an element <button>Not Disabled</button> <button [disabled]="false">Not Disabled</button> Syntax that will disable an element <button disabled></button> <button disabled="true"></button> <button disabled="false"></button> <button [attr.disabled]="true"></button> <button [attr.disabled]="false"></button> <button [disabled]="true"></button> disabled will disable an element whether it is true or false, it's presence means that the element will be disabled. Angular will not add the disabled element at all for [disabled]="variable" if variable is false. As you mentioned in your

Android MVP: What Is An Interactor?

Answer : MVP exists to tackle God Activity problem (An Activity/Fragment that has way too many lines). While it wasn't obligatory (you can code in any pattern that you want), many developers agree that MVP is suitable for Android. It makes your source code cleaner, testable, maintainable and robust. You can think of an interactor as your "Model/Controller". An interactor will fetch data from your database, web services, or any other data source. After getting the data, the interactor will send the data to the presenter. Thus, making changes in your UI. Advantages of using interactor in a separate class is that it will decouple your class, thus making it cleaner and testable. Sure, you can put the interactor in your presenter inner class, but what's the point? The disadvantages of putting the interactor in your presenter is it will make your presenter class bigger and relatively harder to read and manage. Update: Of course this is just an over-simplification

Android Studio Java.lang.NoClassDefFoundError: Android.support.v4.app.NavUtilsJB

Answer : I had this problem and just found the solution - answer is RTFM! Here are the instructions: https://developer.android.com/tools/building/multidex.html Multidexing is a new feature and so requires a support library to be compatible with pre-lollipop devices. You need to add the following to your gradle file dependencies: compile 'com.android.support:multidex:1.0.0' Also enable multidex output in your gradle file: android { compileSdkVersion 21 buildToolsVersion "21.1.0" defaultConfig { ... minSdkVersion 14 targetSdkVersion 21 ... // Enabling multidex support. multiDexEnabled true } } And then add the multidex support application to your manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.multidex.myapplication"> <application

Can I Produce A Row In Excel Which Is Random Permutation Of Another Row?

Image
Answer : Place the values in A1 through G1 In A2 through G2 enter: =RAND() In A3 through G3 enter: =INDEX($A$1:$G$1,MATCH(LARGE($A$2:$G$2,COLUMN()),$A$2:$G$2,0)) Each time the worksheet is re-calculated, a new permutation will be generated. I use a method similar to what Gary's Student posted, but I use RANK in my formula instead. I think this simplifies the formula and makes it a little easier to understand. For sample data in A1:G1 : dog mouse rhino ape cat fish rat Fill the formula =RAND() across A2:G2 . Then fill the formula below across A3:G3 . =INDEX($A$1:$G$1,RANK(A2,$A2:$G2)) This is good for a one-off or a small number of rows. For a more robust solution, I would use VBA. The macro below will allow you to select the values you want to shuffle and specify the number of permutations you'd like to create. The permutations will be printed to a new sheet, where you can copy and paste them wherever you like. Sub nP

Android Material Design Button Styles

Image
Answer : I will add my answer since I don't use any of the other answers provided. With the Support Library v7, all the styles are actually already defined and ready to use, for the standard buttons, all of these styles are available: style="@style/Widget.AppCompat.Button" style="@style/Widget.AppCompat.Button.Colored" style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless.Colored" Widget.AppCompat.Button : Widget.AppCompat.Button.Colored : Widget.AppCompat.Button.Borderless Widget.AppCompat.Button.Borderless.Colored : To answer the question, the style to use is therefore <Button style="@style/Widget.AppCompat.Button.Colored" ....... ....... ....... android:text="Button"/> How to change the color For the whole app: The color of all the UI controls (not only buttons, but also floating action buttons, checkboxes etc.) is managed by the attribute

Char To Ascii Javascript Code Example

Example 1: javascript convert between string and ascii let ascii = 'a' . charCodeAt ( 0 ) ; // 97 let char = String . fromCharCode ( ascii ) ; // 'a' Example 2: character to ascii in js 'a' . charCodeAt ( 0 ) //returns 97, where '0' is the index of the string 'a' Example 3: Javascript convert character to ascii var myVar = 'A' ; var myVarAscii = myVar . charCodeAt ( 0 ) ; //convert 'A' character to it's ASCII code (65) Example 4: character to ascii javascript String . fromCharCode ( 65 , 66 , 67 ) ; // returns 'ABC' Example 5: character to ascii javascript { "31" : "" , "32" : " " , "33" : "!" , "34" : "\"" , "35" : "#" , "36" : "$" , "37" : "%" , "38" : "&" , "39" : &q

Android: Combining Text & Image On A Button Or ImageButton

Answer : For users who just want to put Background, Icon-Image and Text in one Button from different files: Set on a Button background, drawableTop/Bottom/Rigth/Left and padding attributes. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/home_btn_test" android:drawableTop="@drawable/home_icon_test" android:textColor="#FFFFFF" android:id="@+id/ButtonTest" android:paddingTop="32sp" android:drawablePadding="-15sp" android:text="this is text"></Button> For more sophisticated arrangement you also can use RelativeLayout (or any other layout) and make it clickable. Tutorial: Great tutorial that covers both cases: http://izvornikod.com/Blog/tabid/82/EntryId/8/Creating-Android-button-with-image-and-text-using-relative-layout.aspx There's a mu

Adminlte 3 Fro Github Code Example

Example: adminlte npm install admin-lte@^3.0 --save

"Build Failed" On Database First Scaffold-DbContext

Answer : Two most important tips: [1] - Make sure that your project builds completely before you run a new scaffold command. Otherwise... You'll start writing a line of code. You'll realize a required DB column is missing from your model. You'll go to try to scaffold it. Twenty minutes later you'll realize the reason your build (and scaffold command) is failing is because you literally have a half written line of code. Oops! [2] - Check into source control or make a copy: Allows you to easily verify what changed. Allows rollback if needed. You can get some very annoying 'chicken and egg' problems if you get unlucky or make a mistake. Other problems: If you have multiple DLLs make sure you aren't generating into the wrong project . A 'Build failed' message can occur for many reasons, but the dumbest would be if you don't have EFCore installed in the project you're scaffolding into. In the package manager console there is

Accessing $vuetify Instance Property From Vuex Store

Answer : For Vuetify 2.0 you can try following method. (After following Vuetify 2.0 Upgrade guide for themes) import Vuetify from './plugins/vuetify' export default { getters: {}, mutations: { toggleDarkTheme(state) { Vuetify.framework.theme.themes.light.primary = "#424242"; } } $vuetify is an instance property hence you can access any vue instance property using Vue.prototype.$prop For your case import Vue from 'vue'; export default { getters: {}, mutations: { toggleDarkTheme(state) { Vue.prototype.$vuetify.theme.primary = "#424242"; } } }; For Nuxt.js projects with Vuetify set as a buildModule , you can access $vuetify from the $nuxt property in the Vue instance: import Vue from 'vue'; export actions = { yourAction() { Vue.prototype.$nuxt.$vuetify.theme.dark = true; } }

Amazon AWS Filezilla Transfer Permission Denied

Answer : To allow user ec2-user (Amazon AWS) write access to the public web directory (/var/www/html), enter this command via Putty or Terminal, as the root user sudo : chown -R ec2-user /var/www/html Make sure permissions on that entire folder were correct: chmod -R 755 /var/www/html Doc's: Setting up amazon ec2-instances Connect to Amazon EC2 file directory using Filezilla and SFTP (Video) Understanding and Using File Permissions if you are using centOs then use sudo chown -R centos:centos /var/www/html sudo chmod -R 755 /var/www/html For Ubuntu sudo chown -R ubuntu:ubuntu /var/www/html sudo chmod -R 755 /var/www/html For Amazon ami sudo chown -R ec2-user:ec2-user /var/www/html sudo chmod -R 755 /var/www/html In my case the /var/www/html in not a directory but a symbolic link to the /var/app/current, so you should change the real directoy ie /var/app/current: sudo chown -R ec2-user /var/app/current sudo chmod -R 755 /var/app/current I hope th

Bootstrap Cdn W3school Code Example

Example 1: bootstrap cdn link <!-- Latest compiled and minified CSS --> < link rel = " stylesheet " href = " https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css " integrity = " sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u " crossorigin = " anonymous " > <!-- Optional theme --> < link rel = " stylesheet " href = " https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css " integrity = " sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp " crossorigin = " anonymous " > <!-- Latest compiled and minified JavaScript --> < script src = " https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js " integrity = " sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa " crossorigin = " anonymous " > </ script > Exa