Wednesday, April 11, 2012

Parse: Sending Push Notifications using PHP with/without cURL

I started using Parse to easily send push notifications to phones with my app. However I needed to use PHP to send the notifications and not from the command line as shown in their api.

I came up with the following using cURL:

 $ch = curl_init(); 

 $arr = array();
 array_push($arr, "X-Parse-Application-Id: YOUR_APPLICATION_ID");
 array_push($arr, "X-Parse-REST-API-Key: YOUR_REST_API_KEY");
 array_push($arr, "Content-Type: application/json");
 curl_setopt($ch, CURLOPT_HTTPHEADER, $arr);
 curl_setopt($ch, CURLOPT_URL, '');
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_POSTFIELDS, '{ "channel": "","data": { "alert": "Red Sox win 7-0!" } }');

And if for some reason you don't want to use cURL, here is the code using the default stream_context_create and file_get_contents methods:

 $url = '';
 $data = '{"channel":"","data":{ "alert":"Red Sox win 7-0!"}}';

 $opts = array('http' =>
   'method'  => 'POST',
   'header'  => "X-Parse-Application-Id: YOUR_APPLICATION_ID\r\n
       X-Parse-REST-API-Key: YOUR_REST_API_KEY\r\n
       Content-Type: application/json\r\n
       Content-Length: " . strlen($data) . "\r\n",
   'content' => $data

 $context  = stream_context_create($opts); 
 $result = file_get_contents($url, false, $context);
 echo $result;

Tuesday, April 3, 2012

Virtual Nomads

Why do we play video games? We play video games for a social experience. Games can be after all part of the greate social network of the Internet. We play with others because it is more fun. Are social networks a bad things and can such social stimulation be addictive? Perhaps. Games start to become addictive when the player starts to feel compelled be there. The virtual world can be great and terrible. Not only is a product of our genius, but it costs virtually nothing to contribute too. It is something that we can get sucked into and lose our way. Most of us cannot do anything without our computers. The virtual world is has become our lives now. But we are humans, and no man is an island. We can't get all of our social fulfillment from video games. Eventually we feel that need and we come out into the light eventually. Do video games have lasting value? We play for many reasons: to relax, to create, to feel acomplished when we win, but mostly because we are bored. It is much easier to play a video game then it is to go out and make a new, real friend, or to learn a new skill. We lose ourselves if we lose the desire to innovate.

Monday, April 2, 2012

Multi-line overflow in Sencha Touch/ExtJS

Unfortunately CSS doesn't support multi-line overflow. I stumbled upon a stackoverflow question that addressed this. I applied this to work in Sencha Touch and ExtJS.

Try it yourself on jsfiddle:
ExtJS fiddle
Original jquery fiddle

With the following HTML:

<style type="text/css">
.item { 
   width: 300px; height: 120px; overflow: hidden;

.item div { 
  padding: 10px; margin: 0; 

<div class="category-item">
   <div class="list-item-title">Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
      Proin nisi ligula, dapibus a volutpat sit amet, mattis et dui. Nunc porttitor accumsan 
      orci id luctus. Phasellus ipsum metus, tincidunt non rhoncus id, dictum a lectus. Nam sed
      ipsum a lacus sodales eleifend. Vestibulum lorem felis, rhoncus elementum vestibulum eget, 
      dictum ut velit. Nullam venenatis, elit in suscipit imperdiet, orci purus posuere mauris, 
      quis adipiscing ipsum urna ac quam.

The javascript to add multi-line overflow in Sencha Touch is:

var item ='.item div').first();
var divh ='.item').first().getHeight();
while (item.getOuterHeight()>divh) {
   item.dom.innerText = item.dom.innerText.replace(/\W*\s(\S)*$/, '...');

ExtJS is the same with one line changed:

var'.item div').first();

while (item.getComputedHeight()>divh) { //this line changed
    item.dom.innerText = item.dom.innerText.replace(/\W*\s(\S)*$/, '...');

The above code with display the following:

Lorem ipsum dolor sit amet, consectetur 
adipiscing elit. Proin nisi ligula, dapibus a
volutpat sit amet, mattis et dui. Nunc
porttitor accumsan orci id luctus. Phasellus
ipsum metus, tincidunt non rhoncus id...

Thursday, March 22, 2012

Here Comes YouTube

In Shirky’s book "Here comes Everybody", the author discusses the possibility of something called “mass amateurization”. Any one can post anything to the internet using blog sites or other social networks. This includes uploading videos and images, as well as other content. The author describes that these tools don’t get socially interesting until they get technologically boring, and that sharing is enhanced through them. Shirky also states that society was transformed by tools such as the printing press but it is harder to prove that it was made better. it’s simple to say the internet is an interesting phenomenon. Recently I watched a YouTube video called The Machine is Us/ing Us. An Anthropologist from Kansas State University, Michael Wesch, created the video to show the future of Web 2.0. Over the course of the week it became viral. Because of this video, Wesch gave a presentation before the library of congress. Today Welsch and his students study the videos posted YouTube through Anthropology, or the effects of YouTube on society. Watching YouTube is practically a major now. We can see the effects that it has on society, the good and the bad. The web is an interesting place because it allows anyone to post anything, which changes how media is portrayed. But is this what the human race needs? Should people be allowed to post things without consequences? I believe that we should be responsible for our actions. I think that there has to be some way to genuinely authenticate a user before they upload anything so that they can be held morally responsible for what they upload.

Thursday, March 15, 2012

Tinkerers' Market

There has been a trend over the years that women have an aversion to the field of Computer Science. Women receive about half of undergraduate degrees in mathematics, physics and other science related fields but only about 20% in Computer Science. Researchers have determined that women are not drawn to to the study of computers because it is more of a tinkerers' field then an actual science. Early Software Engineers such as Steve Jobs and Bill Gates all got their start as tinkerers. Today Computer Science books give solutions but offer the student to try it on there own in a trial and error approach to solve the problem. Women have been driven out of computer science because there is not an agreed-upon body of knowledge that defines the field. 57% of men are drawn to Computer Science because of tinkering compared to the 16% of women. The study of computers should become a field of a science instead of a field of tinkerers.

Tuesday, March 13, 2012

Technologic Advancements

While reading an article put out by the Church, I was confused why it took so long for these changes to take places. Thinking that it had come out recently, while it was talking about CADs and how much computers can save time, I stumbled across a reference to the Apple II. It was then I realized that the article was not recent, and checking yes it was written in 1984. Many of the systems described in the article are still being updated and worked on. Today it may feel like the Church is still behind where it could be in regards of technology. The reason why I feel this is that it takes awhile for technology to be implemented in a place where peoples' faith are concerned. It would get too impersonal if everything were automated and too much computerization can make a person less receptive to the spirit. The Church has done a marvelous job using the tools that have been given to the world. So much more now is available and so much more is possible that can be done now.

Thursday, March 1, 2012

The Mobile Cuckoo

After reading The Cuckoo's Egg I came across an article stating that 99% of NASA's portable devices are unsecured. The reason why is that mobile devices have certain security features turned off, such as preventing cross-domain requests. Modern browsers have the ability to send cross-domain requests, but this option is turned off by default. The reason? A user can load a page that looks valid but is used by a hacker to send requests to desired server to get sensitive data and information. In The Cuckoo's Egg, a hacker was able to access government computers by guessing common username and passwords. This can also be done with cross-domain requests, guessing HTTP GET and POST queries on a cross-domain request. Finding the right query, a hacker would be able to access a user's information from his own server using a cross-domain request. In browsers to make this possible the hacker would have to hack into the server, put a page on the server to make it a domain-request, and then get the user to that page. If you are a hacker use a mobile device, it's a lot easier.

Tuesday, February 28, 2012

The Cuckoo's Egg

When I started reading, the fast paced nature of the book and the catch-me-if-you-can-ish spy story of an astronomer turned computer security specialist lead me to believe that it was a work of fiction. The elaborate processes that Stoll took to catch the hacker and the general lack in security in government and company systems seemed to confirm it for me. I especially couldn't believe that Stoll hooked up printers in order to track what the hacker was doing. Little did I realize that it all it actually happened! It is amazing to see how far computers have come in terms of levels of network security and what it takes to catch a hacker. While reading I found myself thinking of the steps that would have prevented the hacker from accessing the systems he did. First is that total overhaul of security. Having weak credentials allowed the hacker into many of the systems that he shouldn't have been able to enter.Second is that having a secure centralized logging location would of prevented the hacker from deleting local logs. He would have had to hack to central location, which would have been more difficult to cover his tracks. Third is the covering and fixing of security loopholes in software. This is a bit harder to track, mostly because system admins generally use outsourced software instead of creating it in house. Looking back just 20 years ago it is amazing how primitive computers seemed. It is amazing to see how far we have come today.

Thursday, February 16, 2012

Family Wiki

About a year ago combined data and features from other sites that offered similar ancestory services. Users can now receive email notifications when changes are made to a specific ancestor, as well as the ability to make and undo changes. Ancestry Search is headed in a new direction, ready to break new ground as it fully begins to take advantage of the internet. As it becomes more wiki-like, more and more people will contribute to it and add infromation about common ancestors. The future will eventually lead to social media being fully integrated with ancestry sites. It might be frightening to think that even now our entire lives are slowly being uploaded to the internet, but this is not a bad thing, our descendants will be able to look on ours lives and learn from our mistakes. This will be one step closer to our lives and memories living forever.

Tuesday, February 14, 2012

Standardization of the Webkit

With the rise of webkit in mobile browsers it becomes more and more tempting to drop support for the other browsers altogether. This leads to a problem that other browsers will eventually add de facto support for webkit. You add something with a -webkit prefix to your CSS and the browsers will automatically support it, even if they are not a webkit browser. This is bad. It leads to confusion and chaos. Browsers shouldn't be implementing other browser prefixes. As a developer it is frustrating to have to test in every browser, and then come up with a work around that is not as effective as one would want. But with the standardization of webkit it will be more frustrating to be limited to only webkit browsers when others are better in certain areas. I believe that standardization is not something to be feared, but poor implementation should be. Prefix support is not is not the right way.

Tuesday, February 7, 2012

Google Dart plans to usurp JS.

I read an article on arstenica about a new language that Google is developing called Dart. JavaScript has some fundamental issues that Dart addresses, the most important being that JavaScript is not as fast as a desktop language such as Java or C++ and probably will never be. It's no fun developing a slow web app when you know it could be a lot faster natively.

However there is a lot of talk about how this will affect the web community. JavaScript has been around for years, why should we switch to another language now? My personal feelings on the subject is that if there isn't much performance gain from Dart then it will be really slow for browser venders to switch to it (obviously). With the rise of the mobile market and how slow mobile browsers are, if Google creates a smash with Dart, if it is 10 times faster than JavaScript it is a sure guarantee that Web Developers will switch to it.

Friday, January 27, 2012

TRON Digital Book in HTML Goodness

I stumbled accross this after playing cut the rope. Its a digital book made entirely from html. All the animations, transparency, audio goodness was amazing, but when I found out it was made using HTML5 it nearly brought a tear to my eye.

Thursday, January 26, 2012

SOPA in Still Water

CNN posted a news story story yesterday about the current state of the SOPA/PIPA bill. One interesting thing that I found in the article was that the SOPA bill wasn't even the most lobbied bill of 2011, the most being some bill about making appropriations for Department of Defense[1]. Continuing reading of the article shows that most of the companies for the bill are ones that don't seem to have a huge internet presences. The ones against the bill have a much greater presence on the internet, and therefore have much more to lose if the bill had passed. With all the bad press of SOPA, I doubt that the bill will keep the same name when it is rewritten. Also with the whole of the internets against it I don't see a bill like that passing until lobbyists for it start thinking about everyone it would affect.

Tuesday, January 24, 2012

Revenge of the Techno Bugs

I recently read this article for my computer ethics class. It got me thinking. Technology is taking something and refining it. If something is improved in the correct way then it will not produce undesirable results. We call these results 'bugs'. With the increase of newer and improved technology, less 'ethical bugs' will occur. A good engineer will elimate such bugs within a computer program with time and patience, the same will occur with the 'bugs' of technology. However, I have wondered: is it ethically correct to use things that we don't understand? We tell our children to not use the stove and not operate heavy machinary under the influence of cold medicine because there is a chance that they can ignorantly hurt themselves. How are we any better by using technologies that we don't understand? We should have a complete knowledge of an idea and its effects before we use it.