Allowing your users to upload images to your application is not an unusual feature but I had to pull some of my hair before I found an approach I liked when trying to do it with Ember.

At first we need a component for the file-input as there is no built-in view for this yet.

App.InputFileComponent = Ember.Component.extend({
  attributeBindings: ['multiple', 'type'],
  tagName: 'input',
  type: 'file',
  multiple: true,
  files: null,
});

 
We can use it in our template like this

{{input-file files=files}}

 
And files is the property we are going to use to store our files.
Then we want something to happen when the user chooses which files to upload. We can do this by listening to the change event and populate our array with the files uploaded

change: function(event) {
  var files = event.target.files;
  for (var i = 0; i < files.length; i++) {
    var file = files.item(i);
    this.get('files').pushObject(file);
  }
}

 

We can now render our files on the page.

<ul>
{{#each file in files}}
  {{file.name}}
{{/each}}
</ul>

{{input-file files=files}}

JSBIN Demo

But displaying just the filename is a bit boring, is it not?

As luck would have it, thanks to components it won’t be too hard to show a preview of the image next to the name.

If we remove the list item from our template and replace it with a component. We can do something like this.

<ul>
{{#each file in files}} 
  {{image-preview file=file}} 
{{/each}}
</ul>
{{input-file files=files}} 

 
By creating a image preview component we can use the FileReader class to read our image data and bind it to a img-tag

App.ImagePreviewComponent = Ember.Component.extend({
  tagName: 'li',
  file: null,
  
   didInsertElement: function () {
     var self = this;
     var file = this.get('file');
     var reader = new FileReader();
     reader.onload = function(e) {
       var data = e.target.result;
       self.$("img.preview").attr("src", data);
     };
     reader.readAsDataURL(file);
   },
});

 

JSBIN Demo

Apache vs Ngninx. Passenger vs Unicorn vs Puma. I’ve personally been running Apache with Passenger as I got alot more of Apache experience then with Nginx but when setting up the servers for a recent Rails project I was not really happy about the number of request I could serve.

The beta site is running on Digital Ocean $10 servers which yield the following specs

  • 1GB Memory
  • 1 CPU Core
  • SSD Drives

I use 1 server for the database, 1 with Apache + Passenger and 1 with Nginx + Puma. Then I used another server with some more power behind it to run Apache Benchmark with a conccurency level between 10 and 500.

I bashed the servers with 200, 1000, 5000, 10000 requests to measure number of request per seconds it could handle and  the mean response time

 

Requst / second

rails_benchmark2

 

 

 

 

 

 

 

 

 

 

 

Mean Requst time(ms)

rails_benchmark1

 

 

 

 

 

 

 

 

 

 

 

 

So it seems when it comes to Passenger vs Puma it seems like Puma  is the way to go. Next up I’ll have to try Unicorn.

After my first attendance to World Hosting Days I’ve drawn the following conclusions.

 

Open source is great
The value of open source development has reached even greater spread and hopefully this will lead to additional exchange of knowledge.

 

Love your ecosystems
Having a community around your product and then most importantly, have a product which allows your community to extend and modify it for their own personal needs.

 

Big data will get even bigger
Big data has been the thing to talk about for a while now and it’s still growing and recent analysis shows that by 2020 the amount of storage needed will be around 40 exabytes, that would equal about 85 million years of HD video.
Seagate presented that they needed to innovate and move away from their classical disk manufacturing and the current way of building SANs. When they presented their new Kinetic disks they showed that they really have started to innovate and are building disks for object storage that can communicate over Ethernet.

Kinetic

 

Detach your resources
We have been moving our storage out from our servers for quit a while now and Intel presented that they want to do the same with the rest of our system resources. Using fiber optics they want to move memory and CPU out of the servers and into a rack level.

 

Arm enters the data center
AMD was present to talk about their new investment into Arm processor wanting to create CPUs for specific tasks like video rendering and data analytics.

 

Microsoft impresses
With their new concept, Cloud OS which is based on Windows server and Azure pack among others and lets you build and move between public and private clouds and alot of other cool features.

Cloud OS

 

Learn to love your orchestration layer
While automated deployment and provisioning continue to grow and PaaS and SaaS are getting more popular the demand for on-demand infrastructure will increase.

 

Focus on the things you are good at and do them better

Identify the parts of your business that you do the best, focus on these and partner up with top actors in your edge areas.

whd-cloud

Preview 2 has now been released with mostly fixes from P1

 

  • Fix Heap Overflow in Floating Point Parsing 
  • “literal”.freeze is now optimized 
  • f suffix of String Literal is removed
  • Fix memory consuming issue on RGenGC
  • Updated libraries like json, nkf, rake, RubyGems, and RDoc.

 

And the updates from Ruby 2.0

 

  • VM (method cache)
  • RGenGC http://rubykaigi.org/2013/talk/S73
  • Refinements
  • Syntax changes
    • Decimal/Complex Literal 
    • def’s return value 
  • Bignum, now uses 128bit integers and GMP
  • String#scrub 
  • Socket.getifaddrs 
  • RDoc 4.1.0.preview.2 and RubyGems 2.2.0.preview.2

 

 

We have now gone live with version 2.0 of http://www.flypatterns.co featuring almost no new functions or content, but the codebase has been rewritten from PHP to Ruby on Rails and is running on a Apache / Passenger server.

The new layout is the first step towards making flypatterns.co the best source of flytying resources there is and hopefully, from here on it’s development will be more fluid and faster.