Posts

Showing posts from July, 2019

Automatic Prune With Git Fetch Or Pull

Answer : Since git 1.8.5 (Q4 2013): " git fetch " (hence " git pull " as well) learned to check " fetch.prune " and " remote.*.prune " configuration variables and to behave as if the " --prune " command line option was given. That means that, if you set remote.origin.prune to true: git config remote.origin.prune true Any git fetch or git pull will automatically prune. Note: Git 2.12 (Q1 2017) will fix a bug related to this configuration, which would make git remote rename misbehave. See "How do I rename a git remote?". See more at commit 737c5a9: Without " git fetch --prune ", remote-tracking branches for a branch the other side already has removed will stay forever. Some people want to always run " git fetch --prune ". To accommodate users who want to either prune always or when fetching from a particular remote, add two new configuration variables " fetch.prune

Anaconda Update All Possible Packages?

Answer : TL;DR: dependency conflicts: Updating one requires (by it's requirements) to downgrade another You are right: conda update --all is actually the way to go 1 . Conda always tries to upgrade the packages to the newest version in the series (say Python 2.x or 3.x). Dependency conflicts But it is possible that there are dependency conflicts (which prevent a further upgrade). Conda usually warns very explicitly if they occur. e.g. X requires Y <5.0, so Y will never be >= 5.0 That's why you 'cannot' upgrade them all. Resolving To add: maybe it could work but a newer version of X working with Y > 5.0 is not available in conda. It is possible to install with pip, since more packages are available in pip. But be aware that pip also installs packages if dependency conflicts exist and that it usually breaks your conda environment in the sense that you cannot reliably install with conda anymore. If you do that, do it as a last resort and af

Check If A File Exists Locally Using JavaScript Only

Answer : Your question is ambiguous, so there are multiple possible answers depending on what you're really trying to achieve. If you're developping as I'm guessing a desktop application using Titanium, then you can use the FileSystem module's getFile to get the file object, then check if it exists using the exists method. Here's an example taken from the Appcelerator website: var homeDir = Titanium.Filesystem.getUserDirectory(); var mySampleFile = Titanium.Filesystem.getFile(homeDir, 'sample.txt'); if (mySampleFile.exists()) { alert('A file called sample.txt already exists in your home directory.'); ... } Check the getFile method reference documentation And the exists method reference documentation For those who thought that he was asking about an usual Web development situation, then thse are the two answers I'd have given: 1) you want to check if a server-side file exists. In this case you can use an ajax request try

CardView Not Showing Shadow In Android L

Image
Answer : After going through the docs again, I finally found the solution. Just add card_view:cardUseCompatPadding="true" to your CardView and shadows will appear on Lollipop devices. What happens is, the content area in a CardView take different sizes on pre-lollipop and lollipop devices. So in lollipop devices the shadow is actually covered by the card so its not visible. By adding this attribute the content area remains the same across all devices and the shadow becomes visible. My xml code is like : <android.support.v7.widget.CardView android:id="@+id/media_card_view" android:layout_width="match_parent" android:layout_height="130dp" card_view:cardBackgroundColor="@android:color/white" card_view:cardElevation="2dp" card_view:cardUseCompatPadding="true" > ... </android.support.v7.widget.CardView> Do not forget that to draw shadow you must use hardwareAccelerate

Circular Queue Is Also Known As Code Example

Example: circular queue // Circular Queue implementation in C++ # include <iostream> # define SIZE 5 /* Size of Circular Queue */ using namespace std ; class Queue { private : int items [ SIZE ] , front , rear ; public : Queue ( ) { front = - 1 ; rear = - 1 ; } // Check if the queue is full bool isFull ( ) { if ( front == 0 && rear == SIZE - 1 ) { return true ; } if ( front == rear + 1 ) { return true ; } return false ; } // Check if the queue is empty bool isEmpty ( ) { if ( front == - 1 ) return true ; else return false ; } // Adding an element void enQueue ( int element ) { if ( isFull ( ) ) { cout << "Queue is full" ; } else { if ( front == - 1 ) front = 0 ; rear = ( rear + 1 ) % SIZE ; items [ rear ] = element ; cout << end

Changing Keyboard Layout To Dvorak In Ubuntu-server

Answer : I found this more straightforward and simple: sudo dpkg-reconfigure keyboard-configuration This will guide you through the process of selecting different keyboard layouts: $ dpkg-reconfigure console-data Maybe you will need to install console-data. $ sudo apt-get install console-data If you want to make changes permanent then you can use: $ dpkg-reconfigure console-setup Looks like this will work, too: $ sudo loadkeys dvorak Hat tip to http://ma.tt/2004/01/dvorak-on-linux-console/

Comando Para Parar O Loop Infinito Js Code Example

Example: loop javascript for ( var i = 0 ; i < cats . length ; i ++ ) { if ( i === cats . length - 1 ) { info += 'and ' + cats [ i ] + '.' ; } else { info += cats [ i ] + ', ' ; } }

Angular 5 Material: Dropdown (select) Required Validation Is Not Working

Answer : Based on the excellent answer of (from zero to hero), I want to clarify 2 points mentioned in comments: 1- You have to use ngModel not value 2- You have to give the control a name Full credit goes to him, I wanted to clarify this to any newcomer like me as it took me 2 hours to find out why it doesn't work You added required to the select's option , not the select . Do it like: <mat-form-field> <mat-select placeholder="Favorite food" name="select" [(ngModel)]="select" required> <mat-option *ngFor="let food of foods" [value]="food.value" > {{ food.viewValue }} </mat-option> </mat-select> </mat-form-field> DEMO

Android Get Current Locale, Not Default

Answer : The default Locale is constructed statically at runtime for your application process from the system property settings, so it will represent the Locale selected on that device when the application was launched . Typically, this is fine, but it does mean that if the user changes their Locale in settings after your application process is running, the value of getDefaultLocale() probably will not be immediately updated. If you need to trap events like this for some reason in your application, you might instead try obtaining the Locale available from the resource Configuration object, i.e. Locale current = getResources().getConfiguration().locale; You may find that this value is updated more quickly after a settings change if that is necessary for your application. Android N (Api level 24) update (no warnings): Locale getCurrentLocale(Context context){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){ return context.getResources().ge

40 Inches In Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

26 Out Of 30 Percentage Code Example

Example: what percent is 27 out of 30 oh so you have found me. I am the secret commenter. goodbye now

Laravel Update Controller Code Example

Example 1: laravel create resource controller php artisan make : controller PhotoController -- resource Example 2: how to create controller in laravel Simple controller : php artisan make : controller nameOfController Want to create controller in a folder ? use it like this : php artisan make : controller NameOfFolder / nameOfController Resource Controller : This controller will create all CRUD methods php artisan make : controller nameOfController -- resource Example 3: laravel create resource controller php artisan make : controller PhotoController -- resource -- model = Photo Example 4: resource controller laravel Route :: resource ( 'photos' , PhotoController :: class ) ;

Check For Collision Unity Code Example

Example 1: unity how to tell when a gameobject is colliding void OnCollisionEnter ( Collision collision ) { //Check for a match with the specified name on any GameObject that collides with your GameObject if ( collision . gameObject . name == "MyGameObjectName" ) { //If the GameObject's name matches the one you suggest, output this message in the console Debug . Log ( "Do something here" ) ; } //Check for a match with the specific tag on any GameObject that collides with your GameObject if ( collision . gameObject . tag == "MyGameObjectTag" ) { //If the GameObject has the same tag as specified, output this message in the console Debug . Log ( "Do something else here" ) ; } } Example 2: check for collision unity c# void OnCollisionEnter ( Collision col ) { } Example 3: how to do collision tag in uni

Class Constructor Type In Typescript?

Answer : Solution from typescript interfaces reference: interface ClockConstructor { new (hour: number, minute: number): ClockInterface; } interface ClockInterface { tick(); } function createClock(ctor: ClockConstructor, hour: number, minute: number): ClockInterface { return new ctor(hour, minute); } class DigitalClock implements ClockInterface { constructor(h: number, m: number) { } tick() { console.log("beep beep"); } } class AnalogClock implements ClockInterface { constructor(h: number, m: number) { } tick() { console.log("tick tock"); } } let digital = createClock(DigitalClock, 12, 17); let analog = createClock(AnalogClock, 7, 32); So the previous example becomes: interface AnimalConstructor { new (): Animal; } class Animal { constructor() { console.log("Animal"); } } class Penguin extends Animal { constructor() { super(); console.log("Penguin

How To Fix 0031:err:mscoree:CLRRuntimeInfo_GetRuntimeHost Wine Mono Is Not Installed Code Example

Example: 0009:err:mscoree:CLRRuntimeInfo_GetRuntimeHost Wine Mono is not installed sudo apt - get install mono - complete //if didn't work you can search for how to install .net5 on linux

1 Year In Seconds Code Example

Example: A year is a few seconds 1 year = 365.2425 days = (365.2425 days) × (24 hours/day) × (3600 seconds/hour) = 31556952 seconds One Julian astronomical year, has 365.25 days: 1 year = 365.25 days = (365.25 days) × (24 hours/day) × (3600 seconds/hour) = 31557600 seconds One calendar common year has 365 days: 1 common year = 365 days = (365 days) × (24 hours/day) × (3600 seconds/hour) = 31536000 seconds One calendar leap year has 366 days (occures every 4 years): 1 leap year = 366 days = (366 days) × (24 hours/day) × (3600 seconds/hour) = 31622400 seconds

Bootstrap Modal Backdrop = 'static' Not Working

Answer : I found a workaround for this issue. Once the modal has been hidden bootstrap data still remains on it. To prevent that I had the following: $('#myModal').modal('show'); //display something //... // if you don't want to lose the reference to previous backdrop $('#myModal').modal('hide'); $('#myModal').data('bs.modal',null); // this clears the BS modal data //... // now works as you would expect $('#myModal').modal({backdrop:'static', keyboard:false}); I had the same problem with Bootstrap 4.1.1 and it only worked when I added the data attributes to the html <div class="modal fade show" id="myModal" tabindex="-1" role="dialog" style="display: block;" data-keyboard="false" data-backdrop="static"> ... Similar to Daniele Piccioni but a bit more concise: $('#myModal').modal({backdrop: true, keyboard: false, show: t

Brew Install Ffmpeg Windows Code Example

Example: install ffmpeg mac There are three options, sorted by complexity: Homebrew (or other package managers) Static builds Compile yourself To follow this you need to have a bit of knowledge using a terminal/shell under macOS.

12 Cm X 10 Cm In Inches Code Example

Example: cm to inch 1 cm = 0.3937 inch

Youtube Video Mp3 Download Code Example

Example: youtube download mp3 I use https : //github.com/ytdl-org/youtube-dl/ as a Python CLI tool to download videos