Switch to last active session in tmux - key-bindings

I want to know is it possible to switch to last session I visited in tmux.
For e.g., suppose I was in pane 1 of session A and I switched to pane 1 in session B (using PREFIX s and selecting the pane 1 in B). Now I want to switch back to pane 1 of session A.
Is there any keybinding for that?

Switch between sessions:
C-b ( previous session
C-b ) next session
C-b L ‘last’ (previously used) session
C-b s choose a session from a list

Related

rails multiple user editing the same record

I have a table in the front end with multiple rows that can be read and edited. Each row has an edit icon that the user will click on, and a dialog will pop up to update the fields in the row. The save button on the dialog will save the fields (call the update API), close the dialog, and reload the table by calling the list API with the same page, filters, and sort order.
To support multiple users reading and editing the same table, I want to lock the row that clicks on the edit icon, and unlock if when the user clicks on save or cancel on the dialog that pops up. To do this, I added a lock field to each row in the database.
When the user clicks on the edit icon, I send a lock API call:
lock_success = false
message = nil
row = Row.find(id)
# (with_lock)
if row.lock.nil?
row.lock = #current_user.user_name
row.save!
lock_success = true
end
# (with_lock_end)
When the edit dialog is closed on save or cancel:
Row.update(id, lock: nil)
But there could be a case where this follows?
(1) row = Row.find(1)
(2) row = Row.find(1)
(1) if row.lock.nil?
(2) if row.lock.nil?
(1) row.lock = #current.user_name
(2) row.lock = #current.user_name
(1) row.save!
(2) row.save!
If I wrap row.with_lock around (with_lock) and (with_lock_end), it should solve this problem right?
Lastly, can I use optimistic locking with lock_version?.
User (1) loads row 1 with version 1.
User (2) loads row 1 with version 1.
User (1) updates row 1 with version 1, now row 1 is version 2.
User (2) updates row 1 with version 1, gets back stale object exception.
Then I won't need to wrap the update calls with with_lock? However, how can I keep track of who locked the row via this method?
Try doing something like this:
lock_obtained = Row.where(id: 1, locked_by: nil).update_all(locked_by: #current_user.user_name, locked_at: Time.zone.now) == 1
# this try to update the row with ID 1 with the current_user's name only if it's not already locked, if the call returns 1 it means that the record was updated so #current_user locked it, if it returns 0 it means the record was already locked by someone else, that's the "== 1" for
Now, you'll try to lock the row and know if the row was locked before or succeded in just one line so you won't run into that race condition.
Just a few suggestion:
- I would use an integer with the user id for the locked_by column instead of the name
- I would also save the locked_at timestamp, sounds it could be usedfull
- What do you do if the user closes the tab that locked the row? For this kind of stuff you should use ActionCable so you have can detect if the user got disconnected too.

Neo4j - Relaunch the program always revert the value of new added data

I have a problem with Neo4j database. When I add new Data to database and update the value of it (default : 0.0), it will recorded in database and then when I refresh the page, the data will not changed.
But, when I relaunch the program (Stop - Star or Restart) the program, the value of new Data will back to its original value (0.0). I already try to tracing all event that related to change the value, but none of the breakpoint is executed to change the value.
Is there any bug that can revert the value to its default value? Because the value of my new Data, same like the default value after I added it to database (Before update).
This is my simple code to create new data
LineItem newLineItem = new LineItem(engine, previousLineItem.getNo() + 1, previousLineItem.getSection(), "ACTIVITY ENGINE", previousLineItem.getActivityCode(), "ENGINE", 0.0,
"",checked, "");
lineItems.add(newLineItem);
lineItemService.save(lineItems);
And this is how I updated my data
LineItem lineItem = lineItemService.findById(id);
if(lineItem != null){
if(name != null)lineItem.setName(name);
if(duration != null)lineItem.setDuration(roundUpToNearestQuarter(duration));
lineItemService.save(lineItem);
return lineItemList;
}
return new ArrayList<LineItem>();
The problem is, When I just refresh the page, and never Relaunch it, the duration data is same like the newest data, but after I relaunch the program, the duration data will revert back to default value (0.0)
There is no code that revert back my data to its original, because I already search global and give breakpoint on each code that have possibility to changed the value.
This bug related to my other bug, Argument mistype. Link : Spring Data Neo4j - Argument Type Mismatch
It will revert all my values to default because when I relaunch the program, it will get the default data that I set before.
Just need to check the attribute data and data saved on database, is it correct data or wrong type data.

How to reset a preference to its previous value in Firefox extension?

I have an extension that allows users to change the home page and new tab page. I do so by changing the values of some preferences (e.g. browser.startup.homepage, browser.newtab.url).
I want to reset the values of these preferences to previous values(not default) when the user uninstalls the extension.
How to reset the preference to its previous value?
Thanks.
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const ps = Cc['#mozilla.org/preferences-service;1'].getService(Ci.nsIPrefBranch);
ps.clearUserPref('full.path.to.pref.here');
Note: This reset pref to default value, if no default value is set the pref is deleted.

DynamicUpdateCommand stops working after QlikView restart

I'm using DynamicUpdateCommand inside a macro in this way:
sub addOrder
set choosen = ActiveDocument.Fields("NUMORD").GetPossibleValues
for i = 0 to choosen.Count - 1
set result = ActiveDocument.DynamicUpdateCommand("UPDATE * SET CHOOSE = 'S' WHERE NUMORD = '" & choosen.Item(i).text & "' " )
if result = false then
MsgBox result.ErrorMessage
end if
next
end sub
Dinamic Data Update is enabled.
It works, but, when I close QlikView and reopen it, it doesn't work anymore. Even if try reloading.
I empirically realized that to make it work again I need to click the "Save" button, even without changing anything...
How can I solve this little issue? Maybe is it connected with RAM and way of saving .qvw file to the file system?
Many thanks!
Without any other solution I ended with this workaround, which saves the document programmatically on document opening:
Document Properties... > Triggers > Document Event Triggers > OnOpen > Add Action(s)... > Add > External > Run macro > set Macro name = reactivateDynamicUpdateCommand
Tools > Edit Module...: add this subroutine:
sub reactivateDynamicUpdateCommand
' I know, it's weird
'... but needed to reactivate DynamicUpdateCommand functionality after a restart
ActiveDocument.Save
end sub
It works, though a better solution would be preferred.
Starting from version 11 Dynamic Update can be done as Actions rather than through VB macro. It is preferable to use Actions when possible. However, sometimes even using Dynamic Update action I noticed freezes similar to what you described. I ended up adding one more dummy action right after Dynamic Update (e.g. assigning a value to dummy variable or adding Selection -> Back action to compensate triggering OnSelect).

Ad Asp.Net Changing Passwords

We're using ASP.NET MVC and AdMembership provider for login, and for various reasons had to implement our own "Change Password on next Login" functionality.
We also have a nist requirement of not allowing more than one change per 24 hours. so it's set up that way in AD.
What we need is to Ignore that one requirement when resetting a password to default, we want the student to be forced to change the password on the next logon, even if it's before 24 hours.
here is my stab at it. Basically I want to change the PwdLastSet property to a value more than 24 hours old after we reset the password.
if ( bSetToDefault )
{
var adDate = userToActOn.ADEntry.Properties[ "PwdLastSet" ][ 0 ];
DateTime passwordLastSet = DateTime.FromFileTime( ( Int64 ) adDate );
passwordLastSet = System.DateTime.Now.AddHours( -25 );
long filetime = passwordLastSet.ToFileTimeUtc();
userToActOn.ADEntry.Properties[ "PwdLastSet" ][ 0 ] = filetime;
}
But I keep getting null back even when I know the users password has been changed.
anyone got any hints or suggestions? Am I looking in the wrong property?
hmm this attribute is replicated so should always be available.
Try the command line script to see if it shows up:
http://www.rlmueller.net/PwdLastChanged.htm
Its possible because its a 64bit date and not doing a conversion? Try the script though and see if it works. if it does, then look at the Integer8Date procedure in it for your date conversion.
If you use System.DirectoryServices.AccountManagement then there is an exposed method for the User Principal to expire the password immediately. So it will be as easy as calling it like such oUserPrincipal.ExpirePasswordNow(); for more info about using it please see this article.

Resources