Posts

Showing posts from March, 2017

Codemirror Mode Cdn Code Example

Example: codemirror cdn < script src = " https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.js " > </ script > < link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.css " />

Bash Ping Script File For Checking Host Availability

Answer : I would use this, a simple one-liner: while ! ping -c1 HOSTNAME &>/dev/null; do echo "Ping Fail - `date`"; done ; echo "Host Found - `date`" ; /root/scripts/test1.sh Replace HOSTNAME with the host you are trying to ping. I missed the part about putting it in the background, put that line in a shellscript like so: #!/bin/sh while ! ping -c1 $1 &>/dev/null do echo "Ping Fail - `date`" done echo "Host Found - `date`" /root/scripts/test1.sh And to background it you would run it like so: nohup ./networktest.sh HOSTNAME > /tmp/networktest.out 2>&1 & Again replace HOSTNAME with the host you are trying to ping. In this approach you are passing the hostname as an argument to the shellscript. Just as a general warning, if your host stays down, you will have this script continuously pinging in the background until you either kill it or the host is found. So I would keep that in mind when y

Browser Says "Camera Blocked To Protect Your Privacy"

Answer : type url chrome://flags/#unsafely-treat-insecure-origin-as-secure Enter url in the textarea Choose Enabled in the select option Click image link bellow to see detail example Chrome blocks vulnerable features—including camera, location, microphone, etc. on non-secure sites. As of July 2018, with the release of Chrome 68, Chrome starts to mark all HTTP sites as "not secure." You have three options to unblock these features for your site: Treat 192.168.10.79 as secure origins by setting chrome://flags/#unsafely-treat-insecure-origin-as-secure . Origins must have their protocol specified, e.g., http://192.168.10.79 . Port forwarding your site address to localhost . Chrome treats localhost as secure origins. Set up a self-signed certificate for the server.

Check If A Windows Service Exists And Delete In PowerShell

Answer : You can use WMI or other tools for this since there is no Remove-Service cmdlet until Powershell 6.0 (See Remove-Service doc) For example: $service = Get-WmiObject -Class Win32_Service -Filter "Name='servicename'" $service.delete() Or with the sc.exe tool: sc.exe delete ServiceName Finally, if you do have access to PowerShell 6.0: Remove-Service -Name ServiceName There's no harm in using the right tool for the job, I find running (from Powershell) sc.exe \\server delete "MyService" the most reliable method that does not have many dependencies. If you just want to check service existence: if (Get-Service "My Service" -ErrorAction SilentlyContinue) { "service exists" }

Array.sum Javascript Code Example

Example 1: array sum javascript const arr = [ 1 , 2 , 3 , 4 ] ; const sum = arr . reduce ( ( a , b ) => a + b , 0 ) ; // sum = 10 Example 2: js sum of array [ 1 , 2 , 3 , 4 ] . reduce ( ( a , b ) => a + b , 0 ) // Output: 10 Example 3: javascript sum of array const sum = arr => arr . reduce ( ( a , b ) => a + b , 0 ) ; Example 4: add all elements in array javascript console . log ( [ 1 , 2 , 3 , 4 ] . reduce ( ( a , b ) => a + b , 0 ) ) console . log ( [ ] . reduce ( ( a , b ) => a + b , 0 ) ) Example 5: sum of all numbers in an array javascript const arrSum = arr => arr . reduce ( ( a , b ) => a + b , 0 ) Example 6: javascript sum array values function getArraySum ( a ) { var total = 0 ; for ( var i in a ) { total += a [ i ] ; } return total ; } var payChecks = [ 123 , 155 , 134 , 205 , 105 ] ; var weeklyPay = getArraySum ( payChecks ) ;

C Malloc Array Pointer Code Example

Example: c allocate array int * array = malloc ( 10 * sizeof ( int ) ) ;

Change Upi Id In Google Pay Code Example

Example: reset upi id reset upi id

Center Align Paragraph Html Code Example

Example 1: html center text <div style= "text-align:center" >Dieser Text wird zentriert. <p>Ebenso dieser Paragraph.</p></div> Example 2: center p html <p style= "text-align: center" >this is centered</p> Example 3: how to center text in html text-align : center ; Example 4: html center text <center>Dieser Text wird zentriert. <p>Ebenso dieser Paragraph.</p></center>

Array Filter Is Numbering In Php Code Example

Example 1: php array filter syntax $numbers = [ 2 , 4 , 6 , 8 , 10 ] ; function MyFunction ( $number ) { return $number > 5 ; } $filteredArray = array_filter ( $numbers , "MyFunction" ) ; /** * `$filteredArray` now contains: `[6, 8, 10]` * NB: Use this to remove what you don't want in the array * @see `array_map` when you want to alter/change elements * in the array. */ Example 2: how can use filter in php7.2 Odd : Array ( [ a ] => 1 [ c ] => 3 [ e ] => 5 ) Even : Array ( [ 0 ] => 6 [ 2 ] => 9 [ 4 ] => 10 [ 6 ] => 12 )

C Max Integer Value Code Example

Example: max size for int c - 2 , 147 , 483 , 648 to 2 , 147 , 483 , 647

CGRectMake, CGPointMake, CGSizeMake, CGRectZero, CGPointZero Is Unavailable In Swift

Answer : CGRect Can be simply created using an instance of a CGPoint or CGSize , thats given below. let rect = CGRect(origin: CGPoint(x: 0,y :0), size: CGSize(width: 100, height: 100)) // Or let rect = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) Or if we want to specify each value in CGFloat or Double or Int , we can use this method. let rect = CGRect(x: 0, y: 0, width: 100, height: 100) // CGFloat, Double, Int CGPoint Can be created like this. let point = CGPoint(x: 0,y :0) // CGFloat, Double, Int CGSize Can be created like this. let size = CGSize(width: 100, height: 100) // CGFloat, Double, Int Also size and point with 0 as the values, it can be done like this. let size = CGSize.zero // width = 0, height = 0 let point = CGPoint.zero // x = 0, y = 0, equal to CGPointZero let rect = CGRect.zero // equal to CGRectZero CGRectZero & CGPointZero replaced with CGRect.zero & CGPoint.zero in Swift 3.0 . Quick fix for CGRectMake ,

Adding VirtualHost Fails: Access Forbidden Error 403 (XAMPP) (Windows 7)

Answer : Okay: This is what I did now and it's solved: My httpd-vhosts.conf looks like this now: <VirtualHost dropbox.local:80> DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs" ServerName dropbox.local ErrorLog "logs/dropbox.local-error.log" CustomLog "logs/dropbox.local-access.log" combined <Directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"> # AllowOverride All # Deprecated # Order Allow,Deny # Deprecated # Allow from all # Deprecated # --New way of doing it Require all granted </Directory> </VirtualHost> First, I saw that it's necessary to have set the <Directory xx:xx> options. So I put the <Directory > [..] </Directory> -part INSIDE the <VirtualHost > [..] </VirtualHost> . After that, I added AllowOverride AuthConfig Indexes to the <Directory> options. Now htt

Apache2: 'AH01630: Client Denied By Server Configuration'

Image
Answer : If you are using Apache 2.4 You have to check allow and deny rules Check out http://httpd.apache.org/docs/2.4/upgrading.html#access In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy. In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host. The new directive is Require: 2.2 configuration: Order allow,deny Allow from all 2.4 configuration: Require all granted Also don't forget to restart the apache server after these changes ( # service httpd restart ) For all directories write Require all granted instead of Allow from all Update If the above doesn't work then also remove this below mentioned line: Order allow,deny Double check that the DocumentRoot path is correct. That can cause this error.

Calculate The Value For The Following Improper Integral

Answer : Question 1: your way is not correct (reason: see my answer to question 2). Question 2: ∫ 0 ∞ \int_0^{\infty} ∫ 0 ∞ ​ is convergent    ⟺    \iff ⟺ the integrals ∫ 0 1 , ∫ 1 3 / 2 \int_0^{1},\int_{1}^{3/2} ∫ 0 1 ​ , ∫ 1 3/2 ​ and ∫ 3 / 2 ∞ \int_{3/2}^{\infty} ∫ 3/2 ∞ ​ are all convergent. Now show that ∫ 0 1 d x 2 x 2 − 5 x + 3 \int_0^{1}\frac{dx}{2x^2-5x+3} ∫ 0 1 ​ 2 x 2 − 5 x + 3 d x ​ is divergent ! Conclusion: ∫ 0 ∞ d x 2 x 2 − 5 x + 3 \int_0^{\infty}\frac{dx}{2x^2-5x+3} ∫ 0 ∞ ​ 2 x 2 − 5 x + 3 d x ​ is divergent.

Bootstrap Collapse Not Working Properly (Hide Not Working)

Answer : Your code works! but, It doesn't work properly without jquery. <!DOCTYPE html> <html lang="en"> <head> <title>Title</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <a href="#demo" data-toggle="collapse"><span class=”icon”>Collapsible</span></a> <div id="demo" class="collapse"> Sample Code </div> </div> </body>

Automatically And Elegantly Flatten DataFrame In Spark SQL

Answer : The short answer is, there's no "accepted" way to do this, but you can do it very elegantly with a recursive function that generates your select(...) statement by walking through the DataFrame.schema . The recursive function should return an Array[Column] . Every time the function hits a StructType , it would call itself and append the returned Array[Column] to its own Array[Column] . Something like: import org.apache.spark.sql.Column import org.apache.spark.sql.types.StructType import org.apache.spark.sql.functions.col def flattenSchema(schema: StructType, prefix: String = null) : Array[Column] = { schema.fields.flatMap(f => { val colName = if (prefix == null) f.name else (prefix + "." + f.name) f.dataType match { case st: StructType => flattenSchema(st, colName) case _ => Array(col(colName)) } }) } You would then use it like this: df.select(flattenSchema(df.schema):_*) I am improving my previous a

Bootstrap Input Pretty Code Example

Example 1: bootstrap 4 forms < form > < div class = " form-group row " > < label for = " staticEmail " class = " col-sm-2 col-form-label " > Email </ label > < div class = " col-sm-10 " > < input type = " text " readonly class = " form-control-plaintext " id = " staticEmail " value = " email@example.com " > </ div > </ div > < div class = " form-group row " > < label for = " inputPassword " class = " col-sm-2 col-form-label " > Password </ label > < div class = " col-sm-10 " > < input type = " password " class = " form-control " id = " inputPassword " placeholder = " Password " > </ div > </ div > </ form > Example 2: bootstrap forms < form > <

Curl Basic Auth Header Code Example

Example 1: curl authorization header curl - H "Authorization: token_str" http : / / www.example. com Example 2: curl with basic auth curl - u username : password http : / / curl - u username http : / / Example 3: basic authentication bash $ echo - n user : password | base64

Com Fazer A Raiz Quadrada Em C++ Code Example

Example: com fazer a raiz quadrada em c++ #include <stdlib.h> #include <stdio.h> #include <math.h> / * square root of a number * / int main ( ) { float num , raiz ; printf ( "enter a number: \t" ) ; scanf ( "%f" , & num ) ; raiz = sqrt ( num ) ; printf ( "The square root of %f is: %f.\n" , num , raiz ) ; system ( "pause" ) ; return 0 ; }

Can I Adjust The Aspect Ratio On A Nintendo Switch To Display On A 4:3 Monitor?

Answer : No , it doesn't seem so. It seems Nintendo imagined that people would only connect to 16:9 displays and did not add any options in the Switch display settings. I have been having the same trouble for months. I have my switch hooked up to a 4:3 CRT TV via HDMI to RCA converter. It may be possible to find an adapter that can translate the image to show at a proper aspect.

Codigo Ascii Code Example

Example 1: ascii Reference Ascii Table Dec Char Dec Char Dec Char Dec Char --------- --------- --------- ---------- 0 NUL (null) 32 SPACE 64 @ 96 ` 1 SOH (start of heading) 33 ! 65 A 97 a 2 STX (start of text) 34 " 66 B 98 b 3 ETX (end of text) 35 # 67 C 99 c 4 EOT (end of transmission) 36 $ 68 D 100 d 5 ENQ (enquiry) 37 % 69 E 101 e 6 ACK (acknowledge) 38 & 70 F 102 f 7 BEL (bell) 39 ' 71 G 103 g 8 BS (backspace) 40 ( 72 H 104 h 9 TAB (horizontal tab) 41 ) 73 I 105 i 10 LF (NL line feed, new line) 42 * 74 J 106 j 11 VT (vert

Apache: Client Denied By Server Configuration

Answer : Apache 2.4.3 (or maybe slightly earlier) added a new security feature that often results in this error. You would also see a log message of the form "client denied by server configuration". The feature is requiring an authorized user identity to access a directory. It is turned on by DEFAULT in the httpd.conf that ships with Apache. You can see the enabling of the feature with the directive Require all denied This basically says to deny access to all users. To fix this problem, either remove the denied directive (or much better) add the following directive to the directories you want to grant access to: Require all granted as in <Directory "your directory here"> Order allow,deny Allow from all # New directive needed in Apache 2.4.3: Require all granted </Directory> OK I am using the wrong syntax, I should be using Allow from 127.0.0.1 Allow from ::1 ... In Apache 2.4 the old access authorisation syntax has been depr

How To Uninstall Anaconda In Ubuntu 18.04 Code Example

Example 1: delete conda from machine conda install anaconda - clean # install the package anaconda clean anaconda - clean -- yes # clean all anaconda related files and directories rm - rf ~ / anaconda3 # removes the entire anaconda directory rm - rf ~ / . anaconda_backup # anaconda clean creates a back_up of files / dirs , remove it # ( conda list ; cmd shouldn ' t respond after the clean up ) Example 2: uninstall anaconda ubuntu # Install anaconda - clean conda install anaconda - clean # start anaconda - clean anaconda - clean -- yes