Posts

Use Hashtable with switch case in PowerShell -

i need make decisions in powershell based on values in hashtable. basically need assign users' upn in active directory according attribute, company one, , thought create hashtable containing keys , values this key value company1 @company1.com company2 @company2.com the issue facing don't know how tell powershell use value rather based on company attribute, don't know how cycle/check company attribute against key in hashtable. i've tried use switches $a -match $hashtable or $a -contains $hashtable with little success. i think hashtable need here, of course open suggestion using external files match number of companies need match rather high. while mathias presented proper solution i'd add more explanation. hashtables , switch statements 2 different solutions same problem: transform input value corresponding output. → "foo" b → "bar" c → "baz" ... hashtables simpler (and faster) appr...

performance - SQL Server Stored Procedures Execution difference -

i have sql server 2016. there 2 absolutely same stored procedures different names, execute differently. first completes in 17 minutes, other in 18 second. first created before index on 1 of elements created, recompiled , cleared plans plan cache. result not change. what problem can , how reconfigure execution plan? to improve performance of stored procedure must executed script lower. can recreate execution plan. exec sp_recompile n'procedurename'; go dbcc freeproccache no_infomsgs; go exec sp_updatestats; go

php - Echo variable which has been set in another classes function -

i trying access contents of variable class. have code below, expecting 'test' returned, nothing. i assume because getting $abc_rank empty. required variable populated in function itself. therefore how can $abc_rank hold echo , output via other class? <?php class class1 { public static $abc_rank; public function __construct() { $this->add_text(); } public function add_text() { $this->abc_rank = 'test'; } } class class2 { public function __construct() { $this->display(); } public function display() { $test = class1::$abc_rank; echo $test; } } $go = new class2(); ?> i know can do: public static $abc_rank = 'test'; but population of variable must in function. i have read of other related answers , can't seem work. in class1 : replace $this->abc_rank = 'test'; $this::$abc_rank='test'; ($abc_rank static proper...

ios - Only two selection tableView (Shortcut code) -

in controller user can multiple selection (two) only, code working fine develop ourselves looking wonderful shortcut code, need make nice view of code think liked see ideas -(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { if (self.firstindex) { if (indexpath == self.firstindex) { // return of first selection uitableviewcell *oldcell = [tableview cellforrowatindexpath:indexpath]; if (indexpath.row % 2) oldcell.backgroundcolor = [uicolor whitecolor]; else oldcell.backgroundcolor = [viewcontroller colorfromhexstring:@"#f4f6f9"]; oldcell.textlabel.textcolor = [uicolor blackcolor]; self.firstindex = nil; } else { // selection if (self.secondindex) { if (indexpath == self.secondindex) { // return uitableviewcell *oldcell = [tableview cellforro...

javascript - Ionic: integrate into iMessage on iOS -

everybody. i'm stuck... i'm implementing ios chat on ionic framework, , use angular 1. have idea... in google can't find information implementing imessage app (or otherwise, doesn't matter). for example, service do some ideas i've got here: https://github.com/matiastucci/socket-chat-client you can create imessage app (an app shows in keyboard area when in imessage app). but, can not create app show incoming imessages or send imessage someone. information on building imessage app

Powershell w32tm command error: Getting AD DC list for default domain...GetDcList failed with error code: 0x80070774 -

i trying run script return w32tm status of host, run this- $serverlist = @(w32tm /monitor | where-object{$_.startswith(" ntp:") -and !$_.startswith(" ntp: error")}) to list of ntp sources , time offsets when run domain account works fine, when run local system account error- getting ad dc list default domain...getdclist failed error code: 0x80070774. exiting error 0x80070774 is there way can around this? don't want change user account script runs under other reasons w32time /monitor gets information domain controller (pdc). for same reason, needs domain admin credentials fetch it. but if wish information locally, should use: w32tm /query /configuration hope can understand difference.

r - How to convert a named list of named vectors to a data.frame conveniently? -

suppose have following named list of named vectors: structure(list(var1 = structure(c(-0.59588185761272, -1.40360179042903, -0.930940964040855, 0.627327161612272, 2.5718263501814, -0.494398712878508 ), .names = c("w", "x", "j", "v", "y", "a")), var2 = structure(0.845082248473655, .names = "k"), var3 = structure(c(-0.0445511021832538, 1.29597344526442), .names = c("b", "c"))), .names = c("var1", "var2", "var3")) # $var1 # w x j v y # -0.5958819 -1.4036018 -0.9309410 0.6273272 2.5718264 -0.4943987 # # $var2 # k # 0.8450822 # # $var3 # b c # -0.0445511 1.2959734 how derive data.frame of values, names of vectors , names of lists. derived output looks this: # values vec var.name # 1 -0.5958819 w var1 # 2 -1.4036018 x var1 # 3 -0.9309410 j v...