Knitting Web App FrontEnd with Pattern Editor Knitting Simulator

Hi everyone, I am Sameera Gunarathne and I am a computer science undergraduate of University of Moratuwa, Sri Lanka. This is the first time I have applied for the GSoC and FossAsia and I am quite excited to  give my contribution to FashionTec as it's a whole nice new experience that programming is applied with real world applications in fashion and technology paradigm. I have selected for developing a Graphical User Interface which runs as a web application which is intended to provide a common platform to give input for the knitting machine firmware. As the first step I had to research on the existing knitting applications that are available online commercially and what they provide as features that still need to be included in open source knitting applications. I have looked into both knitting pattern design softwares and knitting machine embedded softwares including knitbird, EnvisioKnit ,Stoll knitting software, ShimaSeiki SDS One Knit. The most significant feature I have noticed is the feature rich pattern editor provided with the software. They provide features like loading patterns from different formats(jpeg, png,gif,pdf), transform patterns(crop,replicate etc) to create new patterns, drawing tools to create a pattern from scratch, Provide colour palette with available yarn carrier colours, Saving and loading the work done by the user in the application storage etc. Therefore in this GSoC period I am developing the assigned Web User Interface with consisting of following components. Web App FrontEnd Work Space + Pattern Editor Knitting Simulator Project Manager Web App Back End Web Client Server component(REST Api to communicate with knitlib interface) Request Handler for back end logic Knitting Simulator is used to simulate the knitting process through the user interface while the knitting is going on. It will display the carriage details, current knitting progress and a graphical simulation of the current knitting position of the pattern with row details. Project Manager component is to save knitting works as projects and load them later as the user preference. The selected technologies for the project implementations are mainly JavaScript(node js for back end and angular js for front end implementations), HTML & CSS (render static content). REST Api for communicating with knit lib interface will be implemented in node js. The offline usage of the app will be implemented using Electron Framework. This project consists of 4 milestones and under the first milestone I am working on the pattern editor features. Currently I have implemented loading different types of patterns into the workspace and pixelate them according to the number of rows and stitches allowed for the knitting. Following tasks will completed end of this week. Identifying individual pixel in the grid as a stitch and add operations such as change colour, size etc. Adding pattern editor tools for selecting pattern area, colour picker, crop-cut-paste tools for pattern replicating. I hope this GSoC will be a fruitful one to spend with a successful implementation of the knit web app and looking forward to provide a competitive open source knitting software at…

Continue ReadingKnitting Web App FrontEnd with Pattern Editor Knitting Simulator

Simpler Control of Knitting Machines with knitting machine abstraction library and JSON based knitting file format

Hello everyone, my name is Sebastian Oliva. I am a developer from Guatemala and part of the team of students currently in Google Summer of Code '15 working on Fashiontec. During last year's GSoC I built a GUI interface for the AYAB project, allowing for easier control for knitting machines supported by AYAB (Brother KH-930, KH-910). When I started getting involved with Fashiontec and FOSSASIA last year I was not aware of the large community related to textile and open fabrication projects. Since then, I have found many projects that have focused on different techniques and have had different approaches to fabrication and in particular the operation of knitting machines. Such as projects that emulate existing functionality of an existing machine, projects that entirely replace or enhance the machine's inner workings, and projects that build machines from scratch. Currently I am working on developing a knitting machine abstraction library and JSON based knitting file format that can enable the use of a single API to control a varied number of knitting machines. A knitting machine library allows us to create even more advanced software to control and operate machines, while a standardized and open format for knitting patterns allows us to create pattern collections such as the common pattern books usually shared by knitting communities, as well as enabling pattern editors and ecosystem. Currently I am: Working on designing and implementing Knitlib's API design. Writing tests for Knitlib's desired behaviour. Starting work on defining Knitpat, the open knitting file format. I hope that this year's GSoC brings a lot of advances to the machine knitting community, and I am happy to be a part of it.

Continue ReadingSimpler Control of Knitting Machines with knitting machine abstraction library and JSON based knitting file format

Optimize React-Redux App

React is advertised as quite fast out of the box. In extreme cases when your app hits performance problem, you just have to optimize the re-rendering process by shallow comparing React props and state inside shouldComponentUpdatelifecycle function. The strategy for optimizing seems quite straight-forward. However I found that this strategy is less clear in a React/Redux environment. Here are some advices that you should considering when dealing with your app performance: Use Immutable data This one should be a no-brainer with any React app. shouldComponentUpdate can only be useful when all the props can be shallow-compared. So as a rule of thumb, your components props can only be of 3 types: Immutable Primitive type (number, boolean, etc.) Function type (e.g. callback event) I didn’t mention how you should handle React state. That is because Redux uses a separate store as application state. But sometimes, you need to use both React’s state and Redux’s store. In that case, both props and state are shallow-compared so state elements should follow mentioned rules as well. Do not use ownProps When you create stateful components (containers) using connect function from react-redux library, shouldComponentUpdate is declared implicitly, so you normally don’t have to implement it yourself. However the implementation of shouldComponentUpdate is such that if you uses ownProps in your mapStateToProps or mergeProps function, it will always return false, so the component will always be updated. This means that if you want your component to be optimized, you can’t use information from passed props to get other information from the store. Why the implementation has to be this way is still unclear to me. Avoid connect on frequently-called elements connect function wraps the component inside another component with lots of decorated elements. These heavy overheads should be avoided on components that are called a lot in your application, for e.g. an element of a list. Use Performance Tools Finally, here are some excellent tools from the React team. Use them to identify the bottleneck in your React application: React Perf’s printWasted() function React Dev Tools trace react update

Continue ReadingOptimize React-Redux App

FOSSASIA API calendar service

ICalendar is a file format residing under RFC 5445, to represent and exchange calendaring and scheduling information. The file extension is generally .ics, and .iCal for Apple software. The aim was to define a standard format that could be understood everywhere, independent of calendar vendors : Google Calendar, Apple iCal, Yahoo! Calendar, Mozilla Lightning, Microsoft Outlook… Nevertheless, true interoperability doesn’t seem to be the reality. My next task at FOSSASIA is to this circumvent this situation and create a calendar service / vizualisation from ICalendar sources provided by different open-source communities, hence probably from different vendors and format deviations. To have an idea of the problem I’m dealing with, I gathered a bunch of ics files, mostly provided by freifunk communities, using these little node scripts, and try to spot a not-so-standard implementation. To have a less mechanical approach, I developed a visual tool to debug my ics. Here are some screenshots of the app: Screenshot 1 Screenshot 2 The tool is fairly simple : you copy the ics text into the text area (or choose between example files), press Feed me !, the system will get running and provide some outputs. There is a general info panel, a yearly heatmap, and a calendar. It is a great help for me since I can just switch between ics files, see all the events counts in the heatmap, and event detailed information in the calendar. Source code & demo version coming soon ! Built with ics parser library https://github.com/johngrogg/ics-parser, CalHeatmap https://kamisama.github.io/cal-heatmap/ and jquery plugin FullCalendar.io. Update : Source : https://github.com/zyzo/ics-tools Demo : http://fossasia-api.herokuapp.com/ References : Freifunk community map https://blog.fossasia.org https://github.com/johngrogg/ics-parser https://kamisama.github.io/cal-heatmap/ FullCalendar.io

Continue ReadingFOSSASIA API calendar service

How to join the FOSSASIA Community

We often get the question, how can I join the community. There is no official membership form to fill out in order to participate in the Open Tech Community. You simply start to contribute to our projects on GitHub and you are already a member. So, let's work together to develop to develop social software for everyone! The FOSSASIA team welcomes contributors and supporters to Free and Open Source Software. Become a developer, a documentation writer, packaging maintainer, tester, user supporter, blogger or organize events and meetups about our projects. Women in IT discussion in the community Here are some ideas how we can collaborate Download our Open Source applications, install them and use them The first step of joining a project is always to download the software and try it out. The best motivation to support a project is, if the project is useful for yourself. Check out our many projects on github.com/fossasia and our project social media Open Source search engine on github.com/loklak. Show your support and ★star FOSSASIA projects Help to motivate existing contributors and show your support of FOSSASIA projects on GitHub. Star projects and fork them. Doing something that people like and that helps people is a great motivation for many. Learn about best practices We have formulated best practices for contributing to Open Source to help new contributors to get started. Please read them carefully. Understanding our best practices will help you to collaborate with the community and ensure your code gets merged more quickly. Subscribe to news Subscribe to the FOSSASIA Newsletter to stay up to date on new software releases, events and coding programs here on the main page. Read the blogs and support users on the mailing list Learn from Open Tech articles on our blog that are written by developers, contributors, volunteers, and staff of companies supporting the FOSSASIA network. Sign up for the FOSSASIA Mailing List and keep reading our blog at blog.fossasia.org. Follow us on Social Media Show us you interest in FOSSASIA's Open Technology and keep up to date on new developments by following us on Twitter and retweeting important updates: twitter.com/fossasia And, become a member on social networks like Google+ and Facebook and connect with other contributors: * Facebook www.facebook.com/fossasia/ * Google+ plus.google.com/108920596016838318216 Join and support the FOSSASIA network at community events Set up a booth or a table about FOSSASIA at Open Source community events! There are many events of the open source community all over the world. The core team of FOSSASIA is simply not able to attend all events. You can support the cause by making the project visible. Register as a member of the FOSSASIA community at events, set up an info point and showcase Free and Open Source projects. Check out for example FOSSASIA event calendar calendar.fossasia.org or our meetup group in Singapore: meetup.com/FOSSASIA-Singapore-Open-Technology-Meetup Translate our projects and their documentation Do you speak more than one language? Most Open Tech projects are 100% volunteer translated, which means you can be part of a translation team translating software and documentation thousands of people will use.…

Continue ReadingHow to join the FOSSASIA Community

Scrum journey

Exception, perception, and knowledge are things that fade away. The truth is that your memory betrays you all the time by erasing (without asking you a word !) all your experience about things that you used to know. If you are old enough to forget how awesome your childhood was, and are frustrating because you do, you’ll understand what I mean. The problem is, experience is often very valuable, even if it is about how you felt being ignorant. For instance, as a teacher, you want to know what it’s like to know nothing about a subject, so you can deliver it to your students, in a less boring or overwhelming way. As a framework designer, if you want to strive for easy integration and small learning curve, you should at first know what small learning curve and easy integration look like for newbies. I’m not going off topic any further. The reason I’m saying all this is because I’m learning a whole new concept that I have absolutely zero idea about: scrum mehodology. This framework is applied in my gsoc project at FOSSASIA. I don’t have all the data yet, but my first impression is that this is a hell of a subject that would deeply impact me in my work life. Therefore I’ll use this blog as a diary to log all my experience in my scrum’s discovery journey, so when I’m skillful enough, I can look back at this and remember what it’s like to be ignorant again. I’ll also post useful links and stuffs that help me, so I hope this blog will benifits others as well. As consequence, this blog will likely be updated in the future. I don’t know when, but it will be. Unless I (am very unlikely to) become a scrum master with no more stuff to learn. Image credit : http://www.agilelearninglabs.com/2012/02/what-does-a-scrum-master-do/ Outline Day 1 : What the heck is scrum and scrum questions ? Day 1 : What the heck is scrum, and scrum questions ? Scrum is a version of agile programming, as opposed to “waterfall” programming where all specifications are planned in the beginning and all deliverables in the end. My first impression about scrum is, it doesn’t bring anything new to the table. Smaller release cycle ? Daily team communication ? Sprint-based/task-based development ? More client interaction ? These are useful tips/guidelines for sure, but for a developer, this sounds quite trivial and just like common sense. Maybe from a manager’s point of view, it might looks more like a fresh idea. But if that’s all agile programming is about, then it might not worth the hassle. My mentors first asked me what my scrum questions are. I was like, questions about scrum ? Yes please, I have tons of them, because I know nothing yet ! But, what scrums questions really mean is simple questions that each member of the team has to answer in each daily standup meeting. It is intended to keep the meeting short (< 15 min) and concise.…

Continue ReadingScrum journey

GSoC 2015 with FOSSASIA : the beginning

I was choosen as a student participant to Google Summer of Code 2015. It’s a program organized by Google that offers students stipends to write code for open source projects. Being selected is a big deal for me since GSoC is a vey selective program, and a meaningful way to spend my summer, by doing what I very much enjoy : coding. What’s more, students get paid doing it. I’m not denying that the $5500 stipend per student is really sexy (at least for me). It’s way more than most software interns in France get for a three months period. I just knew about GSoC two months ago thanks to a teacher. Before that, I have very little notion about open-source software, and none about GSoC. I cure my ignorance since then with a lot of interesting blogs and definitions. Based on the information I’ve been fed with, I could now say open-source is great. From the company’s point at view, it’s a great form of advertising. For the project, open-source often means better code and documentation. The developers knows the whole world has access to the source code, so they’ll probably take better care of it. Also, open-sourcing is a must if you want to create a vibrant community and ecosystem. Open-source is great, getting involved, even better. With GSoC you have the opportunity to work on an open-source project with mentoring support from the core developers who are maintaining it themselves. Awesome ! To get into the program as a student, you have to choose betweens accepted mentoring organizations and propose a project idea suited to them. I was particularly attracted to FOSSASIA, an open-source event community in Asia, and their project idea Extend toolbox for FOSSASIA and Freifunk API. The Freifunk/FOSSASIA API is designed to solve the problem of collecting data from different communities in a decentralized way. It makes some interesting parts of the FOSSASIA community site possible, e.g. the Common Map.  FOSSASIA logo I think the toolbox has a great potential to create a strong network between different communities at different locations, by providing attractive statistics visualization. With that spirit in mind, my project’s proposal aims to add new components and improve old ones. Here are some of them : Improve the json generator page Calendar service Community news / events panel Common Map filters : by country by technical area Statistic service / charts : communities counts active period panel based on news/events date (like the contribution panel on github) API Documentation web app etc. In my gsoc blog series, I’ll cherry-pick sutffs that I find valuable from my GSoC project to show to the world. So if you’re interested on what I’ll do, stick around for upcoming updates ! References : https://blog.fossasia.org

Continue ReadingGSoC 2015 with FOSSASIA : the beginning

Embed Leaflet map as coordinates picker

As a warm up task for my GSoC project, I want to embed a map to the FOSSASIA API generator form as a convenient way for users to provide their location coordinates. When the user clicks on a location on the map, two input fields Latitudeand Longitude will be automatically updated with fresh values. Here’s how. For this task you need jquery and leaflet - an openstreetmap library. You also want to prepare an empty div for the embed map : <html> <head> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/> </head> <body> <label for="latInput">Latitude</label> <input id="latInput"/> <label for="lngInput">Longitude</label> <input id="lngInput"/> <div id="map" style="height : 200px"></div> <script src="https://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script> <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> <body> </html> Now, let’s instanciate the div using the leaflet API. A tile layer must be provided, in this example I’m using mapbox but there are other tile providers as well : var mapCenter = [22, 87]; var map = L.map('map', {center : mapCenter, zoom : 3}); L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', { maxZoom: 18, attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 'Imagery © <a href="http://mapbox.com">Mapbox</a>', id: 'examples.map-i875mjb7', noWrap : true }).addTo(map); When the user clicks on the map, I want to point a marker to their choice and display a popup with choosen coordinates. That’s what updateMarker function is good for : var marker = L.marker(mapCenter).addTo(map); var updateMarker = function(lat, lng) { marker .setLatLng([lat, lng]) .bindPopup("Your location : " + marker.getLatLng().toString()) .openPopup(); return false; }; The last missing piece is, on map click event, updating the lat and lng inputs : map.on('click', function(e) { $('#latInput').val(e.latlng.lat); $('#lngInput').val(e.latlng.lng); updateMarker(e.latlng.lat, e.latlng.lng); }); Now if you need the other way around - enter manually the input fields to update the marker, it could be easily done as well, by capturing a useful event associated with HTML input tag - the… input event : var updateMarkerByInputs = function() { return updateMarker( $('#latInput').val() , $('#lngInput').val()); } $('#latInput').on('input', updateMarkerByInputs); $('#lngInput').on('input', updateMarkerByInputs); That’s about it ! Check out this tutorial on Gist and JSFiddle. References : FOSSASIA API generator page http://api.fossasia.net/generator/index.html https://blog.fossasia.org

Continue ReadingEmbed Leaflet map as coordinates picker

Explore PHP pthreads bugs

I’m developing a utility library called meteor-ddp-php, which makes heavy use of PHP pthreads. Once in a while, I encounters weird, unexplainable bugs that contradicts all my knowledge about computer & programming languages. They just really get me on my nerves. I want to share with you that experience in this post. Suppose I have a class B extending Thread and a class A which initiates and starts B: test.php <?php class B extends Thread { public function run() { $i = 100000000; while($i--); echo 'I\'m feeling lucky' . PHP_EOL; } } class A { public function startB() { $b = new B(); $b->start(); } } $a = new A(); $a->startB(); echo 'Be what\'s next' . PHP_EOL; Logically, the log I expected is (notice I put a considerable delay in B::run() - I didn’t use sleep because it is not thread-safe) : Be what's next I'm feeling lucky Instead, this is what I got by running php test.php : I'm feeling lucky Be what's next That’s just weird ! Apparently my child thread is blocking my parent thread, until it terminated. But wait for it. If I move the the echo line to the end of startB() method : class A { public function startB() { $b = new B(); $b->start(); echo 'Be what\'s next' . PHP_EOL; } } it works just fine. Seems like the problem is not that $b->start() is blocking, but the blocking point is rather at the return of startB() function ! Now, just for fun, how about I changed the variable $b in startB() from function-scope to object-scope instead ? It shouldn’t make any difference right ? ... class A { private $b; public function startB() { $this->b = new B(); $this->b->start(); } } $a = new A(); $a->startB(); echo 'Be what\'s next' . PHP_EOL; Well, it did. The example works as expected, with this little fix. That’s just crazy ! The scope of the variable shoudn’t have anything to do with the blocking thread problem. Using the second fix between these two, I dodged the bullet and go on with my application. I must admit I didn’t go over 300+ issues on the github page, and in one of them may lie the answer for all this madness. But still, these problems just demonstrate the myth of multithreading in PHP. PHP isn’t anywhere near thread-safe yet, even at basic language blocs like function call or variable scope it seems. Working with pthreads requires extreme care and patience. Visit here for real-life example.

Continue ReadingExplore PHP pthreads bugs

[Second Draft] Designing a document based collaboration interface

.. this post is the continuation of my first draft which you could find it here -http://dolftax.com/2015/04/Designing-a-document-based-collaboration-interface/. I would ask you to go through the first draft before proceeding here, because here I’ve explained only the wireframes which are modified/tweaked, based on the comments on the first draft. This post is structured as /me resolving the comments on my first draft, with the new wireframes and explaining the reasons for modification. Rooms could be nested #1 : We could not enforce a topic/subtopic structure because rooms can be deeply nested. Topics and subtopics are all rooms. The users are free to organize the rooms as they wish. They could be topics, they could be something else. At every level, there may be documents and more rooms. => Removed topic/subtopic structure. As the rooms are completely nested, a room could contain any number of sub-rooms. Rooms and documents are analogous to folders and files. But wait, there are containers which are multi-part documents. To get the clear idea of what we mean by containers- refer to the discussion we had IRC log -https://tr.im/UOZpT Shared and Private workarea #2: The basic elements in sTeam are users, groups, rooms and documents. Each group has a workarea connected to it, and each user has a private workroom. Each user is a member of at least one group. So when a user enters the server, there are at least two rooms: the users private workarea, and the workarea of the group, that the user is a member of. => Workarea implemented. Under shared workarea, the user will get list of all rooms and documents which he got access to. Under private workarea he would get list of his private documents and rooms, which when shared will move to the shared workarea. Shared Workarea Private Workarea If you notice, you could create a room or document only in your private workarea. When you change permissions for a room/document in your private workarea, it would be pushed to shared workarea automatically. Permissions are inherited If a room has rw permissions, then everything inside the room also has rw permissions. Room view - Level two Notice the settings icon? Except for the first level, (levels are tracked by the level/stage bar) a user could change room/document attributes with the help ofsettings icon which pops up a window with following options. The settings option appears only in the levels inner to level 1, because obviously, if the user is in the first level, he is not into any room. Navigation between rooms #3: The user can move from room to room. The server keeps track of where the user is, and actions taken (such as creating a document) are relative to the users location. Users can pick up documents (the document is moved from the room, to the user itself), move to another room and drop the documents there. => When a document is selected, the copy and paste buttons (look at the above wireframe. buttons next to sort…

Continue Reading[Second Draft] Designing a document based collaboration interface