Posts

Showing posts from August, 2005

Angularjs Broadcast Once, Broadcastonce,on Twice

Answer : Since you register your o n l i s t e n e r o n on listener on o n l i s t e n ero n rootScope, it doesn't get destroyed with the controller and next time you init the controller it gets created again. You should create your listener on controller scope $scope.$on('menuActivateActionPublish', function(event) {}); Be careful you avoid two instances of the controller means two event listeners, which means the method gets executed twice !! ( example: using twice 'ng-controller' ) To complement que1326 answer, as an example, if you are using ui-router and have something like .state('app.yourpage', { url:'yourPage', views: { 'content@': { templateUrl : 'views/yourPage.html', controller : 'YourController' } } }) and in yourPage.html you have a ng-controller="YourController as Ctrl" , th

Can I Remove Files In /var/log/journal And /var/cache/abrt-di/usr?

Answer : journal logs Yes you can delete everything inside of /var/log/journal/* but do not delete the directory itself. You can also query journalctl to find out how much disk space it's consuming: $ journalctl --disk-usage Journals take up 3.8G on disk. You can control the size of this directory using this parameter in your /etc/systemd/journald.conf : SystemMaxUse=50M You can force a log rotation: $ sudo systemctl kill --kill-who=main --signal=SIGUSR2 systemd-journald.service NOTE: You might need to restart the logging service to force a log rotation, if the above signaling method does not do it. You can restart the service like so: $ sudo systemctl restart systemd-journald.service abrt logs These files too under /var/cache/abrt-di/* can be deleted as well. The size of the log files here is controlled under: $ grep -i size /etc/abrt/abrt.conf # Max size for crash storage [MiB] or 0 for unlimited MaxCrashReportsSize = 1000 You can control the max s

Beautiful Soup Find Element By Class Name Code Example

Example 1: beautifulsoup find by class soup.find_all("a", class_="sister") Example 2: beautifulsoup find class mydivs = soup.findAll("div", {"class": "stylelistrow"})

Beamer: Removing Headline And Its Space On A Single Frame (for Plan), But Keeping The Footline

Answer : Ok, after more investigation (in the beamer sources :)), I have found the solution. For those who will search like me in the future, here it is in a simple small example : { % to delimit a block (we only want to remove the header for this frame) \makeatletter % to change template \setbeamertemplate{headline}[default] % not mandatory, but I though it was better to set it blank \def\beamer@entrycode{\vspace*{-\headheight}} % here is the part we are interested in :) \makeatother \begin{frame}{Table of contents} % and our simple frame \tableofcontents \end{frame} } It is also possible to define an environment to be able to use it more easily. To do so, use this part of code before the \begin{document} : \makeatletter \newenvironment{withoutheadline}{ \setbeamertemplate{headline}[default] \def\beamer@entrycode{\vspace*{-\headheight}} }{} \makeatother And for your frame : \begin{withoutheadline} \begin{frame}{Table of contents} %

Azure Functions - Can't Be Invoked From Azure WebJobs SDK

Answer : for some reason, had to go with .NET Standard 2.0 instead of .NET 461, which I was previously using, along the tutorial suggestion. It seems that when you create azure function initial, your function is .NET 461 and for some reason, you change it to .NET Standard 2.0. However, when your function is .NET Standard 2.0, your runtime version should be set to beta . So add AzureFunctionsVersion in your .csproj, because the default .NET 461 runtime is 1 and when you change to .NET core, you need to change the runtime to " beta " manually. You could refer to the following code: <PropertyGroup> <TargetFramework>netstandard2.0</TargetFramework> <AzureFunctionsVersion>v2</AzureFunctionsVersion> </PropertyGroup>

Change MAC Address Of Intel(R) Dual Band Wireless-AC 7260

Answer : Although Intel doesn't support it anymore, it still does work for me with the AC 7260 and driver version 17.15.0.5. Only thing that took me some tries and searching was the fact that Microsoft restricts spoofing for wireless cards in Windows, so that you have to use 2,6,A or E for the second character. So your MAC has to follow one of these patterns: X2-XX-XX-XX-XX-XX X6-XX-XX-XX-XX-XX XA-XX-XX-XX-XX-XX XE-XX-XX-XX-XX-XX If you add the following to your registry you should even be able to edit it again in the advanced configuration options. BUT BEWARE to find the correct ID number for your wireless adapter. So please change the key name "0002" in the following code to the correct number for your card. To find that go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318} in the registry and look through the keys named "0000", "0001" etc. and look for their "DriverDesc" val

20cm In Inches Uk Code Example

Example: cm to inches const cm = 1; console.log(`cm:${cm} = in:${cmToIn(cm)}`); function cmToIn(cm){ var in = cm/2.54; return in; }

Angular-Material Sidenav CdkScrollable

Answer : Add to your app module imports: ScrollDispatchModule . Add cdkScrollable to your mat-sidenav-content : <mat-sidenav-content cdkScrollable> </mat-sidenav-content> In your root component: a) inject ScrollDispatcher from @angular/cdk/overlay and subscribe to scrolling: constructor(public scroll: ScrollDispatcher) { this.scrollingSubscription = this.scroll .scrolled() .subscribe((data: CdkScrollable) => { this.onWindowScroll(data); }); } c) do something when scrolling, e.g. check the offset private onWindowScroll(data: CdkScrollable) { const scrollTop = data.getElementRef().nativeElement.scrollTop || 0; if (this.lastOffset > scrollTop) { // console.log('Show toolbar'); } else if (scrollTop < 10) { // console.log('Show toolbar'); } else if (scrollTop > 100) { // console.log('Hide toolbar'); } this.lastOffset = scrollTop; } D

85 Cm To Inches Code Example

Example: cm to inch 1 cm = 0.3937 inch

Use The C Max Function Code Example

Example: How to define Max in define in c // For defining x > y # define MAX ( X , Y ) ( ( ( X ) > ( Y ) ) ? ( X ) : ( Y ) ) // For defining x < y # define MIN ( X , Y ) ( ( ( X ) < ( Y ) ) ? ( X ) : ( Y ) )

Dependency Injection In Angular Example

Dependencies are services or objects that a class needs to perform its function. Dependency injection, or DI, is a design pattern in which a class requests dependencies from external sources rather than creating them. Angular's DI framework provides dependencies to a class upon instantiation. You can use Angular DI to increase flexibility and modularity in your applications. See the live example for a working example containing the code snippets in this guide. Creating an injectable service To generate a new HeroService class in the src/app/heroes folder use the following Angular CLI command. ng generate service heroes/hero This command creates the following default HeroService . import { Injectable } from '@angular/core' ; @ Injectable ( { providedIn : 'root' , } ) export class HeroService { constructor ( ) { } } The @ Injectable() decorator specifies that Angular can use this class in the DI system. The metadata, providedIn:

Pyplot.legend Code Example

Example 1: matplotlib legend import numpy as np import matplotlib . pyplot as plt x = np . linspace ( 0 , 20 , 1000 ) y1 = np . sin ( x ) y2 = np . cos ( x ) plt . plot ( x , y1 , "-b" , label = "sine" ) plt . plot ( x , y2 , "-r" , label = "cosine" ) plt . legend ( loc = "upper left" ) plt . ylim ( - 1.5 , 2.0 ) plt . show ( ) Example 2: plt.legend( plt . legend ( [ 'first' , 'second' ] ) ; Example 3: python how to add a figure legend at the best position # Short answer : # matplotlib . pyplot places the legend in the "best" location by default # To add a legend to your plot , call plt . legend ( ) # Example usage : import matplotlib . pyplot as plt x1 = [ 1 , 2 , 3 ] # Invent x and y data to be plotted y1 = [ 4 , 5 , 6 ] x2 = [ 1 , 3 , 5 ] y2 = [ 6 , 5 , 4 ] plt . plot ( x1 , y1 , label = "Dataset_1" ) # Use label = "data_name"

AngularJS Ng-class If-else Expression

Answer : Use nested inline if-then statements ( Ternary Operators ) <div ng-class=" ... ? 'class-1' : ( ... ? 'class-2' : 'class-3')"> for example : <div ng-class="apt.name.length >= 15 ? 'col-md-12' : (apt.name.length >= 10 ? 'col-md-6' : 'col-md-4')"> ... </div> And make sure it's readable by your colleagues :) you could try by using a function like that : <div ng-class='whatClassIsIt(call.State)'> Then put your logic in the function itself : $scope.whatClassIsIt= function(someValue){ if(someValue=="first") return "ClassA" else if(someValue=="second") return "ClassB"; else return "ClassC"; } I made a fiddle with an example : http://jsfiddle.net/DotDotDot/nMk6M/ I had a situation where I needed two 'if' statements that could both go true and an &

The Return 0 Statement In Main Function Indicate Code Example

Example: return 0; c++ // This example gives a reason why you should use using namespace std # include <iostream> using namespace std ; cout << "Hello " << endl ; /* this one is shorter*/ // without the using namespace std you will need to use this std :: cout << "Hello" << std :: cout << endl /* this one is longer and it requires shorter amount of time */