My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Showing posts with label hack. Show all posts
Showing posts with label hack. Show all posts

Sunday, March 8, 2020

Typechecker in hhvm and running Hack program

Let's start with writing a sample program of printing cubes of numbers. eg:

Using the editor of your choice (e.g., VSCode or vim), let's create a file called first.hack with the following code:
<<__entrypoint>> function main(): void { echo "Welcome to Hack! \n\nTutorial by Anwar Faiz\n\n"; \printf("Table of Cubes\n" . "----------------\n"); for ($i = -5; $i <= 5; ++$i) { \printf(" %2d %2d \n", $i, $i * $i * $i); } \printf("----------------\n"); exit(0); }
To see the result of Typechecking:
$ hh_client first.hack
You should see:
No errors!
* Note that however, you might get following error - Error: /Users/mfaiz/ECPCP/hhvm-hack/first.hack is not a directory
But that is other issue. i will explain in next post.

To run the program on client side:
$hhvm first.hack 
You will get following as result.

By the way by now I am already feeling like using Node like application for PHP. This is looking cool. Hurray! 
Take care readers. And pour in your thoughts :)




Friday, March 6, 2020

First Hello World using Hack & HHVM from Facebook

1. Install HHVM on MacOS via Homebrew:
brew tap hhvm/hhvm
brew install hhvm

The out-of-the-box HHVM configuration won't need tweaking by most new users. Notably, the JIT compiler that gives HHVM its speed is on by default. If you want to take a look at the configuration used, it's at /usr/local/etc/hhvm/php.ini in MacOS.



2. Test: After installing HHVM, change to the directory where your code lives, and start up HHVM:

hhvm -m server -p 8080
-m represents the mode and here indicates that HHVM is running in HTTP server mode.
-p configures the TCP port that HHVM uses to listen to HTTP requests. The default port is 80, the standard HTTP port. However, that port requires root access, so for this example, we will use port 8080.

This will start the server as follows and then you can test on browser.


3. Write a simple "Hello World" program named hello.hack:

<<__entrypoint>> function main(): noreturn{ echo "Hello World in Hack Language! \nThis is Anwar Jamal Faiz"; exit(0); }

Save this hello.hack in the same directory that you ran the hhvm command from above. Then, load http://localhost:8080/hello.hack in your browser and verify you see "Hello World!" appear.


See in browser:
You may also write the program as:
<<__entrypoint>>
function main(): noreturn{
  echo "Hello World in Hack Language! \nThis is Anwar Jamal Faiz";
  exit(0);
}




4.  You can directly run file using hhvm itself.

$ hhvm hello.hack




Note: You can configure HHVM too. Running HHVM automatically at boot as a service (instead of just on the command line as above) unfortunately does require some configuration. See the proxygen documentation for details. However, default settings are okay for any average usecase.


My First look of Hack Language over HHVM by Facebook

Hack is a great language in terms of the advantages it has over PHP. The hack language introduce a level of type safety and related concepts. Undoubtedly, with HHVM it becomes a faster processing language. It is more expressive, more economic, it is faster to write and catch more bugs. The key features as explained by Facebook itself are:

Fast Development
Hack reconciles the fast development cycle of a dynamically typed language with the discipline provided by static typing, while adding many features commonly found in other modern programming languages.


Type Checking
Hack provides instantaneous type checking by incrementally checking your files as you edit them. It typically runs in less than 200 milliseconds, making it easy to integrate into your development workflow without introducing a noticeable delay.


Built for HHVM
Hack is built specifically for HHVM, a high performance 


Type Annotations
Type annotations allow for code to be explicitly typed on parameters, class member variables and return values.


Generics
Generics allow classes and methods to be parameterized (i.e., a type associated when a class is instantiated or a method is called) in the same vein as statically typed languages like C# and Java).

Lambdas
Lambdas succinctly allow definition of first-class functions.


HHVM is an open-source virtual machine designed for executing programs written in Hack. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining amazing development flexibility. HHVM should be used together with a webserver like the built in, easy to deploy Proxygen, or a FastCGI-based webserver on top of nginx or Apache.

Released in 2014, Hack is still not so much popular and I see following as the reasons.
  1. I cannot find any big hosting provider to support HHVM hosting and support for Hack language. You need to maintain your own server. This is one of the big issues that I see with Hack.
  2. Vast majority of php programmers do not build using TDD approach or do lots of whitebox testing. Hence, the benefit of type checking does not attract them much. For many hhvm is just a slightly faster incompatible php, no surprise they aren’t going to invest much there.
  3. Installing Hack on different systems require more technical knowledge. Novice programmers usually lack the skills of core OS. Also, on some systems you need to build HHVM from scratch using the source code repo.
  4. Backwards compatibility with PHP is not 100%. Almost all PHP code works in Hack but there are certain features of PHOP which is not supported in Hack. Hack may have some incompatibility with existing PHP codebases, which increases the cost of switching.
  5. Not everyone needs the amount of scalebilty the companies like Facebook need.
  6. Other bigger eCom and web companies are trying with new RAD tools like React and doing pretty well in their NodeJS world. Webservices are already build using Java or C# and they do not want to come to PHP of Hack.
  7. Hack doesn't allow templating of HTML and Hack code together, which is a popular feature of PHP. You need an engine in between.
  8. Last, but not the least, no one knows how far facebook itself will support the developemnt and Bug fixes in Hack or HHVM.

However, we should also understand that in the world of PHP, the language Hack becomes very useful. It will help developers catch some errors while writing the code itself. Further, the dev tools by Facebook and other contributors are also very exciting. So, I will be experimenting more with the language. Will keep you all posted about new features.

Thursday, November 23, 2017

How can I open a cmd window in a specific location on Windows

Hi,

This hack will help you in many ways. And, shall help you many ways too!
This is a part of my initiative to post simple tricks aimed to Help/ease a QA Day to day life. These Tech Hacks are very handy but increase your efficiency much.

So, for our case today - How can I open a cmd window in a specific location on Windows; I provide two methods:

Trick 1:

If the folder is opened.
Click on address bar, alternatively press Alt+D
Now when address bar is highlighted, type cmd in the bar.
Press Enter key
You will notice that command prompt from that folder



Trick 2:

In the folder. Press Shift and then Right Click

A option appears -> Open Command Window here.


Press that. It will open a command window with present working directory as the selected hotel

Monday, January 28, 2013

A shabby tailor would not be a gentleman's tailor.


Thats true!!

This thought has occured to me a while before. And, I seriously find this a good phrase in the world of Services and Product companies, institutions, and organisations.

Brief of the letter to a leading Software Company( sent a couple of minutes before.) This also describes my phrase coined today i.e. January 28th, 2013.

Dear Company,

For a company as big as you and one of the biggest seller of softwares, products, SaaS and hosted platform services, you should be very cautious of choice of softwares, and your own security mechanisms. Technically, because a shabby tailor would not be a gentleman's tailor.

Yours sincerely,
Anwar Faiz
Toughjamy@Yahoo.Com

PS: I would not reveal the name of the company and the sort of attack or vulnerabilty pointed in their system. I have already send the details, screenshots, source code lines having mistakes, the degree of threat, and possible resolutions to the concerned authorities in the company.

I am not bound to maintain this secrecy, but I feel its ethical :)



Tuesday, June 21, 2011

inurl search fails on Google - Is it not a Google hack or failure


Hi
Earlier you must have used inurl: searches in Google Search Engine.
But today i found out that it fails.

I looked for query : inurl:adobe
And nothing comes up.

Then i searched for inudl:adobe and several results come up.
I am also advised to search for inurl:adobe instead.

But again on clicking the Link the Google Search Engine stopped responding.



I rechecked this many times today.

Someone from Google, have a look!!
1) Please advertise if the support has ended
2) In any case the search engine should not get confused and must not hang.

Wednesday, April 20, 2011

How to tackle the problem of opening PDF docs in Web Browser when Adobe PDF Reader not installed.

It is often said that you must not forget your enemies however small it may seem.One such scenario came when one of my close acquaintance Mr Sandeep wanted to show PDF docs on his website. Now you may say what makes it a big deal to devote a blog post for this?
However the problem was that my friend wanted to show his PDF links even if Adobe Reader was not installed on his client machine. True that this situation is rare , but what is to be done if as a consultant you are posed such questions. Let's all see how the problem has to be tackled.

There are two important points regarding the problem:

1) The AdobeReader not installed on the machine is very rare situation. It is a free tool easily downloadable and installable from Adobe website. It has penetration of 99.9% worlds computer . That is 99.9% computers using Internet have this already installed. All computer manufacturers give this preloaded and free. So even if your client is having problem of not having this you can ask him to install it without any business, reputational, or efficacy loss.

2) Now a dayz many browsers also have inbuilt AdobeReader. Since adobe does not charge other companies from using this. So new browsers have this automatic pluging. Eg in Google Chrome, Internet Explorer 10, Mozilla Firefox. Browsers which dont have this, for them plugins come. So in any case if your client is not able to view PDF, it is not even slightest of your problem to worry. You can also give a link to download Adobe reader, free of cost, Since Adobe has free distribution as well as redistribution policy. Or in best case show them downloadable link from Adobe website itself.


In all other cases if you are too vigorous for perfection (which i wud really say too! coz even if u miss that , its not a big deal). Then in that case I give you the easiest, trickiest, and free to use idea.
This idea uses Google docs.

Suppose you have a PDF doc -->abc.pdf
It is stored at any location on your server-->www.meonshow.com/abc.pdf
Then use the following Link to open that
http://docs.google.com/viewer?url=http://www.meonshow.com/abc.pdf

Rest can be tested urself. You can modify the parts of pages that has to be shown. A simple HTML editing and rendering the page in Frame or I-Frame.

For Example: Click Here to view Mohd Anwar Jamal Faiz Latest Resume.

Other ideas can be to search the enormous web and to use some quality free tools for the purpose. Or pdf to SWF converters or make some customized Flex/Flash Application that can do that job properly. Search madxperts or codebox website. They have this I guess.

Hey readers, I forgot to mention one important issue in any case. Behold. Its not related to IT. I am married now. Wow!! Please give your blessings to our family. Will give accounts in some other post.
Bye till then.

Mohd Anwar Jamal Faiz
TCS/Adobe/Symantec

Thursday, February 17, 2011

Intresting trick to Show your name after Time in Taskbar

To help young ones and also to the grown up prank players, I am again with a simple trick. This time it is something unusual. You can add your name (If you want even my name is good enuff!!) in place of AM and PM beside the time. This would be catchy in your group of friend/ colleagues. Just to add, my best friend *SO*loves to know about these small lil tricks. She is an avid computer/internet/social-networking user though (I think Mark Zuckerburg should hire both of us for using his virtual space FB.com to love, fight,discuss and romance!!)

You can start by going to Start -> Control Panel -> Regional and Language option -> Press Customize button -> Go to TIME tab -> Change AM symbol and PM symbol from AM and PM to your name -> Apply -> Ok.
Has it changed?
Have patience…Sometimes you need an additional setting too. Go to the Time in taskbar and Double Click it to open "Date and time property" .Look place where time changes in digital form i.e. 02:47:52 AM. Now you have to click the arrow to change the AM or PM. This will popup your name (that I believe is legitimately yours. Rolf!!!). Apply OK there.
Mission Accomplished!!!