Posts

Showing posts from April, 2019

Are Arrays Passed By Value Or Passed By Reference In Java?

Answer : Everything in Java is passed by value. In case of an array (which is nothing but an Object), the array reference is passed by value (just like an object reference is passed by value). When you pass an array to other method, actually the reference to that array is copied. Any changes in the content of array through that reference will affect the original array. But changing the reference to point to a new array will not change the existing reference in original method. See this post: Is Java "pass-by-reference" or "pass-by-value"? See this working example: public static void changeContent(int[] arr) { // If we change the content of arr. arr[0] = 10; // Will change the content of array in main() } public static void changeRef(int[] arr) { // If we change the reference arr = new int[2]; // Will not change the array in main() arr[0] = 15; } public static void main(String[] args) { int [] arr = new int[2]; arr[0] = 4;

Brew Update Not Working After Mac 10.9

Answer : This fixed it for me cd `brew --prefix`/Homebrew git fetch origin git reset --hard origin/master brew update worked fine after that Solution You might still find.. brew update not working after git pull origin master Here what you need to do. cd /usr/local git pull origin master brew install git Now you might already have git on your System, but what this will do it that now. Your broken brew update will automatically be updated before at first run.. Here is the link to the origin issue in HomeBrew. brew stuck I simply removed the .git directory inside of the /usr/local directory, then ran the command brew update .

Bootstrap Carousel Full Screen

Answer : Update Bootstrap 4 Bootstrap 4 has utility classes that make it easier to create a full screen carousel. For example, use the min-vh-100 class on the carousel-item content... <div class="carousel slide" data-ride="carousel"> <div class="carousel-inner bg-info" role="listbox"> <div class="carousel-item active"> <div class="d-flex align-items-center justify-content-center min-vh-100"> <h1 class="display-1">ONE</h1> </div> </div> </div> </div> Full screen carousel demo This works to make the carousel items full screen , but carousel items that contain images or videos that have a specific size & aspect ratio require further consideration. Since the viewport h/w ratio is likely to be different than the image or video h/w ratio, usually background

Ascii Value Of A To Z In Python Code Example

Example 1: how to write the character from its ascii value in python c = 'p' x = ord ( c ) #it will give you the ASCII value stored in x chr ( x ) #it will return back the character Example 2: ascii values in python of c = 'p' print ( "The ASCII value of '" + c + "' is" , ord ( c ) )

Apache_Http_Server MPM: GracefulShutdownTimeout Example

Description: A collection of directives that are implemented by more than one multi-processing module (MPM) Status: MPM CoreDumpDirectory Directive Description: Directory where Apache HTTP Server attempts to switch before dumping core Syntax: CoreDumpDirectory directory Default: See usage for the default setting Context: server config Status: MPM Module: event , worker , prefork This controls the directory to which Apache httpd attempts to switch before dumping core. If your operating system is configured to create core files in the working directory of the crashing process, CoreDumpDirectory is necessary to change working directory from the default ServerRoot directory, which should not be writable by the user the server runs as. If you want a core dump for debugging, you can use this directive to place it in a different location. This directive has no effect if your operating system is not configured to write core files to the working di

Brython Tutorial Code Example

Example 1: python tutorial print ( "Hello, Python!" ) ; Example 2: python tutorial This is a very good free python tutorial : https : / / www . youtube . com / watch ? v = _uQrJ0TkZlc Example 3: python tutorial # printing hello world in python print ( "Hello World" ) # adding 2 numbers num1 = 10 num2 = 20 print ( num1 + num2 )

Change Month Name To French

Answer : Use strftime : http://php.net/manual/en/function.strftime.php <?php setlocale(LC_TIME, "fr_FR"); echo strftime(" in French %d.%M.%Y and"); (not sure about that %d.%M.%Y but you can read documentation) From http://php.net/manual/en/function.date.php: To format dates in other languages, you should use the setlocale() and strftime() functions instead of date(). I know this is old but for anyone still looking this up, a more complete answer for your date in French would be: //set locale setlocale(LC_TIME, "fr_FR"); Then //echo date/formatting based on your locale, in this case, for French echo strftime("le %d %B, %Y", strtotime( $sgps_newsletter->getCreatedAt() )); //without day of the week = le 18 septembre, 2013 OR echo strftime("%A le %d %B, %Y", strtotime( $sgps_newsletter->getCreatedAt() )); //with day of the week = mercredi le 18 septembre, 2013 OR echo strftime("%d/%m/%Y",

Can't Perform A React State Update On An Unmounted Component

Answer : Here is a React Hooks specific solution for Error Warning: Can't perform a React state update on an unmounted component. Solution You can declare let isMounted = true inside useEffect , which will be changed in the cleanup callback, as soon as the component is unmounted. Before state updates, you now check this variable conditionally: useEffect(() => { let isMounted = true; // note this flag denote mount status someAsyncOperation().then(data => { if (isMounted) setState(data); }) return () => { isMounted = false }; // use effect cleanup to set flag false, if unmounted }); const Parent = () => { const [mounted, setMounted] = useState(true); return ( <div> Parent: <button onClick={() => setMounted(!mounted)}> {mounted ? "Unmount" : "Mount"} Child </button> {mounted && <Child />} <p> Unmount Child, while it is still

Access Denied When Editing MSMQ Messsage Queuing Properties

Answer : Putting this here for posterity ;) Background: For as long as I’ve been using Windows 2008 R2, I have not been able to change the Message Queuing configuration settings (such as storage limits, storage locations, security, etc.) or access the System Queues (Journal messages, Dead-letter messages, Transactional dead-letter messages); all attempts at doing any of these things resulted in a cryptic “Access is denied” error. Whenever I needed to install Message Queuing on a server in our environment, I used Server Manager to install the Message Queuing Feature. Solution(?): On a whim, rather than install the Message Queuing Feature, I instead choose to add the “Application Server” Role. Adding this role automatically selected and installed the Message Queuing Feature, though it only enabled the Message Queuing Server, not Directory Service Integration and Message Queuing Triggers. I am now able to re-configure Message Queuing settings, as well as access and perform acti

Angular2 NgFor OnPush Change Detection With Array Mutations

Answer : Angular2 change detection doesn't check the contents of arrays or object. A hacky workaround is to just create a copy of the array after mutation this.myArray.push(newItem); this.myArray = this.myArray.slice(); This way this.myArray refers a different array instance and Angular will recognize the change. Another approach is to use an IterableDiffer (for arrays) or KeyValueDiffer (for objects) // inject a differ implementation constructor(differs: KeyValueDiffers) { // store the initial value to compare with this.differ = differs.find({}).create(null); } @Input() data: any; ngDoCheck() { var changes = this.differ.diff(this.data); // check for changes if (changes && this.initialized) { // do something if changes were found } } See also https://github.com/angular/angular/blob/14ee75924b6ae770115f7f260d720efa8bfb576a/modules/%40angular/common/src/directives/ng_class.ts#L122 You might want to use markForCheck method from ChangeDetect

Bitbake Not Installing My File In The Rootfs Image

Answer : Remove all lines that aren't necessy, just to be on the safe side. FILESEXTRAPATHS is not necessary; it's only used when you're writing a .bbappend file to modify a recipe in another layer. ALLOW_EMPT_${PN} is also not needed. It's used to allow PN to be empty, which is only useful if you're creating other packages. In your case, you wnat the firmware files in PN, thus it's better to have bitbake error out while building your package if the files can't be installed. INSANE_SKIP_${PN} += "installed-vs-shipped" is also not needed. It's only required if you install files in your do_install that you're not putting in a package. Normally, you're advised to not install them or delete the files instead. Your do_install() should work fine; though I'd recommend to use install instead of cp and chmod . That way you're also ensured that the owner and group will be correct. (Checks for this are added as a new QA

Class 'app Http Controllers Response' Not Found Laravel 7 Code Example

Example: Class 'App\Http\Controllers\Response' not found use Response; Or use full namespace: return \Response::json(...); Or just use helper: return response()->json(...);

Add Velocity To Rigidbody Unity Code Example

Example 1: unity how to set rigidbody velocity Vector3 velocity = new Vector3 ( 10f /*x*/ , 10f /*y*/ , 10f /*z*/ ) ; GetComponent < Rigidbody > ( ) . velocity = velocity ; Example 2: rigidbody velocity c# unity //for rigidbody2D GetComponent < Rigidbody2D > ( ) . velocity = new Vector2 ( 40 , 0 ) ;

Howw To Print A Double C Code Example

Example: print double in c # include <stdio.h> int main ( ) { double d = 123.32445 ; //using %f format specifier printf ( "Value of d = %f\n" , d ) ; //using %lf format specifier printf ( "Value of d = %lf\n" , d ) ; return 0 ; }

Bootstrap Warning Alerts Code Example

Example 1: bootstrap alert <div class= "alert alert-primary" role= "alert" > This is a primary alert—check it out! </div> <div class= "alert alert-secondary" role= "alert" > This is a secondary alert—check it out! </div> <div class= "alert alert-success" role= "alert" > This is a success alert—check it out! </div> <div class= "alert alert-danger" role= "alert" > This is a danger alert—check it out! </div> <div class= "alert alert-warning" role= "alert" > This is a warning alert—check it out! </div> <div class= "alert alert-info" role= "alert" > This is a info alert—check it out! </div> <div class= "alert alert-light" role= "alert" > This is a light alert—check it out! </div> <div class= "alert alert-dark" role= "alert"

How To Print F Bool In C Code Example

Example: how to print boolean in c printf ( "%s" , x ? "true" : "false" ) ;

AnkhSVN Not Showing In Visual Studio 2017

Answer : I came here looking for an answer to the same question. I am Running Windows 10 Enterprise and had VS2015 with AnkhSVN working before and after installing VS2017, but in VS2017 AnkhSVN was not available under SCC Plug-In Selection (even after uninstall and reinstall of the install executables downloaded from http://ankhsvn.open.collab.net, which offer registration against VS Dev15/2017). This is what eventually worked: Removed AnkhSVN (Windows: Add or Remove Programs) Installed AnkhSVN Nuget package (Visual Studio: Tools/Extensions and Updates) So the trick I believe is to "remove program installed by MSI/EXE followed by install extension via Visual Studio VSIX". I was also subsequently able to upgrade AnkhSVN (2.7.12815 from VSIX install), by running the downloaded EXE installer for the latest daily build (2.7.12821), after which AnkhSVN is available in both VS2015 and 2017, although I had to reselect it in 2015. I had the same issue with VS2017 and

Angular Material Stepper Component Prevent Going To All The Non Visited Steps

Answer : The solution that I found to this problem is to use completed attribute of step. Refer to the line of code given below: <mat-step [completed]="isCompleted"> When isCompleted is true it will enable the next step. Note: For this to work, the stepper component must be in the linear mode. This can be done by setting the attribute linear on the stepper component, like <mat-horizontal-stepper linear> Check this link . You need to use linear stepper. A stepper marked as linear requires the user to complete previous steps before proceeding. For each step, the stepControl attribute can be set to the top level AbstractControl that is used to check the validity of the step. Example shown as below import { Component, Input } from '@angular/core'; import {FormBuilder, FormGroup, Validators} from '@angular/forms'; import {MatIconRegistry} from '@angular/material'; @Component({ selector: 'stepper', te

Change Startup Programs On A Mac Code Example

Example: how to change what startup apps mac Open System Preferences. Go to Users & Groups. Choose your nickname on the left. Choose Login items tab. Check startup programs you want to remove. Press the “–” sign below. You're done.

Prim's Algorithm In Python Code Example

Example 1: prim's algorithm python def empty_graph ( n ) : res = [ ] for i in range ( n ) : res . append ( [ 0 ] * n ) return res def convert ( graph ) : matrix = [ ] for i in range ( len ( graph ) ) : matrix . append ( [ 0 ] * len ( graph ) ) for j in graph [ i ] : matrix [ i ] [ j ] = 1 return matrix def prims_algo ( graph ) : graph1 = convert ( graph ) n = len ( graph1 ) tree = empty_graph ( n ) con = [ 0 ] while len ( con ) < n : found = False for i in con : for j in range ( n ) : if j not in con and graph1 [ i ] [ j ] == 1 : tree [ i ] [ j ] = 1 tree [ j ] [ i ] = 1 con += [ j ] found = True break if found : break return tree matrix = [ [ 0 , 1 , 1 , 1 , 0 , 1