w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Bell chart with PHP
Simple bell curve for ($x = -M_PI; $x <= M_PI; $x += (M_PI / 20)) { echo sprintf('%+01.2f => %01.8f' . PHP_EOL, $x, (cos($x) + 1) / 2); } But please explain your three inputs: that would be expected for a Gaussian curve, with mean, standard deviation and X value. A bell curve is a special case of a Gaussian with a mean of 0 and a standard deviation of 1, so only the X value is variable.

Categories : PHP

bell in Emacs shell
I was able to get the bell to beep when control-G characters are sent to the shell by evaluating this code: (defun beep-on-alert-char (str) (if (string-match-p "x7" str) (beep))) (add-hook 'comint-output-filter-functions 'beep-on-alert-char)

Categories : Shell

Server alarm bell
I'm assuming that your server is *nix, as you're mentioning cronjobs. You can find bash scripts doing exactly this functionality, if you google it. Here's a bash script which checks for specific services and sends emails if a service is down: http://bash.cyberciti.biz/monitoring/simple-process-checker-script/ You just need to tweak the _chklist, _sendemail and _email variables to suit your needs

Categories : Python

Is there any modern use for the bell character (a)
Back in the dark ages when ASCII was codified out of the ashes of BAUDOT, a terminal was a large chunk of iron that hammered ink onto paper, often included a paper tape punch and reader, and interpreted keystrokes to generate an asynchronous serial signal at a few hundred baud with spinning wheels and relays. In case an operator fell asleep to the soothing noises of it hammering out text, it had an actual bell it could ring. The character coded 007 in octal, 0x07 in hex, or as a in a C character or string constant rang the bell when received. As terminals became smaller and implemented with few or no moving parts, the physical bell was replaced by a beeper. Exactly what your terminal emulator (aka a Console Window in Windows, xterm or something similar in Unix) does when it is asked to

Categories : Java

Target a bell character with a regular expression
In your IF statement, you can search for either a (you have that in there already and it returns true) or the u2407 character, which matches the bell unicode character.

Categories : Javascript

Bell Curve algorithm to adjust set of scores
You usually assume that your data fit a distribution instead of transforming your data into a given distribution. If your input data fit a normal distribution ("bell curve"), then you can adjust by simply add/remove the same value from all the sample. The distribution will be preserved, only the mean will change. If you want to center your distribution on a given mean, just add the difference between your target mean and the actual one.

Categories : C#

how to create bell graph using google charts or any other charts and fill multiple colors inside the curve
If you want "strange" graphics, I recomend you to create yourself the SVG file: Google charts draw images using vectorial images in SVG format. SVG format is a XML/DOM format that you may edit dynamically using Javascript DOM functions (like for HTML). You have 2 options: Use the Google charts and edit the resulting image. Create yourself all the charts. You may find an introductory tutorial for SVG format at: www.w3schools.com

Categories : Javascript

Renaming zip to match it's contents using PowerShell
This should help you here's a function to get the name of the zip file based on your requirements, just pass it the location of your log files: function Get-ZipFileName { param ($logPath) # Get a list of files, remove the extension and split on the hyphen, # # then take the second part of the array $filenames = gci -Path $logPath -Filter "*.log" | % { $($_.Basename -split "-")[1] } # Get the first item in the now sorted list $first = $filenames | Sort-Object | Select-Object -First 1 # Get the first item in the sorted list, now descending to get the last $last = $filenames | Sort-Object -descending | Select-Object -First 1 # return the filename "log-{0} - {1}" -f $first, $last } I would suggest you look at using a slightly different date

Categories : Powershell

Powershell Regular Expressions getting values out of a -replace match
Split the string and cast valid values to integers. function doubleIt($digits = "1 2 3 4 5") { #[string](-split $digits -as [int[]] | ForEach-Object {$_*2}) [string](-split $digits | where {$_ -as [int]} | foreach {2*$_} ) }

Categories : Regex

Excel 2007 VBA MATCH function is not finding a match, but a match does exist in that range?
You must use MatchType of 0 to use wild card characters (* or ?) see: http://office.microsoft.com/en-001/excel-help/match-function-HP010062414.aspx Use Application.Match("More items related to*", Range("AZ1:AZ1000"), 0)

Categories : Excel

Why would installing Azure SDK 2.1 or powershell 3 on the build server break some of our tests which run in powershell?
Have you tried passing a fully qualified path to startInfo.FileName instead of just Powershell.exe incase there's a problem with %PATH% since the update Complete total guess, but any chance your running into FileSystemRedirector 32 vs. 64 issues as seen in this answer - Process.Start(): The system cannot find the file specified, but my file path seems to be legit

Categories : Powershell

Executing Powershell script as different User in Exchange 2007 Powershell
I just found out that executing Remote Powershell Commands/Skripts is not supported with Exchange 2007 (http://howexchangeworks.com/2009/11/exchange-2007-sp2-supports-powershell.html). So I need to wait until the upgrade to 2013. Some workarounds: http://social.technet.microsoft.com/Forums/en-US/exchangesvrgeneral/thread/4596035a-cede-4541-8b8e-e2e9bf1b40dc Or: http://peerfect.blogspot.co.at/2012/10/re-blog-of-my-exchange-remote.html

Categories : Powershell

Add Powershell Snapin for Powershell Module and Import Multiple Times
You might want to try to specify this module required by your own module through a module manifest (.psd1). See RequiredModules here.

Categories : Powershell

PowerShell Community Extensions not Recognized by TeamCity PowerShell Runner
Do you import the PSCX module in your script? PowerShell v3 will cache the module info after you have done this once so you don't need to import it again. However if TeamCity is running the 64-bit console and you normally run the 32-bit console, then the 64-bit console wouldn't have PSCX commands in the command cache. Anyway, it is a good practice to have your scripts explicitly require the modules it depends upon e.g. #requires -Modules Pscx

Categories : Powershell

How to use powershell variable in PowerShell.AddParameter method in C#?
The variable won't be available until you invoke the first script. Try this: ps.AddScript("$backupFile = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(),'{0}.bak')".FormatInvariant(databaseName)); ps.Invoke(); ps.Commands.Clear(); var backupFile = ps.Runspace.SessionStateProxy.PSVariable.Get("backupFile"); ps.AddCommand("New-Item") .AddParameter("Force") .AddParameter("ItemType", "File") .AddParameter("Path", backupFile )); ps.Invoke(); If you go this route though, I don't think you can use the RunspacePool because you're likely to get different runspaces between each Invoke(). In that case, the variable won't be available to the other runspace. Do you really need to use the RunspacePool in this scenario? If you do then why not just do the first bit in C#: var backup

Categories : C#

Powershell Script that will login into powershell for office 365
For the exchange powershell use: $SecPass1 = convertto-securestring -asplaintext -string "PasSword" -force $MSOLM = new-object System.Management.Automation.PSCredential -argumentlist "GlobalAdmin@some.com",$SecPass1 $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $MSOLM -Authentication Basic -AllowRedirection Import-Module MSOnline Import-PSSession $Session –AllowClobber

Categories : Actionscript

How do I return value or object from C# powershell command to Powershell
You have to use the CmdLet.WriteObject method. Here a good explanation from @RomanKuzmin.

Categories : Powershell

Powershell Start-Process to start Powershell session and pass local variables
I'm pretty sure there's no direct way to pass variables from one PowerShell session to another. The best you can do is some workaround, like declaring the variables in the code you pass in -ArgumentList, interpolating the values in the calling session. How you interpolate the variables into the declarations in -ArgumentList depends on what types of variables. For an array and a string you could do something like this: $command = '<contents of your scriptblock without the curly braces>' Start-Process powershell -ArgumentList ("`$Array = echo $Array; `$String = '$String';" + $command)

Categories : Powershell

Regex to match paths that don't match a specific pattern: Express Router
The following regex will match any path except those starting with /foo/ app.get(/^/([^f][^o][^o]|.{1,2}|.{4,})/.*$/, routes.index); I assume that this is a standard javascript regex.

Categories : Regex

How to boost results in elasticsearch, so that match in field1 is always higher then match in field2?
Have you tried setting use_dis_max to be false? This should mean that a doc with "small" in category and title would be higher than a doc with "small" in just the category. As for the strange behaviour you are seeing between the 2nd and 3rd results, I am a bit lost... Can you do the query and ask for the explanation of how the scores were calculated?

Categories : Elasticsearch

Excel VBA: Can't get a match, error "Unable to get the Match property of the WorksheetFunction class"
Use the Application.Match function which allows for better ability to trap errors. When using the WorksheetFunction.Match, when a match is not found, it returns an error, which is what you're experiencing. If Not IsError(Application.Match(Cells(e, 1).Value, myrange, 0)) Then 'Do stuff when the match is found Cells(e, 3).Value = "Yes" Else: Cells(e, 3).Value = "No" End If You could also potentially use the CountIf function: If Application.WorksheetFunction.CountIf(myRange, Cells(e,1).Value) > 0 Then Cells(e,3).Value = "Yes" Else: Cells(e,3).Value = "No" End If Neither of these approaches requires you to use the m1 variable, you can assign this variable within the True part of the If/Then statement, if you need to identify where the match is found.

Categories : Excel

Merge two data frame on one exact match and one partial URL match
You can put your data in the long format and then process by ID within a data.table . library(reshape2) dat <- do.call(rbind,lapply(list(pattern,dataset),function(x) melt(x,id.vars='SessionId'))) library(data.table) DT <- data.table(dat,key='SessionId') DT[,if(.N ==2) if(length(grep(value[1],value[2]))>0) as.list(value) ,by='SessionId'] SessionId V1 V2 1: 5b8cc8794a02ba868db21faef1 somewebsite.com/abc/detail/110302288511/ somewebsite.com/abc/detail/110302288511/110302288512/ 2: 5b8cc8794a02ba868db21faef3 somewebsite.com/abc/detail/110302288513/ somewebsite.com/abc/detail/110302288513/1103022815/ EDIT benchmarking the 2 solutio

Categories : R

Javascript string.match refuses to return an array of more than one match
You're looking for the form needle.exec(haystack) From my console: > haystack = "{List:[Names:a,b,c][Ages:1,2,3]}"; "{List:[Names:a,b,c][Ages:1,2,3]}" > needle = /^{List:[Names:([a-zA-z,]*)][Ages:([0-9,]*)]}$/g ; /^{List:[Names:([a-zA-z,]*)][Ages:([0-9,]*)]}$/g > needle.exec(haystack); ["{List:[Names:a,b,c][Ages:1,2,3]}", "a,b,c", "1,2,3"]

Categories : Javascript

Should I expect to have exactly same match everytime I run the match with greedy algorithm?
"Greedy" doesn't necessarily mean "deterministic," in particular if you have two choices with equal weight/value then it may be possible to first select one choice during one algorithm execution and to first select the other choice on another algorithm execution.

Categories : Algorithm

PHP MySQL query: match two tables with percentage match
Try below: SELECT e_id, e.skill, c.skill, (e.points/c.points)*100 from employee_skills as e, company_skills as c WHERE e.skill = c.skill GROUP BY e.e_id,e.skill See below: SELECT c.skill, total_emp_points, c.points as total, (total_emp_points/c.points)*100 as percnt FROM company_skills AS c, (SELECT e.skill, SUM(e.points) as total_emp_points FROM employee_skills as e GROUP BY e.skill) as emp WHERE c.skill = emp.skill; see SqlFiddle

Categories : PHP

Regex to match only till first occurence of class match
You were missing ? Your regex would be (?i)(.*?)case[^a-zd]*(d+)(.*) You can toggle case insensitive match using (?i) in regex

Categories : Regex

compare 2 tables if match update if not match insert
The easiest way is a MERGE statement: MERGE INTO Table_B USING Table_A ON TableA.ID1 = Table_B.ID1 AND TableA.ID2 = Table_B.ID2 AND TableA.ID3 = Table_B.ID3 WHEN MATCHED THEN UPDATE SET A = Table_A.A, B = Table_A.B -- Etcetera... WHEN NOT MATCHED THEN INSERT (A, B) VALUES (Table_A.a, Table_A.B) -- Etcetera... WHEN NOT MATCHED BY SOURCE THEN DELETE -- If Necessary... ; By the way, don't forget the ";" at the end. SQL Server doesn't usually need them, but a MERGE does.

Categories : Sql Server

Extracting both the full match, and the last token match in a regexp
I guess you could use this regex: =hyperlink("([@\ws()-./]+\([^"]+))") And this new replace: <a href="file:///$1">$2</a> I'm not sure how your regex was working, but I added the quotes in the regex and replaced the single quotes by double quotes in the replace. Revert those if need be. Demo

Categories : Javascript

Scala, how to access the whole match: X match {case Y(z) as matched =>
You should be able to use the @ syntax: x match { case matched @ Y(z) => // do stuff both with "matched" and "z" here ... ... } From here

Categories : Scala

javascript password match if not match show in innerHTML
Add a div to store your password validation response to the document like <div id='validate'></div> and then after you have checked for passwords match, you can display the appropriate result in the html of this div document.getElementById('validate').innerHTML="passwords do not match!";

Categories : Javascript

Unable to connect to Windows Azure from Powershell Azure Powershell module
To see is there some result from Import-AzurePublishSettingsFile you can call: Get-AzureSubscription By default it select the default to current subscription. If you don't see any result then you don't import your subscription settings right. This Introduction to Windows Azure PowerShell also can help you.

Categories : Windows

Regex that match if the match contains special word
You're kind of on the right track with lookahead assertions: {{START}}(?:(?!{{END}})[sS])*specialword(?:(?!{{END}})[sS])*{{END}} Explanation: {{START}} # Match {{START}} (?: # Match... (?!{{END}}) # ...as long as we haven't reached {{END}} yet: [sS] # any character )* # any number of times. specialword # Match "specialword" (?: # Match (as before)... (?!{{END}}) # whatever follows, unless it's {{END}} [sS] )* {{END}} # Then finally match {{END}}

Categories : Regex

Regex - Find the match that is inside a match
You can try this regex: /href=[^>]+.pdf/ regex101 demo Most of the time, when you can avoid .* or .+ (or their lazy versions), it's better :) Also, don't forget to escape periods.

Categories : PHP

Invoke one PowerShell script from Another PowerShell script with passing arguments
PS C:> gc . est2.ps1 . est1.ps1 'foo' Write-Host 'bar' PS C:> gc . est1.ps1 $a = $ARGS[0] -split '' [array]::Reverse($a) Write-Host ($a -join '') PS C:> . est2.ps1 oof bar

Categories : Powershell

Regex.Match() won't match a substring
Try removing ^ and $: Regex regex = new Regex(@"[ABCEGHJKLMNPRSTVXY]{1}d{1}[A-Z]{1} *d{1}[A-Z]{1}d{1}", RegexOptions.None); ^ : The match must start at the beginning of the string or line. $ : The match must occur at the end of the string or before at the end of the line or string. If you want to match only in word boundaries you can use  as suggested by Mike Strobel: Regex regex = new Regex(@"[ABCEGHJKLMNPRSTVXY]{1}d{1}[A-Z]{1} *d{1}[A-Z]{1}d{1}", RegexOptions.None);

Categories : C#

regex not returning match but there is clearly a match
You need to escape the dollar sign. start = '>$' end = '</td>' AnnualDiv = re.search('%s(.*)%s' % (start, end), s).group(1) The reason is that the $ is a special character in regex. (It matches the end of a string or before the newline.) This will set AnnualDiv to the string '0.48'. If you want to add the $, you can do it using this: AnnualDiv = "$%s" % re.search('%s(.*)%s' % (start, end), s).group(1)

Categories : Python

Exact match, then partial match
You need to aggregate your data by entry and then apply the order conditions: select entry_id from posts group by entry_id order by max(category_id = 50) + max(category_id = 56) desc The expression max(category_id = 50) returns 1 if category 50 is in the mix (for the entry) and 0 otherwise. By adding these two expressions together, you get the number of category matches. If you care about the order of the singleton matches (as suggested by the question), then do: select entry_id from posts group by entry_id order by max(category_id = 50) + max(category_id = 56) desc, max(category_id = 50) desc, max(category_id = 56) desc EDIT: If you store your available categories in a comma delimited list, then you can have the best of all worlds. You can order by the number o

Categories : Mysql

Looking for non-zero property TOs: Can I match a Description with number property, but use a regex match?
It is known that integer types has to be passed as integers in the description rendering the usage of regular expressions useless unfortunately. I do not have a QTP installation at hand right now, but to investigate it further, what happens if you use Print Browser("myBrowser").WebElement("height:=11").ChildObjects.Count and Print Browser("myBrowser").WebElement("height:=^[1-9][0-9]*$").ChildObjects.Count Where "myBrowser" is your browser definition of course.

Categories : Regex

extract file content from match pattern to another match pattern
With awk: awk '/> myoccupation/,/> mygrosssalary/' file With sed: sed -n '/> myoccupation/,/> mygrosssalary/p' file And you can use output redirection to create another file, with comand ... > newfile

Categories : Linux

How to get first possible match using preg match in php
Short answer: Yes you can. You need to use lazy quantifiers. So instead of preg_match("/[[test.*]]/i",$str,$match); use preg_match("/[[test.*?]]/i",$str,$match); to make the function stop at the first match. Note: if you want to match a literal [ or ]charactor you need to escape them like: [ or ]. After a little reaserch on php.net I discovered a pattern modifier U (PCRE_UNGREEDY) that will set the default for the pattern to lazy as apposed to greedy. So this means that preg_match("/[[test.*]]/iU",$str,$match); will also suit for this purpose. A note for this though: All *, +, ? in the regex will now try to match as few characters as possible.

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.