Friday, December 21, 2012
Tuesday, December 18, 2012
The first thing that you need to do is to download/install Scala and Play into your computer.
To create the application, go into your terminal console and do the following:
- play new foobar
- Keep the same name of the application
- Select the Scala template (1)
- Change the directory to the foobar directory
- type "play run"
- Go into http://localhost:9000
The structure is very similar to Ruby on Rails.
- app: is the directory for all classes in the application
- controllers: all the controllers/actions for the applications
- models: domain objects
- views: the scala html pages
- conf: has all the properties files including the routes
- logs: the logs of the project
- project: build classes
- public: CSS and others
- target: compiled classes
Looking at the conf/routes we can see the following: This says that the moment that the application goes to the "/" it will call the controller Application and invoke the "index" method.
The controller has the following code: The index method calls an Action and sends an OK, which is nothing but a HTTP 200 code, and calls the page views.html.index with the string parameter: "Your new application is ready". If you look at the apps/views/index.scala.html you will see the following:
The message that was passed by the Application controller is stored in the message: String. The application calls a main html page and passes two parameters: "Welcome to Play 2.0" and "message".
If you look at the app/views/main.scala.html you can see that the first parameter is the "title" and the second parameter is the HTML content:
Remove the "@play20.welcome(message) so that the page looks like this: Render the page again, and you will see only the parameter passed by the controller. Lets go to the controller and edit the text by changing it to "Playing around".
Go back to the web browser and refresh the page. As you can see, the application renders automatically. The one thing that I like about the Scala programming language is that it is statically typed, so I can check in my editor. Lets configure the application as an Eclipse project.
Go to the console application and type control "D" or control "C" to stop the application. Now, type "play". You should see the play console. By typing "eclipsify" the play application will be ready to be imported as a project for Eclipse. Just go into Eclipse and import the project (file, import, select foobar directory). Once you are done type "run" to start the application.
As I mentioned, the conf/routes has the configuration for all the routes. If we add a route:
And go to http://localhost:9000/foo
You should see the same as if you go to http://localhost:9000.
Lets create an application that create a bar. The first thing we need to do is to create a model object named bar. Create a model by creating a Scala class in apps/models/Bar
The object will have only an id and a name. Now, we need to create a way to persist to a database. For Play the DB of choice is H2. It is a memory database and it is easy to work for development. To enable the database go to conf/application.conf and uncomment two fields:
Now that we have the drivers and the database, we need to create a script to create the database. Create a file for the DB schema inside conf/evolutions/default/1.sql
Refresh the page and you should be prompted to load up this script (or evolution). Just click on "apply this script now!"
Now, lets go back to the Bar model class and add the following:
This section will be the domain, which simply creates the bar and inserts it into the database. As you can see, we use the anorm API to map the SQL. This is not an ORM but more like a MyBatis (an SQL mapper).
Now, lets go to the Application controller and add the two things: the controller and the view. The first thing we need is to intercept the HTML form and add the action for the controller. Here we add the action and send a message depending on the type of transaction (error or success). We need to create the view form, but first we need to add the route to the controller.
Now, lets create the form view in the views/index.scala.html: You should be able to see the form in the application. Lets try to add a "test" bar. You shouldn't have any errors.
Now, we need to displays all the bars added. To do this, lets first modify our domain/model Bar object and controller. Using the allBars, we will be able to get all of the records from the bar table. For the controller, we will add the following: Now, we need to add the route in the conf/routes: If we go to http://localhost:9000/bars
Wednesday, October 31, 2012
Sunday, October 14, 2012
I worked in many places that cared more about the "perception" of the company rather than the people. Many manager/directors worry about the image of the company without realizing that they are setting the tone of the company's culture (their workers), and this will affect their bottom-line/product. For example, "we expect you to work from 9 am - 6 pm", "we expect you to work AT the company, not at your house", "we expect you to dress a certain way - we have a dress code", "we need to ship this feature, we don't care how you get it done…that's your problem."
When we started a my former start-up, we thought we understood our customers, we thought we knew what they wanted, and we just wanted an application that WE would like. After all, "build it, and they will come", right? WRONG! The bottom line is that we were assholes. We really didn't have it right. It was until hard lessons learned that we started listening to our customers and focused on what they wanted rather on what we thought they wanted. But also, it was until we started changing our culture and hiring the right people that the company finds its product.
Zach talked about things like:
Your product should be a byproduct of the people, process, and technology of your company.
Foster a good environment, be more likely to create a good product.
Hire those bothered by suck. You want fixersI'm very committed to my companies, but I'm also in LOVE with my family. This is constant tough of war in my head. I do want to help the company in everything I can, but I also want to help my son with homework, and spend some time with my daughter and wife. I do feel that where I work is MY company. I know that there are some people that said that it shouldn't be like this, "you shouldn't live for work, but work to live". But that's not what I mean. I work as it's my company in the perspective of shutting down my MacBook Pro,with the feeling of "I kicked ASS today". It is not always like this, but most of the time, they are. I like the fact that people (coworkers and directors) say, "ever since we hired Marcelo, this place is TIGHT", but I also want my family to say, "we love were you work, because we can see you and spend quality time with us".
As Zach mentions:
Any time you interview a potential hire, you need to ask yourself not only if they're talented or collaborative but also if they're capable of literally running this company, because they will." - VALVe
Hire broad people. Hire diverse people.
Good culture attracts good people
Be family friendly
Flexible location, hours, workload
Wednesday, August 29, 2012
Wednesday, June 20, 2012
Edit the following file:/etc/apache2/sites-available/default Make sure that the configuration for WSGISocketPrefix is set as follows:Otherwise, you will get the following error:
[Tue Jun 19 13:21:28 2012] [error] [client 192.168.0.112] (2)No such file or directory: mod_wsgi (pid=19506): Unable to connect to WSGI daemon process 'graphite' on '/etc/apache2/run/wsgi.19365.1.1.sock' after multiple attempts.Create initial database: Create the admin for graphite: Start carbon (data aggregator)
Check the log file for any error: /opt/graphite$ find . -name '*.log' | xargs tail -F
To Feed the data do the following:Go into the server localhost in your prefer browser and you should see graphite site.
Tuesday, April 24, 2012
Wednesday, February 29, 2012
- Preventable: this is when it could have been prevented. For example, testing in production, deploying code before testing it, logged in as root and doing an "rm -rf /".
- Complexity related: a large number of organizational failure are due to the inherent uncertainty of work: A particular combinations of needs, people, and problems may have never occurred before. Although serious failures can be averted
- Intelligent: failure when experimentation is necessary. An example will be like "spike" in Agile.
Fail often in order to succeed soonerThis is something that not so many companies have. Entrepreneurs embrace failure and uncertainty. In startups, there is just too much uncertainty and as Steve Blank puts it,
In a startup no business plan ever survives first contact with customers.So what happens if the original business plan fails? An entrepreneur adapts! He/she learns what went wrong, makes adjustments, and then monitors the new business plan. This means that failure is a natural part of doing business.
- Detection: the should be to surface failure early.
- Analysis: find out what is the root-cause of the problem, or in agile terms: root-cause analysis (RCA).
- Experimentation: try to generate intelligent failure for the express purpose of learning and innovation.
Friday, February 17, 2012
- Technically savvy - can the candidate do the job? Does he/she has a good foundation on computer science (data structures, algorithms, etc)
- Quick learner or persistent when it comes to finding a solution.
- Is he/she an asshole
THE DIRTY DOZENCommon Everyday Actions That Assholes Use1. Personal insults2. Invading one’s 'personal territory'3. Uninvited physical contact4. Threats and intimidation, both verbal and nonverbal5. 'Sarcastic jokes' and 'teasing' used as insult deliverysystems6. Withering e-mail flames7. Status slaps intended to humiliate their victims8. Public shaming or 'status degradation' rituals9. Rude interruptions10. Two-faced attacks11. Dirty looks12. Treating people as if they are invisible
If you have the wrong people, it doesn’t matter whether you discover the rightdirection—you still won’t have a great company. Great vision without great people isirrelevant
Tuesday, February 14, 2012
Defining an accurate (an universally agreed-to) measure of information technology productivity is perhaps the 'holy grail' of IT measurement.That's absolutely correct. If you're a manager, or have been a manager, then you know that is true. He composed a list of "6 Core Assessment Areas for Measuring IT Productivity":
- Computer Technology Measures of Processor Economic Efficiency
- Supply-Side Measures of Reduce Economic Efficiency and Productivity
- Demand-Side Measures of Economic Efficiency And Productivity
- IT Portfolio Measures of "Run the Business" vs. "Change the Business"
- IT Budget Agility Measures of Fixed vs. Variable Costs
- Operational Leverage Measures
- Release cycles: how often we make deployments of new features or fixes
- How many bugs were introduced on the release/deployment
- Turn-around time on bug fixes: how fast do we find them?
- Performance and scalability of application: how fast is our application? How much can it handle?
- Hight Availability measurements. For example, what is the turn-around time for an event failure (going from primary to secondary)
Creating software is about delivering business value. Without some measure of business value, it's hard to determine whether the software has any.
- Increased revenue (sales, royalties, fees)
- Decreased expenses
- Using less resources
- More efficient use of resources
- Customer satisfaction
- Product promoters / satisfiers/ detractors
- Staying in business
- Avoiding risk
- Are you delivering something of value every week?
- Are you striving to continuously improve?
Thursday, February 9, 2012
The objectives were the following:
- Check file every 1 minute from 9:30 am - 4:00 pm
- The first line contains "ACMEFixLogs" and it is not a reject payload
- Notify the number of rejects and the name of the file
- If after the notification, there are no rejects, do not notify
The simplest way is to leverage some type of log checkers that reads the content and saves the last line in a temporary file. This way, the next check will start from the saved line and the content will not be repeated. I found logwarn and I really like it. Mostly because it is has a Nagios plugin and this is my notification engine. Also, logwarn has a regex filter that I could use for my file.
Here is how I solve the problem:
- Create a shell script as a Nagios plugin (exit 0 if everything is "OK", exit 2 if there are any errors.
- Leverage the capabilities of logwarn to handle the reading of the file
- Use the regex so that I disregard the first line "ACMEFixLogs" using the logwarn "!"
- Use Linux's word count to find out how many rejected lines there are
- If there are any reject payloads notify (exit 2)
- If there are none, notify that everything is fine (exit 0)
Here is the script:
Monday, February 6, 2012
Friday, February 3, 2012
Here is the unit test cases:
Thursday, February 2, 2012
First, create a directory: sudo mkdir /mnt/ultralord-logs/
Now, lets try to make the mount:
Here, I am mounting the //ultralord-main/logs with the username "gandalf" and the domain "ultralord". If the username is only a local user (not in the domain), then the domain will be the name of the computer "domain=ultralord-main".
Now, check if the mount was valid by doing: ls -l /mnt/ultralord-logs
I always recommend to setup a credential file to hide the username and password.
If you are able to see logs in the directory, then you are ready to edit the /etc/fstab so that the mount happens automatically.
If when trying to mount a drive you get the following:
The solution is to install smbfs