How to create multiple div's with php Posted: 22 Jul 2021 07:58 AM PDT I want to run a script on a simple php page which is not connected to any database. So basically i need a php code in which i can define a particular initial and final value for php script, and this should generate required div's with values increment visible right next to current value. I basically have no idea how to do this job done. So please help me with this. I am writing an incomplete code with this also. <?php $initialval=5; $finalval= 10 <div class="w3-card-4" > <div class="w3-container"> <h3>Current Value: 5</h4> </div> </div><br> <div class="w3-card-4" > <div class="w3-container"> <h3>Current Value: 6</h4><br> </div> </div><br> <div class="w3-card-4" > <div class="w3-container"> <h3>Current Value: 7</h4><br> </div> </div><br> . . . . . and soon upto final value. ?> Please give me a working code for my project. |
How would I link a recipe_ID with multiple instances of ingredient_ID when creating a recipe database? Posted: 22 Jul 2021 07:58 AM PDT I am writing a recipe database to be used with a java webapp. The issue I'm having is assigning multiple rows from the ingredients table to individual rows from the recipes table. I'm not even sure if it's possible to say something like recipe_id(1) corresponds to ingredient_id(1, 2, 4, 6, 11) |
How do I populate an array with values sourced from WorksheetFunction.Unique()? Posted: 22 Jul 2021 07:57 AM PDT I'm trying to get an array of unique values sourced from a listobject table. I'm trying to use the 'Unique' method of the worksheetfunction object, but I'm getting a host of errors however I try to write the code. How do I use Worksheetfunction.Unique to populate an array? Here's a pseudocode skeleton: Dim Ws As Worksheet Set Ws = Worksheets("Sheet1") Dim Rng As Range Dim UniqueArr() As String Set Rng = Ws.ListObjects("Table").ListColumns(2).DataBodyRange Set UniqueArr() = WorksheetFunction.Unique(Rng) --Fill UniqueArr() with these values I can't set the size of the array without knowing how many unique values there are, but I can't fetch the unique values to count them. |
Google cloud compute VM instance not getting listed Posted: 22 Jul 2021 07:57 AM PDT I lost my vm instance and a huge amount of data with it. I even paid the pending amount to google but when i went to the vm instance page, it is showing only create instance menu. How can i recover my old vm instance. Please help |
Auditd exclude filters are adding a significant delay Posted: 22 Jul 2021 07:57 AM PDT I am running AuditBeat with the auditd module, and I have noticed that some filter rules are adding a significant delay between the event being created, and AuditBeat publishing the event. For example: Consider the following rule which is filtering out events which are not the message_types PATH, SYSCALL or CWD. -a never,exclude -F msgtype!=SYSCALL -F msgtype!=PATH -F msgtype!=CWD From the AuditBeat logs: 2021-07-22T16:38:11.822+0200 DEBUG [processors] processing/processors.go:203 Publish event: { "@timestamp": "2021-07-22T14:38:09.791Z", "@metadata": { "beat": "auditbeat", "type": "_doc", "version": "7.11.1" }, . . . "process": { "ppid": 9599, "name": "touch", "executable": "/usr/bin/touch", "pid": 18287 } } 2021-07-22T16:38:12.329+0200 DEBUG [kafka] kafka/client.go:371 finished kafka batch As can be seen, there is a 2 second delay before the touch event happened, and the event is published by Auditbeat: 2021-07-22T14:38:09.791 vs 2021-07-22T16:38:11.822 However, exclude filters which "Blacklisting" instead of "Whitelisting" does not seem to introduce the same delay. Consider the following filters which are defining which message_types to exclude, instead of which message_types not to exclude: -a always,exclude -F msgtype=user_acct -a always,exclude -F msgtype=add_group -a always,exclude -F msgtype=add_user -a always,exclude -F msgtype=cred_disp -a always,exclude -F msgtype=cred_acq -a always,exclude -F msgtype=cred_refr -a always,exclude -F msgtype=crypto_key_user -a always,exclude -F msgtype=crypto_login -a always,exclude -F msgtype=user_auth -a always,exclude -F msgtype=user_avc -a always,exclude -F msgtype=user_logout From the Auditbeat logs: 2021-07-22T16:47:25.227+0200 DEBUG [processors] processing/processors.go:203 Publish event: { "@timestamp": "2021-07-22T14:47:25.207Z", "@metadata": { "beat": "auditbeat", "type": "_doc", "version": "7.11.1" }, . . . "process": { "pid": 18685, "ppid": 9599, "title": "touch hello", "name": "touch", "executable": "/usr/bin/touch", "working_directory": "/var/entimice" } } 2021-07-22T16:47:25.729+0200 DEBUG [kafka] kafka/client.go:371 finished kafka batch As can be seen from the logs, the time difference is much more reasonable: 2021-07-22T14:47:25.207 vs 2021-07-22T16:47:25.227 Since there is a lot of different message_types (https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/security_guide/sec-audit_record_types) it is obviously more convenient to use the first rule, instead of a 100-something rules to capture all the message_types I am not interested in. I would like to know what is causing this delay, and if it can be circumvented somehow. |
Filter only true combination before the mean operation Posted: 22 Jul 2021 07:56 AM PDT I'd like to extract the mean just only in the existing combinations in var1 and var2 using for , in my example: # Create my variables var1<-c(rep(6,25),rep(7,5)) var2<-c(1,1,1,1,1,2,2,2,2,2,5,5,5,5,5,10,10,10,10,10,11,11,11,11,11,5,5,5,5,5) var3<-rnorm(30) # Create a data frame mydf<-data.frame(var1,var2,var3) str(mydf) # Inspection by var1 and var2 table(mydf$var1,mydf$var2) #1 2 5 10 11 #6 5 5 5 5 5 #7 0 0 5 0 0 # I'd like not considering "0" combinations!! # My idea is create a subset just only for combinations that have values, but if I make: var1ID <- unique(mydf$var1) var2ID <- unique(mydf$var2) for(a in 1:length(var1ID)){ for(b in 1:length(var2ID)){ mydf_sub <- mydf[mydf$var1 == var1ID[a] & mydf$var2 ==var2ID[b],] print(var1ID[a]) print(var2ID[b]) print(mean(mydf_sub$var3)) }} # [1] 6 # [1] 1 # [1] 0.2683563 # [1] 6 # [1] 2 # [1] -0.1699396 # [1] 6 # [1] 5 # [1] -0.1041284 # [1] 6 # [1] 10 # [1] 0.1410427 # [1] 6 # [1] 11 # [1] 0.14649 # [1] 7 # [1] 1 # [1] NaN # [1] 7 # [1] 2 # [1] NaN # [1] 7 # [1] 5 # [1] 0.608454 # [1] 7 # [1] 10 # [1] NaN # [1] 7 # [1] 11 # [1] NaN Here a have a problem because I'd just only the output with values existent combinations and not "NaN". Please, any help with my problem or any dplyr approach to solving it? |
How can i copy one index into multiple indices based on field value? Posted: 22 Jul 2021 07:56 AM PDT I have an elasticsearch index generated per day (ex: index-2021-07-21, index-2021-07-22 ...), each of these indices have a field called projectId (ex: "projectId": "xxx", "projectId": "yyyy") I would like to split daily generated index in question into multiple indices based on "projectId" field. for example : let's say we have index-2021-07-21. the result expected : index-xxx-2021-07-21 --> where this index contain all docs where "projectId" field equal to "xxx" index-yyy-2021-07-21 --> where this index contain all docs where "projectId" field equal to "yyy" and so on... how can i do that ? any help would really appreciated |
Why a variable function can be called from a array in php? Posted: 22 Jul 2021 07:58 AM PDT I am reading the documentation of php about Variable functions I don't understand the example 4 below. How come the first and second $func(); can call the function bar() and baz() . The $func is a array . Maybe it is a silly question. Thanks. <?php class Foo { static function bar() { echo "bar\n"; } function baz() { echo "baz\n"; } } $func = array("Foo", "bar"); $func(); // prints "bar" $func = array(new Foo, "baz"); $func(); // prints "baz" $func = "Foo::bar"; $func(); // prints "bar" ?> |
Calculating mean coverage per gene Posted: 22 Jul 2021 07:57 AM PDT I have 2 files: file 1 (below) has bp start and stop coordinates |Chrom| Gene start (bp) | Gene end (bp) | | --------| -------- | -------------- | | 1| 50902700 | 50902978 | | 1| 103817769 | 103828355 | file 2 has mean coverage values per base pair position: Chrom | pos | mean | 1 | 12141 | 0.029005 | 1 | 12142 | 0.029216 | what I need: I need to match chrom, start and end from file 1 (taking start and end as a range) to chrom, pos; and calculate average of means (mean column in file 2) within that range of coordinates of file 1. desired output: Chromosome/scaffold name Gene start (bp) Gene end (bp) average coverage per gene 1 50902700 50902978 x 1 103817769 103828355 x 1 50927141 50936822 x 1 50965430 50965529 x 1 51048076 51048183 x 1 51215968 51216025 x 1 45959538 45965751 x I have tried using dictionaries and nested for loops: but am still struggling, whats the best way to do this? |
Divide the specific element of a list of lists by one number? Posted: 22 Jul 2021 07:57 AM PDT I have the below list and I want to divide only the third element of the items by 48: mlst: [(3, 4, 3), (20, 20, 4), (5, 30, 26)] So my expected results should be: mexlst: [(3, 4, 0.062), (20, 20, 0.083), (5, 30, 0.54)] |
How to move border bottom bar to the end of navbar while hovering Posted: 22 Jul 2021 07:58 AM PDT How can I move the red bottom bar to the end of the navbar on hovering on my list elements? Also, as you can see the edges of the bar are not straight, how can I fix this issue? Current code: - header { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 12%; background-color: #1c2236; color: white; position: fixed; left: 0; right: 0; } .nav-links { li { list-style: none; display: inline-block; border: 2.5px solid transparent; margin: 0.4rem 1rem; padding-bottom: 0.5rem; &:hover { border-bottom: 2.5px solid red; padding-bottom: 0.5rem; cursor: pointer; transition: 0.25s; } } } a { color: #fff; } |
R changing Excel Date columns Datatype to Logical during read_excel() if Date column is empty in excel Posted: 22 Jul 2021 07:57 AM PDT So I have 2 excels VIN1.xlsx and VIN2.xlsx that I need to compare. VIN1 excel has a dale column OUTGATE_DT which is populated for atleast 1 rows. VIN2 excel has a date column OUTGATE_DT which is completely null for all rows. when I import VIN1.xlsx excel using read_excel, it creates the object, and when I check the OUTGATE_DT column, it says its datatype to be as POSIXct[1:4] (which I assume is correct for Date Column. ) But when I import VIN2.xlsx excel using read_excel, it creates the object, and when I check the OUTGATE_DT column, it says its datatype to be logical[1:4] (it is doing this because this column is entirely empty). and that is why my compare_df(vin1,vin2) functions failing stating - Error in rbindlist(l, use.names, fill, idcol) : Class attribute on column 80 of item 2 does not match with column 80 of item 1. I am completely new with R, your help would be highly appreciated. TIA Please check the screenshot for reference.enter image description here |
Using Selenium ChromeDriver with VBA Error Posted: 22 Jul 2021 07:57 AM PDT I'm a beginner with both VBA and Selenium so forgive me if this is too obvious. I'm trying to see whether I can make VBA open a Chrome window to check that Selenium works fine, via the code below: Option Explicit Private MyBrowser As Selenium.ChromeDriver Sub TestSelenium() Set MyBrowser = New Selenium.ChromeDriver MyBrowser.Start End Sub I, however, get the following error: Does anyone know what I could be doing wrong? Thanks so much |
Chat message style Posted: 22 Jul 2021 07:56 AM PDT I am Having a lof of problems trying to create a message card for my app. Basically I want to the content of the message div to be align with the name of the person,like this app .I already Tried to change the display to flex wrap,but still not the same, And I am looking if it's possible to re-create what this person did on the image here Right now mine is this: ::-webkit-scrollbar { width: 3px; height: 3px; } ::-webkit-scrollbar-button { width: 0px; height: 0px; } ::-webkit-scrollbar-thumb { background: #fc0303; border: 100px none #ffffff; border-radius: 7px; } ::-webkit-scrollbar-thumb:hover { background: #fc0303; } ::-webkit-scrollbar-thumb:active { background: #000000; } ::-webkit-scrollbar-track { background: #191919; border: 100px none #ffffff; border-radius: 100px; } ::-webkit-scrollbar-track:hover { background: #191919; } ::-webkit-scrollbar-track:active { background: #333333; } ::-webkit-scrollbar-corner { background: transparent; } #menu_icon { width:40px; height:40px; border-radius:50%; transition: transform .9s; float:right } #menu_icon:hover { cursor:pointer; -ms-transform: scale(1.1); /* IE 9 */ -webkit-transform: scale(1.1); /* Safari 3-8 */ transform: scale(1.1); } .chat_box{ background-color:#191919; overflow: scroll; overflow-x: hidden; border: 2px black dashed; width:100%; height:100%; border-radius:3px; padding:10px; } .chat_box_message_content{ display:block; } .msg-txt { display: flex; flex-flow: wrap column; width: 80%; } .chat_box_message_content p{ color:white; } .chat_box_message_content img { width:35px; height:35px; border-radius:50%; } body { background: #eef0f1; color: black; font-family: "Roboto", sans-serif; overflow-x: hidden; } <div id="chat_box" class="chat_box"> <img onclick="showMenu()" id="menu_icon" src="https://i.pinimg.com/736x/3f/e0/dc/3fe0dcb84367af59e8881edcb7747d58.jpg"> <p style="color:white;font-size:13px;font-style: oblique;margin-top:50px">Usuário Conectado ao servidor!</p> <div class="chat_box_message_content"> <img src="https://i.pinimg.com/736x/3f/e0/dc/3fe0dcb84367af59e8881edcb7747d58.jpg"> <span style="color:#9b72da" class="chat_box_message_content_icon">o</span> <p class="chat_box_message_content_msg"> AAAAAAAAA </p> </div> <div class="chat_box_message_content"> <img src="https://i.pinimg.com/736x/3f/e0/dc/3fe0dcb84367af59e8881edcb7747d58.jpg"> <span style="color:#da729f" class="chat_box_message_content_icon">Maria</span> <p class="chat_box_message_content_msg"> teste </p> </div> </div> Can U guys help me with it? |
Javascript - Is there a better way to split a string based on its length? Posted: 22 Jul 2021 07:58 AM PDT I have the time of day in strings ie. (830, 1450, 1630). I know I can do simple if statements to check if the length is 3 or 4 and get out (8) and (30) or (14) and (50), but is there a cleaner way to split the hour and the minute without having to check in if statements? |
How do I adjust this code to add easing to mouse movement? Posted: 22 Jul 2021 07:58 AM PDT Im trying to add easing to the custom cursor on my site but im having no luck after trying a few things. If anyone knows how to adjust the following code to enable this functionality that would be super helpful as i've been stuck on it for a few hours! I as reading about using lerp to achieve this See this Codepen , but couldn't extract the code successfully. jQuery(document).ready(function($){ $(document).mousemove(function(e) { const cursor = $('.custom-cursor'); const target = $(event.target); // update position of cursor cursor.css('left', e.clientX-10).css('top', e.clientY-10); const isLinkTag = target.is('a,span,[onclick],img,video,i'); const isHovered = cursor.hasClass('hoveredCursor'); // toggle the cursor class if necessary if(isLinkTag && !isHovered) { cursor.addClass('hoveredCursor'); } else if(!isLinkTag && isHovered) { cursor.removeClass('hoveredCursor'); } }) $(document).mouseleave(function(e) { const cursor = $('.custom-cursor'); cursor.hide() }); $(document).mouseenter(function(e) { const cursor = $('.custom-cursor'); cursor.show() }); }); * { cursor: none; } .custom-cursor{ width: 20px; height: 20px; top: 0; left: 0; bottom: 0; right: 0; background-color: #FB4D98; border: 2px solid black; position: fixed; border-radius:50%; pointer-events: none !important; z-index: 99999999 !important; transition: transform 0.2s; } .hoveredCursor { transform: scale(0.5); transition: transform 0.2s; opacity: 0.5; background-color: black; border: 2px solid #FB4D98; } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="custom-cursor"></div> |
Running in to issue with script I'm attempting to adapt Posted: 22 Jul 2021 07:57 AM PDT I found this script I'm looking to use to send emails to users when their passwords expire. This is the area I'm running in to issues with: param( # $smtpServer Enter Your SMTP Server Hostname or IP Address [Parameter(Mandatory=$True,Position=0)] [ValidateNwotNull()] [string]$smtpServer, # Notify Users if Expiry Less than X Days [Parameter(Mandatory=$True,Position=1)] [ValidateNotNull()] [int]$expireInDays, # From Address, eg "IT Support <support@domain.com>" [Parameter(Mandatory=$True,Position=2)] [ValidateNotNull()] [string]$from, [Parameter(Position=3)] [switch]$logging, # Log File Path [Parameter(Position=4)] [string]$logPath, # Testing Enabled [Parameter(Position=5)] [switch]$testing, # Test Recipient, eg recipient@domain.com [Parameter(Position=6)] [string]$testRecipient, # Output more detailed status to console [Parameter(Position=7)] [switch]$status, # Log file recipient [Parameter(Position=8)] [string]$reportto, # Notification Interval [Parameter(Position=9)] [array]$interval, ) # Time / Date Info $start = [datetime]::Now $midnight = $start.Date.AddDays(1) $timeToMidnight = New-TimeSpan -Start $start -end $midnight.Date $midnight2 = $start.Date.AddDays(2) $timeToMidnight2 = New-TimeSpan -Start $start -end $midnight2.Date # System Settings $textEncoding = [System.Text.Encoding]::UTF8 $today = $start # End System Settings # Load AD Module try{ Import-Module ActiveDirectory -ErrorAction Stop } catch{ Write-Warning "Unable to load Active Directory PowerShell Module" } # Set Output Formatting - Padding characters $padVal = "20" Write-Output "Script Loaded" Write-Output "*** Settings Summary ***" $smtpServerLabel = "SMTP Server".PadRight($padVal," ") $expireInDaysLabel = "Expire in Days".PadRight($padVal," ") $fromLabel = "From".PadRight($padVal," ") $testLabel = "Testing".PadRight($padVal," ") $testRecipientLabel = "Test Recipient".PadRight($padVal," ") $logLabel = "Logging".PadRight($padVal," ") $logPathLabel = "Log Path".PadRight($padVal," ") $reportToLabel = "Report Recipient".PadRight($padVal," ") $interValLabel = "Intervals".PadRight($padval," ") # Testing Values if($testing) { if(($testRecipient) -eq $null) { Write-Output "No Test Recipient Specified" Exit } } # Logging Values if($logging) { if(($logPath) -eq $null) { $logPath = $PSScriptRoot } } # Output Summary Information Write-Output "$smtpServerLabel : $smtpServer" Write-Output "$expireInDaysLabel : $expireInDays" Write-Output "$fromLabel : $from" Write-Output "$logLabel : $logging" Write-Output "$logPathLabel : $logPath" Write-Output "$testLabel : $testing" Write-Output "$testRecipientLabel : $testRecipient" Write-Output "$reportToLabel : $reportto" Write-Output "$interValLabel : $interval" Write-Output "*".PadRight(25,"*") # Get Users From AD who are Enabled, Passwords Expire and are Not Currently Expired $users = get-aduser -filter {(Enabled -eq $true) -and (PasswordNeverExpires -eq $false)} -properties Name, PasswordNeverExpires, PasswordExpired, PasswordLastSet, EmailAddress | where { $_.passwordexpired -eq $false } # Count Users $usersCount = ($users | Measure-Object).Count Write-Output "Found $usersCount User Objects" # Collect Domain Password Policy Information $defaultMaxPasswordAge = (Get-ADDefaultDomainPasswordPolicy -ErrorAction Stop).MaxPasswordAge.Days Write-Output "Domain Default Password Age: $defaultMaxPasswordAge" # Collect Users $colUsers = @() # Process Each User for Password Expiry Write-Output "Process User Objects" foreach ($user in $users) { # Store User information $Name = $user.Name $emailaddress = $user.emailaddress $passwordSetDate = $user.PasswordLastSet $samAccountName = $user.SamAccountName $pwdLastSet = $user.PasswordLastSet # Check for Fine Grained Password $maxPasswordAge = $defaultMaxPasswordAge $PasswordPol = (Get-AduserResultantPasswordPolicy $user) if (($PasswordPol) -ne $null) { $maxPasswordAge = ($PasswordPol).MaxPasswordAge.Days } # Create User Object $userObj = New-Object System.Object $expireson = $pwdLastSet.AddDays($maxPasswordAge) $daysToExpire = New-TimeSpan -Start $today -End $Expireson # Round Expiry Date Up or Down if(($daysToExpire.Days -eq "0") -and ($daysToExpire.TotalHours -le $timeToMidnight.TotalHours)) { $userObj | Add-Member -Type NoteProperty -Name UserMessage -Value "today." } if(($daysToExpire.Days -eq "0") -and ($daysToExpire.TotalHours -gt $timeToMidnight.TotalHours) -or ($daysToExpire.Days -eq "1") -and ($daysToExpire.TotalHours -le $timeToMidnight2.TotalHours)) { $userObj | Add-Member -Type NoteProperty -Name UserMessage -Value "tomorrow." } if(($daysToExpire.Days -ge "1") -and ($daysToExpire.TotalHours -gt $timeToMidnight2.TotalHours)) { $days = $daysToExpire.TotalDays $days = [math]::Round($days) $userObj | Add-Member -Type NoteProperty -Name UserMessage -Value "in $days days." } $daysToExpire = [math]::Round($daysToExpire.TotalDays) $userObj | Add-Member -Type NoteProperty -Name UserName -Value $samAccountName $userObj | Add-Member -Type NoteProperty -Name Name -Value $Name $userObj | Add-Member -Type NoteProperty -Name EmailAddress -Value $emailAddress $userObj | Add-Member -Type NoteProperty -Name PasswordSet -Value $pwdLastSet $userObj | Add-Member -Type NoteProperty -Name DaysToExpire -Value $daysToExpire $userObj | Add-Member -Type NoteProperty -Name ExpiresOn -Value $expiresOn # Add userObj to colusers array $colUsers += $userObj } # Count Users $colUsersCount = ($colUsers | Measure-Object).Count Write-Output "$colusersCount Users processed" # Select Users to Notify $notifyUsers = $colUsers | where { $_.DaysToExpire -le $expireInDays} $notifiedUsers = @() $notifyCount = ($notifyUsers | Measure-Object).Count Write-Output "$notifyCount Users with expiring passwords within $expireInDays Days" # Process notifyusers foreach ($user in $notifyUsers) { # Email Address $samAccountName = $user.UserName $emailAddress = $user.EmailAddress # Set Greeting Message $name = $user.Name $messageDays = $user.UserMessage # Subject Setting $subject="Your password will expire $messageDays" # Email Body Set Here, Note You can use HTML, including Images. # examples here https://youtu.be/iwvQ5tPqgW0 $body =" <font face=""verdana""> Dear $name, <p> Your Password will expire $messageDays<br> To change your password on a PC press CTRL ALT Delete and choose Change Password <br> <p> If you are using a MAC you can now change your password via Web Mail. <br> Login to <a href=""https://mail.domain.com/owa"">Web Mail</a> click on Options, then Change Password. <p> Don't forget to Update the password on your Mobile Devices as well! <p>Thanks, <br> </P> IT Support <a href=""mailto:support@domain.com""?Subject=Password Expiry Assistance"">support@domain.com</a> | 0123 456 78910 </font>" # If Testing Is Enabled - Email Administrator if($testing) { $emailaddress = $testRecipient } # End Testing # If a user has no email address listed if(($emailaddress) -eq $null) { $emailaddress = $testRecipient }# End No Valid Email $samLabel = $samAccountName.PadRight($padVal," ") try{ # If using interval paramter - follow this section if($interval) { $daysToExpire = [int]$user.DaysToExpire # check interval array for expiry days if(($interval) -Contains($daysToExpire)) { # if using status - output information to console if($status) { Write-Output "Sending Email : $samLabel : $emailAddress" } # Send message - if you need to use SMTP authentication watch this video https://youtu.be/_-JHzG_LNvw Send-Mailmessage -smtpServer $smtpServer -from $from -to $emailaddress -subject $subject -body $body -bodyasHTML -priority High -Encoding $textEncoding -ErrorAction Stop $user | Add-Member -MemberType NoteProperty -Name SendMail -Value "OK" } else { # if using status - output information to console # No Message sent if($status) { Write-Output "Sending Email : $samLabel : $emailAddress : Skipped - Interval" } $user | Add-Member -MemberType NoteProperty -Name SendMail -Value "Skipped - Interval" } } else { # if not using interval paramter - follow this section # if using status - output information to console if($status) { Write-Output "Sending Email : $samLabel : $emailAddress" } Send-Mailmessage -smtpServer $smtpServer -from $from -to $emailaddress -subject $subject -body $body -bodyasHTML -priority High -Encoding $textEncoding -ErrorAction Stop $user | Add-Member -MemberType NoteProperty -Name SendMail -Value "OK" } } catch{ # error section $errorMessage = $_.exception.Message # if using status - output information to console if($status) { $errorMessage } $user | Add-Member -MemberType NoteProperty -Name SendMail -Value $errorMessage } $notifiedUsers += $user } if($logging) { # Create Log File Write-Output "Creating Log File" $day = $today.Day $month = $today.Month $year = $today.Year $date = "$day-$month-$year" $logFileName = "$date-PasswordLog.csv" if(($logPath.EndsWith("\"))) { $logPath = $logPath -Replace ".$" } $logFile = $logPath, $logFileName -join "\" Write-Output "Log Output: $logfile" $notifiedUsers | Export-CSV $logFile if($reportTo) { $reportSubject = "Password Expiry Report" $reportBody = "Password Expiry Report Attached" try{ Send-Mailmessage -smtpServer $smtpServer -from $from -to $reportTo -subject $reportSubject -body $reportbody -bodyasHTML -priority High -Encoding $textEncoding -Attachments $logFile -ErrorAction Stop } catch{ $errorMessage = $_.Exception.Message Write-Output $errorMessage } } } $notifiedUsers | select UserName,Name,EmailAddress,PasswordSet,DaysToExpire,ExpiresOn | sort DaystoExpire | FT -autoSize $stop = [datetime]::Now $runTime = New-TimeSpan $start $stop Write-Output "Script Runtime: $runtime" # End When I run the code it produces this error: PS C:\> .\ExpiredPassswordv6.ps1 -smtpServer smtp.office365.com -expireInDays 14 -from "TestDesk <TestDesk@gmail.com>" -logging -logPath C:\automation -testing -testRecipient testemail@gmail.com -reportto -interval 1 At C:\ExpiredPassswordv6.ps1:66 char:22 + [array]$interval, + ~ Missing expression after ','. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : MissingExpressionAfterToken PS C:\> I'm not well versed in Powershell and I cannot find any solution to this thing. There's a lot more to the script but I think I've narrowed the issue down to this location for now. *Edit - added rest of the script |
How to rename multiple files in linux and store the old file names with the new file name in a text file? Posted: 22 Jul 2021 07:57 AM PDT I am a novice Linux user. I have 892 .pdb files, I want to rename all of them in a sequential order as L1,L2,L3,L4...........,L892. And then I want a text file which contains the old names assigned to new names ( i.e L1,L2,L3). Please help me with this. Thank you for your time. |
How can I update a scene in Qt? Posted: 22 Jul 2021 07:57 AM PDT I'm trying to learn c++ and for that, I would like to implement a board game (the game of life) in which we have several cells. If the cell is alive, we paint it white, if the cell is dead we paint it black. What I am trying to do at the moment is simply: - make one cell alive
- show it on screen
- wait for half a second
- make another cell alive
- show it on screen.
However, it seems to me that when the scene is displayed, both cells are already alive. This is the main part of my current code: #include "mainwindow.h" #include <vector> #include <iostream> #include <QApplication> #include <QPushButton> #include <QGraphicsScene> #include <QGraphicsItem> #include <QGraphicsView> #include <QTimer> using namespace std; // global variables: const int WIDTH = 600; const int HEIGHT = 400; const int SIZE = 10; const int NCOL = HEIGHT/SIZE; const QColor aliveCol = QColor(200,200,200); const QColor deadCol = QColor(50,50,50); class Cell { public: int x; int y; bool alive; vector<Cell> neigh; Cell(int a = 0, int b = 0) { x = a; y = b; alive = false; neigh = {}; } void draw(QGraphicsScene * scene){ QGraphicsRectItem * cell1 = new QGraphicsRectItem(this->x*SIZE,this->y*SIZE,SIZE,SIZE); if (this->alive) { cell1->setBrush(QBrush(aliveCol)); } else { cell1->setBrush(QBrush(deadCol)); } scene->addItem(cell1); } }; void updateScene (Cell mat [NCOL][NCOL], QGraphicsScene * scene) { for (int i = 0; i<NCOL; i++) { for (int j = 0; j<NCOL; j++) { mat[i][j].draw(scene); } } } int main(int argc, char *argv[]) { QApplication prog(argc, argv); //MainWindow w; //w.show(); /** QPushButton *button = new QPushButton("Quit now!!"); QObject::connect(button, SIGNAL(clicked()), &prog, SLOT(quit())); button->show();**/ QGraphicsScene * scene = new QGraphicsScene(0,0,WIDTH,HEIGHT); //background: scene->setBackgroundBrush(Qt::gray); //build the board for (int i = 0; i <= NCOL; i++){ scene->addLine(SIZE*i,0,SIZE*i,HEIGHT); scene->addLine(0,SIZE*i,HEIGHT,SIZE*i); } //building the cells matrix: Cell mat [NCOL][NCOL]={}; for (int i = 0; i<NCOL; i++) { for (int j = 0; j<NCOL; j++) { mat[i][j] = Cell(i,j); } } //(...) <- Non important stuff //step 1 mat[9][7].alive = true; updateScene(mat,scene); //step 2 QGraphicsView * view = new QGraphicsView(scene); view->setFixedSize(610,410); view->show(); //step 3 (I know this is not how it is done, but I'm having troubles with QTimer) for (int i = 0; i < 2000; i++) { continue; } // step 4 mat[20][30].alive = true; updateScene(mat,scene); // step 5 scene->advance(); scene->update(); return prog.exec(); } |
Adding spaces to ggplot line graph Posted: 22 Jul 2021 07:57 AM PDT I have in total 39 weeks worth of data on mean strength and agility. However on week 10, no data was collected. When I plot my line graph to show this data, how would I put an empty spacing to indicate the missing value for week 10? i.e line graph plots week 9 and week 11 only (fitting line of best fit for week 10) It currently plots it by number of column entries so it looks like I have 38 weeks of continuous data which is misleading. my current code to plot this is: strength <- data %>% select(contains("stregnth_fac_")) %>% colMeans(., na.rm = TRUE) agility <- data %>% select(contains("agility_fac_")) %>% colMeans(., na.rm = TRUE) strength <- as.data.frame(strength) agility <- as.data.frame(agility) x <- 1:38 colors <- c("strength" = "blue", "agility" = "red") plot + scale_x_continuous(breaks=seq(0,45,5)) + geom_point() plot <- ggplot() + # blue plot geom_point(data= strength, aes(x=x, y= strength)) + geom_line(data= strength, aes(x=x, y= strength), colour="darkblue", size=1) + # red plot geom_point(data= agility, aes(x=x, y= agility)) + geom_line(data= agility, aes(x=x, y= agility), colour="red", size=1) + ylab("Score (1 - 10)") + xlab("Week") + labs(colour = "Legend") + ggtitle( "strength / agility Score") + theme(plot.title = element_text(size = 15, face = "bold", hjust = 0.5)) + ylim(5,10) plot EDIT: dput(strength) structure(list(strength = c(6.96645282796775, 6.9434770196974, 6.9294858041908, 6.96177484634987, 7.03444726005702, 6.95287400076132, 6.97520962449872, 7.16991357843855, 7.0516846361186, 7.16047777687495, 7.12286805260925, 7.18192771084337, 7.20209668025626, 7.26842105263158, 7.26456993569132, 7.3665857212239, 7.35361253506142, 7.35968885387948, 7.33265347746278, 7.35438494373302, 7.26772044934884, 7.1710243902439, 7.26794821498627, 7.16986222179401, 7.13271362974577, 7.21015218261914, 7.14576880807273, 7.10625192485371, 6.99561018437226, 7.06859571023877, 7.01988265971317, 7.18301335559265, 6.9627055825805, 7.15087538619979, 7.18207487973227, 7.06894071714785, 7.03441156228493, 6.83571981424149)), row.names = c("strength_fac_1", "strength_fac_2", "strength_fac_3", "strength_fac_4", "strength_fac_5", "strength_fac_6", "strength_fac_7", "strength_fac_8", "strength_fac_9", "strength_fac_11", "strength_fac_12", "strength_fac_13", "strength_fac_14", "strength_fac_15", "strength_fac_16", "strength_fac_17", "strength_fac_18", "strength_fac_19", "strength_fac_20", "strength_fac_21", "strength_fac_22", "strength_fac_23", "strength_fac_24", "strength_fac_25", "strength_fac_26", "strength_fac_27", "strength_fac_28", "strength_fac_29", "strength_fac_30", "strength_fac_31", "strength_fac_32", "strength_fac_33", "strength_fac_34", "strength_fac_35", "strength_fac_36", "strength_fac_37", "strength_fac_38", "strength_fac_39"), class = "data.frame") I've only put in dput for strength here but the format is almost identical for the agility variable. |
Get null fields after deserialization java JSON Posted: 22 Jul 2021 07:57 AM PDT I assume a problen in class structure. But I do not see where. Here is a code. I'm gonna use only some values from JSON. If you need some other code part just let me know. Maily I think I get objest (user) wuth null values here: User userDTOGetOne = userRequester.getUser ( token, new HashMap<String, Object>() {{ put("Uuid", userResponseDTO.getUserUuid()); }} ) .getBody() .as(User.class); I suppose here is a problem .as(User.class) with class structure. I have compared them not once and I can not find a problem. Thank you in advance. |
search in rows for common words and select them Posted: 22 Jul 2021 07:57 AM PDT there is some and mysqli . i want to select common words in each box. my dataset and words separated by | in each row. now if user clicks on show common words , it search in rows for common words and select them. or if there is a php way, please help me. |
How to optimize handling of list items Posted: 22 Jul 2021 07:57 AM PDT I have a list of items each containing of a start-point and an end-point. I want to run through the list and add an index on each member, so that the item with index 1 will be the item, where the start-point does not have a matching end-point in the list. The item with index 2, will be the item, where start-point matches item 1's end-point, and so on, until all items have an index. Is there an easy way to do this ? I only need to create the index-number, so I can sort my list prior to showing it on a listView. My source looks something like this right now : class lines { private string startPoint; private string endPoint; private int index = 0; } private static readonly List<lines> lineList = new List<lines>(); int aNumber = 0; foreach (var from in lineList ) { foreach (var to in lineList ) { if (to.startPoint == from.endPoint) { to.index = ++aNumber; } } } Data looks something like this before : startPoint endPoint index A B 0 C D 0 E F 0 D E 0 B C 0 The result after solving the problem would be : startPoint endPoint index A B 1 C D 3 E F 5 D E 4 B C 2 |
OpenIddict server with ClientCertificateMode.RequireCertificate and .well-known/openid-configuration endpoint Posted: 22 Jul 2021 07:58 AM PDT I have Openiddict secured with client certificates /smart cards and have RequireCertificate. The Resource (api) Server isn't able to hit the .well-known/openid-configuration endpoint since it does not have a client cert. The endpoints are secured with Openiddict. With AllowCertificate then it all works but I need to use RequireCertificate. I tried using just local validation but it still calls to the Auth Server Is there a way to not have the Resource server reach out to the Auth Server for the .well-known/openid-configuration endpoint or can I host the .well-known/openid-configuration endpoint on the Resource Server? //startup.cs public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddDbContext<DbContext>(options => { // Configure the context to use Microsoft SQL Server. options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), b => b.MigrationsAssembly("OpeniddictServerWindows")); // Register the entity sets needed by OpenIddict. // Note: use the generic overload if you need // to replace the default OpenIddict entities. options.UseOpenIddict(); }); // OpenIddict offers native integration with Quartz.NET to perform scheduled tasks // (like pruning orphaned authorizations/tokens from the database) at regular intervals. services.AddQuartz(options => { options.UseMicrosoftDependencyInjectionJobFactory(); options.UseSimpleTypeLoader(); options.UseInMemoryStore(); }); // Register the Quartz.NET service and configure it to block shutdown until jobs are complete. services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true); services.AddAuthentication( CertificateAuthenticationDefaults.AuthenticationScheme) .AddCertificate(options => { options.AllowedCertificateTypes = CertificateTypes.All; options.ValidateCertificateUse = false; options.Events = new CertificateAuthenticationEvents { OnAuthenticationFailed = context => { context.Fail("failed"); return Task.CompletedTask; }, OnCertificateValidated = context => { //TODO: validat cert if not expired and whatever else var cc = context.ClientCertificate; var claims = new[] { new Claim( ClaimTypes.NameIdentifier, context.ClientCertificate.Subject, ClaimValueTypes.String, context.Options.ClaimsIssuer), new Claim(ClaimTypes.Name, context.ClientCertificate.Subject, ClaimValueTypes.String, context.Options.ClaimsIssuer) }; context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); context.Success(); return Task.CompletedTask; } }; }); services.AddCors(options => { options.AddPolicy("AllowAllOrigins", builder => { builder .AllowCredentials() .WithOrigins( "http://localhost:4200" ) .SetIsOriginAllowedToAllowWildcardSubdomains() .AllowAnyHeader() .AllowAnyMethod(); }); }); // Configure Identity to use the same JWT claims as OpenIddict instead // of the legacy WS-Federation claims it uses by default (ClaimTypes), // which saves you from doing the mapping in your authorization controller. services.Configure<IdentityOptions>(options => { options.ClaimsIdentity.UserNameClaimType = Claims.Name; options.ClaimsIdentity.UserIdClaimType = Claims.Subject; options.ClaimsIdentity.RoleClaimType = Claims.Role; }); services.AddOpenIddict() // Register the OpenIddict core components. .AddCore(options => { // Configure OpenIddict to use the Entity Framework Core stores and models. // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities. options.UseEntityFrameworkCore() .UseDbContext<DbContext>(); // Enable Quartz.NET integration. options.UseQuartz(); }) // Register the OpenIddict server components. .AddServer(options => { //Enable the authorization and token endpoints. options.SetAuthorizationEndpointUris("/connect/authorize") //.SetIntrospectionEndpointUris("/connect/introspect") .SetTokenEndpointUris("/connect/token") .SetUserinfoEndpointUris("/connect/userinfo"); // Mark the "email", "profile", "roles" and "dataEventRecords" scopes as supported scopes. options.RegisterScopes(Scopes.Email, Scopes.Profile, Scopes.Roles, "api1"); // Note: this sample only uses the authorization code flow but you can enable // the other flows if you need to support implicit, password or client credentials. options.AllowAuthorizationCodeFlow() .AllowRefreshTokenFlow(); // Register the encryption credentials. This sample uses a symmetric // encryption key that is shared between the server and the Api2 sample // (that performs local token validation instead of using introspection). // // Note: in a real world application, this encryption key should be // stored in a safe place (e.g in Azure KeyVault, stored as a secret). //options.AddEncryptionKey(new SymmetricSecurityKey( // Convert.FromBase64String("DRjd/GnduI3Efzen9V9BvbNUfc/VKgXltV7Kbk9sMkY="))); var cert = CertificateUtility.LoadFromFile("C:\\certs\\AuthServerCert.pfx", "password"); options.AddEncryptionCertificate(cert); // Register the signing credentials. //options.AddDevelopmentEncryptionCertificate() // .AddDevelopmentSigningCertificate(); //used for local validation //options.AddEncryptionKey(new SymmetricSecurityKey( // Convert.FromBase64String("DRjd/GnduI3Efzen9V9BvbNUfc/VKgXltV7Kbk9sMkY="))); // Register the signing credentials. options.AddDevelopmentSigningCertificate(); // Force client applications to use Proof Key for Code Exchange (PKCE). options.RequireProofKeyForCodeExchange(); // Register the ASP.NET Core host and configure the ASP.NET Core-specific options. // // Note: unlike other samples, this sample doesn't use token endpoint pass-through // to handle token requests in a custom MVC action. As such, the token requests // will be automatically handled by OpenIddict, that will reuse the identity // resolved from the authorization code to produce access and identity tokens. // options.UseAspNetCore() .EnableStatusCodePagesIntegration() .EnableAuthorizationEndpointPassthrough() .EnableTokenEndpointPassthrough() .EnableUserinfoEndpointPassthrough() // During development, you can disable the HTTPS requirement. .DisableTransportSecurityRequirement(); options.IgnoreEndpointPermissions() .IgnoreScopePermissions(); options.DisableAccessTokenEncryption(); }) // Register the OpenIddict validation components. .AddValidation(options => { // Import the configuration from the local OpenIddict server instance. options.UseLocalServer(); // Register the ASP.NET Core host. options.UseAspNetCore(); }); // Register the worker responsible of seeding the database with the sample clients. // Note: in a real world application, this step should be part of a setup script. services.AddHostedService<Worker>(); } //Program.cs webBuilder.ConfigureKestrel(options => { options.ConfigureHttpsDefaults(q => { q.ClientCertificateMode = ClientCertificateMode.RequireCertificate; q.SslProtocols = SslProtocols.Tls12; }); }); |
How to extract data/labels back from TensorFlow dataset Posted: 22 Jul 2021 07:57 AM PDT there are plenty of examples how to create and use TensorFlow datasets, e.g. dataset = tf.data.Dataset.from_tensor_slices((images, labels)) My question is how to get back the data/labels from the TF dataset in numpy form? In other words want would be reverse operation of the line above, i.e. I have a TF dataset and want to get back images and labels from it. |
git push --mirror without pull refs Posted: 22 Jul 2021 07:56 AM PDT I'm migrating one git repo to another. To do this I'm using the --mirror flag for both the clone and push operations. This works, except for a failure at the end, causing my bash script to fail, which appears isolated to pull requests: ! [remote rejected] refs/pull/1/head -> refs/pull/1/head (The current action can only be performed by the system.) ! [remote rejected] refs/pull/1/merge -> refs/pull/1/merge (The current action can only be performed by the system.) ! [remote rejected] refs/pull/2/head -> refs/pull/2/head (The current action can only be performed by the system.) ! [remote rejected] refs/pull/3/head -> refs/pull/3/head (The current action can only be performed by the system.) Is it necessary to migrate pull requests? How can I omit the pull requests when I do git push --mirror ? I've seen references to modifying config files, but I'd prefer to handle it at the CLI if at all possible. |
Error while running query on solr slave Posted: 22 Jul 2021 07:58 AM PDT |
Better way to find last used row Posted: 22 Jul 2021 07:57 AM PDT I am trying to find the last row the same way I found the last column: Sheets("Sheet2").Cells(1,Sheets("Sheet2").Columns.Count).End(xlToLeft).Column I know this way but it is not as helpful as the prior would be: u = Sheets("Sheet1").Range("A65536").End(xlUp).Row I tried: Sheets("Sheet2").Cells(Sheets("Sheet2",1).Rowa.Count).End(xlToUP).Column Synopsis: I would like the below way for last row. Sheets("Sheet2").Cells(1,Sheets("Sheet2").Columns.Count).End(xlToLeft).Column |
Connect Azure RDP, "The logon attempt failed" Posted: 22 Jul 2021 07:57 AM PDT I've just created two Windows VM's in Azure, one 2012 Datacenter and a 2008 R2 SP1 and i am not able to connect via remote desktop to either of them. Both machines are running under the same cloud service and the RDP ports are mapped to two distinct public ports. Every time i try to connect i get the error message "The logon attempt failed". Using NMAP in a Linux VM i also have there, i was able to check that the port 3389 is OPEN in both machines. Also, the public RDP ports respond correctly (e.g. are open). I tried to enter using two different Windows 7 client machines, also with no lock. MSTSC version is 6.3.9600.16415, in both machines. I've used both the .rdp file, downloaded from the "Connect" option in the windows azure dashboard and a brand new RDP connection created by me - same result. I've tried also to upgrade the VM size from small (1 core, 1.5 GBRam) to medium (2 cores, 3.6 GBRam), restart, setup a new clean windows VM, with different credentials... nothing changed, same result. The really odd thing is that i was able to connect, after several failed attempts, to one of the VM's, the 2012 one, but only one time - after that, no luck, always "The login attempt failed". |
How do you stop MySQL on a Mac OS install? Posted: 22 Jul 2021 07:56 AM PDT I installed MySQL via MacPorts. What is the command I need to stop the server (I need to test how my application behave when MySQL is dead)? |
No comments:
Post a Comment