In computing, netstat (network statistics) is a command-line network utility tool that displays network connections for the Transmission Control Protocol (both incoming and outgoing), routing tables, and a number of network interface (network interface controller or software-defined network interface) and network protocol statistics.
List out all connections
The most simple command is to list out all the current connections by using: netstat -a
Example:
1 2 3 4 5 6 7 8 9
$ netstat -a
Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 enlightened:domain *:* LISTEN tcp 0 0 localhost:ipp *:* LISTEN tcp 0 0 enlightened.local:54750 li240-5.members.li:http ESTABLISHED tcp 0 0 enlightened.local:49980 del01s07-in-f14.1:https ESTABLISHED tcp6 0 0 ip6-localhost:ipp [::]:* LISTEN
Get process name/pid and user id
When viewing the open/listening ports and connections, its often useful to know the process name/pid which has opened that port or connection. You can use the following command: sudo netstat -nlpt
Example:
1 2 3 4 5 6
~$ sudo netstat -nlpt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 1144/dnsmasq tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 661/cupsd tcp6 0 0 ::1:631 :::* LISTEN 661/cupsd
04/04 21:51:30 [^[[1;31mERROR^[[0m] IPv4 RPC: failed to bind TCP port 6800 Exception: [SocketCore.cc:312] errorCode=1 Failed to bind a socket, cause: Address already in use
04/04 21:51:30 [^[[1;31mERROR^[[0m] IPv6 RPC: failed to bind TCP port 6800 Exception: [SocketCore.cc:312] errorCode=1 Failed to bind a socket, cause: ai_family not supported
Get the coordinates of the place you want to go. In this example, I want to simulate Reykjavik Airport in Iceland, which is 64.131933, -21.948947. You can easily find it in Google Maps.
Change latitude and longitude settings
Find heaven.gpx file in repository folder, and find code <wpt lat="64.131933" lon="-21.948947">. Change whereever you want to go.
Install in your iPhone
Change the project settings in upper left corner. Find Produce --> Scheme --> Eidt Scheme --> Options, change Default Location to heaven, and choose device to your iPhone. Install it!
Check it out
Open Google Maps, and you will find GPS is already changed to the location you set. Have fun!
On February 2, 2016, Github posted an article about an update in Github Page. Basically, it will run Jekyll 3.0 in Github Page, and the major impact are below:
GitHub Pages will only support kramdown, Jekyll’s default Markdown engine.
GitHub Pages now only supports Rouge.
Local builds are significantly faster.
If you are building your website under Github Page, or even use Jekyll 3.0 to build directly, the main problem is that the old highlight function is no long workable. This post is gonna talk about how to use Rouge highlight under Jekyll 3.0.
Configuration setting
First of all, change some settings in your _config.yml. markdown will use kramdown, highlighter will use rouge, also change syntax_highlighter to rouge. Below is the code:
A common form of lorem ipsum reads below with words altered, added, and removed to make it nonsensical, improper Latin.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
I’m exploring tvOS and I found that Apple offers nice set of templates written using TVML. I’d like to know if a tvOS app that utilises TVML templates can also use UIKit.
Can I mix UIKit and TVMLKit within one app?
Answer One
Yes, you can. Displaying TVML templates requires you to use an object that controls the JavaScript Context: TVApplicationController.
1
var appController: TVApplicationController?
This object has a UINavigationController property associated with it. So whenever you see fit, you can call:
1 2
let myViewController = UIViewController() self.appController?.navigationController.pushViewController(myViewController, animated: true)
This allows you to push a Custom UIKit viewcontroller onto the navigation stack. If you want to go back to TVML Templates, just pop the viewController off of the navigation stack.
If what you would like to know is how to communicate between JavaScript and Swift, here is a method that creates a javascript function called pushMyView()
//allows us to access the javascript context appController?.evaluateInJavaScriptContext({(evaluation: JSContext) -> Voidin
//this is the block that will be called when javascript calls pushMyView() let pushMyViewBlock : @convention(block) () -> Void = { () -> Voidin
//pushes a UIKit view controller onto the navigation stack let myViewController = UIViewController() self.appController?.navigationController.pushViewController(myViewController, animated: true) }
//this creates a function in the javascript context called "pushMyView". //calling pushMyView() in javascript will call the block we created above. evaluation.setObject(unsafeBitCast(pushMyViewBlock, AnyObject.self), forKeyedSubscript: "pushMyView") }, completion: {(Bool) -> Voidin //done running the script }) }
Once you call createPushMyView() in Swift, you are free to call pushMyView() in your javascript code and it will push a view controller onto the stack.
Answer Two
If you already have a native UIKit app for tvOS, but would like to extend it by using TVMLKit for some part of it, You can.
Use the TVMLKit as a sub app in your native tvOS app. The following app shows how to do this, by retaining the TVApplicationController and present the navigationController from the TVApplicationController. The TVApplicationControllerContext is used to transfer data to the JavaScript app, as the url is transferred here :
// Get the JS context and send it the url to use in the JS app let hostedContContext = TVApplicationControllerContext() iflet url = URL(string: ViewController.tvBootURL) { hostedContContext.javaScriptApplicationURL = url }
// Save an instance to a new Sub application, the controller already knows what window we are running so pass nil appController = TVApplicationController(context: hostedContContext, window: nil, delegate: self)
// Get the navigationController of the Sub App and present it let navc = appController!.navigationController present(navc, animated: true, completion: nil) }
I am trying to do API request by using RESTful API, however, I got error message below from console.
XMLHttpRequest cannot load http://example.com/abcd. Response to preflight request doesn’t pass access control check: The ‘Access-Control-Allow-Origin’ header has a value ‘http://example.com' that is not equal to the supplied origin. Origin ‘http://example.com' is therefore not allowed access.