Rectangle 27 11

I don't know if there's an idiomatic way, but if you use manual bootstrap (ie, get rid of ng-app), then to reset you could

  • Remove the element that you bootstrapped angular into
  • Replace it with a clean copy of the element
<div id="myid" ng-controller="MyCtrl">
  <button ng-click="i = i+1">Add 1</button>
  <span>i = {{i}}</span>
  <button ng-click="reset()">RESET</button>
</div>

Example controller/JS (with jQuery included as well), which would be run on onload:

var $cleanCopy = $("#myid").clone();

function bootstrap() {
  angular.bootstrap(document.getElementById('myid'), ['mymodule']);
}

angular.module('mymodule', []).controller('MyCtrl', function($scope) {
  $scope.i = 1; 

  $scope.reset = function() {
    // You need this second clone or angular bootstraps
    // into the original clone!
    $("#myid").replaceWith($cleanCopy.clone());
    bootstrap();
  };
});

bootstrap();

This doesn't work and the fiddle no longer contains the same code.

!!! I'm not sure how that happened. I've updated the link to a working JSFiddle.

I did all 3 points but got an error that element was already bootstrapped.

angularjs - How to restart angular app without page reload? - Stack Ov...

angularjs
Rectangle 27 10

I don't know if there's an idiomatic way, but if you use manual bootstrap (ie, get rid of ng-app), then to reset you could

  • Remove the element that you bootstrapped angular into
  • Replace it with a clean copy of the element
<div id="myid" ng-controller="MyCtrl">
  <button ng-click="i = i+1">Add 1</button>
  <span>i = {{i}}</span>
  <button ng-click="reset()">RESET</button>
</div>

Example controller/JS (with jQuery included as well), which would be run on onload:

var $cleanCopy = $("#myid").clone();

function bootstrap() {
  angular.bootstrap(document.getElementById('myid'), ['mymodule']);
}

angular.module('mymodule', []).controller('MyCtrl', function($scope) {
  $scope.i = 1; 

  $scope.reset = function() {
    // You need this second clone or angular bootstraps
    // into the original clone!
    $("#myid").replaceWith($cleanCopy.clone());
    bootstrap();
  };
});

bootstrap();

This doesn't work and the fiddle no longer contains the same code.

!!! I'm not sure how that happened. I've updated the link to a working JSFiddle.

I did all 3 points but got an error that element was already bootstrapped.

angularjs - How to restart angular app without page reload? - Stack Ov...

angularjs
Rectangle 27 20

One solution is the perpage package, that provides a general mechanism for resetting counters per page. Put the command \usepackage{perpage} and \MakePerPage{footnote}into your document preamble, immediately after the \documentclass line and before the \begin{document} line.

\documentclass{article}
\usepackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
\begin{document}

The interface is pretty simple: \MakePerPage{footnote} will do the job. If you want to restart the counter at something other than 1 (for example to avoid something in the LaTeX footnote symbol list), you can use: \MakePerPage[2]{footnote}. Its a first-rate package, small and efficient.

latex - How to restart \footnote numbering every page - Stack Overflow

latex footnotes
Rectangle 27 1

var initialHref = window.location.href;
navigator.splashscreen.show();
// Reload original app url (ie your index.html file)
window.location = initialHref;
navigator.splashscreen.hide();

angularjs - How to restart Ionic app in IOS - Stack Overflow

angularjs cordova ionic-framework phonegap-plugins
Rectangle 27 5

Reset the footnote counter, or make it reset by page:

latex - How to restart \footnote numbering every page - Stack Overflow

latex footnotes
Rectangle 27 8

if you want to just reload the configuration file, one can do

(jenkins_url)/reload

This is quicker, if you have made some small change in the configuration file like config.xml directly on the file system or make copies of the job through the filesystem ( not through the browser ).

How to restart Jenkins manually? - Stack Overflow

jenkins
Rectangle 27 4

Obviously if you do not restart the server you will not see the results of any changes you have made, however you do not have to do this manually. There are many options that will automatically restart the app when you change the source files, the most popular being:

javascript - Should I restart application server on every change using...

javascript node.js express
Rectangle 27 4

Obviously if you do not restart the server you will not see the results of any changes you have made, however you do not have to do this manually. There are many options that will automatically restart the app when you change the source files, the most popular being:

javascript - Should I restart application server on every change using...

javascript node.js express
Rectangle 27 22

just create a restart.txt in tmp dir of your app

touch %RAILS_ROOT%/tmp/restart.txt

How can I be sure this has its effect (I'm reorganizing my phusion/capistrano set-up)? Or, what is this "restart" needed for anyway?

Ah! I can tell it restarts by watching the Apache error log file (/var/log/apache2/error.log in my case) for something like: [ 2014-01-08 20:37:38.9069 32489/7ff921f67700 Pool2/SmartSpawner.h:301 ]: Preloader for /app01/akiary_registration/app started on PID 13325, listening on unix:/tmp/passenger.1.0.32480/generation-0/backends/preloader.13325

How to restart Phusion Passenger + Apache in Production mode on Ubuntu...

ruby-on-rails ruby-on-rails-3 apache passenger
Rectangle 27 1

If when you attempt to get or post a request to your server and it fails and gives you a connection error you can just navigate back to your first page and clear out all your stored variables. Create a function like

function reset_app(){
    $.mobile.changePage('#first_page');
    global_vars = default_global_vars;
}

javascript - Jquery Mobile, How to restart an App - Stack Overflow

javascript jquery jquery-mobile restart
Rectangle 27 2

For Restart jenkins manually using browser: Enter Your www.jenkins-ip/restart (ex. http://localhost:8080/restart) in browser. Jenkins will restart and load login page automatically after restart

How to restart Jenkins manually? - Stack Overflow

jenkins
Rectangle 27 2

You would have to use the manual bootstrap way (explained in https://docs.angularjs.org/guide/bootstrap) for angular but doing that would cause a memory leak over time as angular add listener on DOM that you destroy and is not aware of it's removal, so they stay, and so does for the controller / directives / binding and other features that are referenced by your code.

Not really sure how that would work. Yes, I can wrap whatever I want in a directive, but what would that do? Or do you mean wrapping the entire content of body-content in a directive?

I don't know much about yii2 framework but I assume it's a javascript librairy that you can specify what to render with some sorts of templates you could register a directive in angular that replace body-content and render the internal with the yii2 frameworks as normal, the you could rerender the angular directive like it's explained in stackoverflow.com/questions/22080351/ and angular would take care of analysing the html attributes and and do it's magic.

@VladTheLad thanks for noticing the Yii2 was a backend rendering framework, this is more conflicting than I expected. Better to choose one or the other otherwise you would walk a very difficult and hacky path to make that work. Maybe Yii2 could render angular templates used in the application

javascript - Restart/reload Angular app - Stack Overflow

javascript jquery html angularjs
Rectangle 27 3

i.e.: PyDev will properly kill subprocesses on a kill process operation and when debugging even with regular reloading on, PyDev will attach the debugger to the child processes.

Unfortunately, that's expected, as PyDev will simply kill the parent process (i.e.: as if instead of ctrl+C you kill the parent process in the task manager).

The solution would be editing Django itself so that the child process polls the parent process to know it's still alive and exit if it's not... see: How to make child process die after parent exits? for a reference.

After a quick look it seems related to django/utils/autoreload.py and the way it starts up things -- so, it'd be needed to start a thread that keeps seeing if the parent is alive and if it's not it kills the child process -- I've reported that as a bug in Django itself: https://code.djangoproject.com/ticket/16982

Note: as a workaround for PyDev, you can make Django allocate a new console (out of PyDev) while still running from PyDev (so, until a proper solution is available from Django, the patch below can be used to make the Django autoreload allocate a new console -- where you can properly use Ctrl+C).

Index: django/utils/autoreload.py
===================================================================
--- django/utils/autoreload.py  (revision 16923)
+++ django/utils/autoreload.py  (working copy)
@@ -98,11 +98,14 @@
 def restart_with_reloader():
     while True:
         args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
-        if sys.platform == "win32":
-            args = ['"%s"' % arg for arg in args]
         new_environ = os.environ.copy()
         new_environ["RUN_MAIN"] = 'true'
-        exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
+
+        import subprocess
+        popen = subprocess.Popen(args, env=new_environ, creationflags=subprocess.CREATE_NEW_CONSOLE)
+        exit_code = popen.wait()
         if exit_code != 3:
             return exit_code

python - PyDev and Django: how to restart dev server? - Stack Overflow

python django eclipse pydev devserver
Rectangle 27 3

A different approach may be to formalise your test driven development, and instead of using the interpreter to test your module, save your tests and run them directly.

You probably know of the various ways to do this with python, I imagine the simplest way to start in this direction is to copy and paste what you do in the interpreter into the docstring as a doctest and add the following to the bottom of your module:

if __name__ == "__main__":
    import doctest
    doctest.testmod()

Your informal test will then be repeated every time the module is called directly. This has a number of other benefits. See the doctest docs for more info on writing doctests.

The advice to drive the development using automated tests (with the py.test or unittest modules, for example) deserves a +10, but I can give it only one. :(

That's also a good idea. However, the API is rapidly changing at the moment at these early stages. This is something that I would generally include later in the packages development.

How to develop a Python module/package without having to restart the i...

python module packages
Rectangle 27 1

It's difficult to give an answer without nowing "what your batch do", the size and structure of your CSV, ....

But an idea is to get the row number like this :

@echo off
for /F "tokens=5 delims= " %%a in ('type YourLog.txt ^| find "error"') do set $row=%%a
echo %$row%

And then set the tokens with the recuparating value with the ; or , as delims who is the standard for a CSV file.

for /f "tokens=%$row.=%,* delims=;" %%a in (file.csv) do (set $start=%%a
                                                           set $rest=%%b)
echo Error Row=%$start%
echo Rest of the line : %$rest%

That's an idea IF THE ROWS ARE ON THE SAME LINE... With the restriction of the size of an environnment Variable in batch (for the *).

OK If the value of the error message is corresponding to the line number of the error in your .CSV. You can just read thee .CSV skipping the N line of the error message +1 et genertae un new .CSV file.

@echo off
for /F "tokens=10 delims= " %%a in ('type YourLog.txt ^| find /i "error"') do set $row=%%a
set /a $row="%$row:.=%"+1
for /f "skip=%$row% delims=" %%a in (file.csv) do echo %%a>>newfile.csv

And then work with the newfile.csv .

my cvs line number will not the the same as the line number the error message occurs on in my log. however the csv line number is given in the error log message eg : ".... Error found in row 3611. Exception ..." 3611 is the line in the csv file that hit the problem.

to clarify : The line number of the error message in the log will not be the same as the line number of the csv row that has a problem, I need to parse out the number from the log text. If I understand your script it assumes the line numbers are the same.

No. If the ERROR ROW VALUE is 1000, then my script will skipp 1000+1 line of your .CSV file and save the rest in NewFile.Csv. It don't count the line number of your LogFile.

windows - how to: restart batch processing of csv file at certain line...

windows batch-file csv
Rectangle 27 2

Ahh, this happens to me a lot. Try to force kill the app once it has a crash before you restart, the app is hung on the device. But once it happens delete the app on the device/simulator, restart the device/simulator and restart XCode. Very annoying right! Alternatively you could edit your scheme and change debugger to GDB. It has nothing to do with your code.

objective c - How to restart an app after a dangling pointers is teste...

objective-c xcode cocoa-touch
Rectangle 27 7

A couple things to point out here. When your role starts, it uses something called the IISConfigurator to call out programmatically to IIS and create apps, vdirs, app pools, etc. as defined in Service Definition. That is done once on startup.

Remember that the w3wp.exe process that hosts your website is completely separate from the RoleEntryPoint that you might use to run code. As such, you cannot just called RoleEntryPoint.RequestRecycle() and expect that IIS will restart (it won't).

One solution you might try if you must restart IIS is to programmatically do it. Here is my 3 line solution for restarting IIS on Windows Azure:

var mgr = new ServerManager();
var azurePools = mgr.ApplicationPools.Where(p => Guid.TryParse(p.Name));
azurePools.ToList().ForEach(p => p.Recycle());

I am using the knowledge that application pools are GUIDs in Windows Azure to filter them down to the ones I am interested in.

Now, you just need a way to run that code from an elevated condition on demand across each instance. That is a common problem with lots of solutions. Perhaps have each instance poll a file or table for a signal to run that code whenever you need to restart IIS.

+1 This is good to know. In our case, we don't have any code that runs in the RoleEntryPoint. That's why restarting IIS works for us. Would you recommend running the above code in a production instance?

how is this solution ANY different to iis-reset, or RDP'ing and restarting the IIS processes manually? this just does it through code. if the article you link to is true, then this will make no difference at all. will it?

If you know that you occasionally need to reset IIS in response to normal application updates (e.g modifying CRM themes, etc.), you typically want an automated solution. Otherwise, no, it is not altogether different. RDP is great for troubleshooting, not so hot for longterm operations mgmt.

@jmac - it depends a bit on how you implement it. A non-trivial implementation would roll through each instance, have it report itself busy to the load balancer, then run this code to restart (and then report back as ready). That way you keep some instances available as you upate. If you just shotgun the command to each instance, you will likely have a brief period while each IIS app pool recycles until it can serve again.

Is it possible to restart IIS on a Azure web role without restarting t...

iis azure
Rectangle 27 2

Ipython does allow reloads see the magic function %run iPython doc

or if modules under the one have changed the recursive dreloadd() function

If you have a complex context is it possible to create it in another module? or assign it to a global variable which will stay around as the interpreter is not restarted

The dreload() sounds also good but it seems to run into problems with Numpy - it also seems to ignore whatever I set in the exclude keyword list ...

dreload()

How to develop a Python module/package without having to restart the i...

python module packages
Rectangle 27 1

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>

@interface ViewController () <AVAudioPlayerDelegate>

@property (nonatomic, strong) AVAudioPlayer *audioPlayer;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    _audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"ttt" ofType:@"mp3"]] error:nil];
_audioPlayer.delegate = self;
}

- (void)play:(id)sender
{
    [_audioPlayer play];
}

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    NSError *error = nil;
    if (![audioSession setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&error]) {
        NSLog(@"resume music player failed, error=%@", error);
    }
}

@end

I know it's old, but thank a lot, really helped me!

ios - how to restart the music player after play a sound in my app in ...

ios objective-c xcode avaudioplayer
Rectangle 27 1

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>

@interface ViewController () <AVAudioPlayerDelegate>

@property (nonatomic, strong) AVAudioPlayer *audioPlayer;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    _audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"ttt" ofType:@"mp3"]] error:nil];
_audioPlayer.delegate = self;
}

- (void)play:(id)sender
{
    [_audioPlayer play];
}

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    NSError *error = nil;
    if (![audioSession setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&error]) {
        NSLog(@"resume music player failed, error=%@", error);
    }
}

@end

I know it's old, but thank a lot, really helped me!

ios - how to restart the music player after play a sound in my app in ...

ios objective-c xcode avaudioplayer