Updated on February 9, 2015
Type casting type
Updated on February 15, 2019
CIRP Citation Style for Mendeley
For previous academic work I have been using EndNote as my reference manager. Unfortunately it wasn’t possible to use it at the company where I am doing research for my thesis due to heavy software limitations. So I switched to Mendeley, a great alternative in which you can manage your reference online as well. And using a little trick found in the forums of PortableApps.com I was able to run the desktop version of Mendeley on my company provided laptop.
But the next step was to use the correct citation style for my thesis. Unfortunately the one I need, based on the CIRP Journal of Manufacturing Science and Technology, wasn’t yet available. So the only way was to create it myself using the great visual editor Mendeley provides. For those interested, you can download the CIRP Citation style for Mendeley here:
Download
Since the CIRP annals are not very extensive about the citation styles I have made a couple of assumptions on how to display several items based on the general IEEE citation style. However if you think it needs changes please contribute to the style and adjust it accordingly!
For those interested, you can read more about my thesis on the Circular Economy on my blog.
Updated on May 19, 2015
Call a previous AJAX request again
For a project I was trying to solve the issue of session timeouts while not frustrating the user after an ajax call. So the previous ajax call had to be saved and executed again after a successful log-in.
For example you have some management system that is open for a long time, but for safety sessions are not kept alive too long. However people might find themselves in the situation that they were still working on something while their session expired. So it would be nice for a user to execute an action, be prompted with a log-in form, and if it succeeds the original ajax call will automatically be made.
I used the CodeIgniter platform which has some nice functions to set the headers as well as jQuery for easy ajax handling. In the solution I propose it would be best to have proper handling of request headers. As W3C specs define the 401 Unauthorized is returned in case:
- the request requires user authentication.
- If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials.*
* i.e. the credentials were wrong or the the person is just not authorized
So to achieve this you first want to keep track of previous ajax calls. First of all we will extend the jQuery ajax object with an extra array called mostRecentCalls
.
1 2 3 | $(document).ready(function(){ $.ajax.mostRecentCalls = []; }) |
Then we keep track of each completed ajax call using $.ajaxComplete();
Because you might have several different ajax call throughout your website that should not interfere (for example timed polling of messages or notifications, some user statistics polling, etc.) it would be best to define namespaces for each type of ajax request that you want to keep the most recent from.
1 2 3 4 5 6 7 8 9 | $(document).ajaxComplete( function(ev, jqXHR, settings){ if(!(settings.namespace === false || typeof settings.namespace === 'undefined')){ // create new namespace if it does not exist yet. if(!$.isArray($.ajax.mostRecentCalls[settings.namespace])){ $.ajax.mostRecentCalls[settings.namespace] = []; } $.ajax.mostRecentCalls[settings.namespace] = settings; } }); |
In our ajax call we can then access the previous ajax call. Generall your current ajax call probably looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 | $.ajax({ url: 'my/request/url', data: myDataObj, success: function(data){ // data will be object with your content, // set it as content to your object $(target).html(data.myHtml); }, error: function(response){ alert('an error occured') } }) |
Yes, it’s not very neat error handling, but its just an example. You might also have defined deferred object methods like .done()
and .fail()
, however to make this work neatly you must extend the ajax object with at least the success callback as above. This way we can just have the previous saved settings used for the $.ajax object and all is set.
So how would that look like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | $.ajax({ url: '', namespace: 'SPECIFIC_AJAX_CALL_ID', // success callback must be in the $.ajax object success: function(data){ // successful request, do whatever you want :) $(target).html(data.myHtml); }, // error callback may be in the $.ajax object, but can also be set as deferred .fail() method // error function shows the log-in form in case of 401 response error: function(response){ if(response.status == 401){ // move login form to your target // (assumed you already have a login form somewhere ;)) $(target).html($('#login-form')); // handle the log-in form $('#form-login', $(target)).on('submit', function(e){ // submit the form by ajax $.ajax({ url: $('#form-login').attr('action'), type: $('#form-login').attr('method'), data: $( '#form-login' ).serialize() }) .done(function(response){ // execute previous ajax call $.ajax( $.ajax.mostRecentCalls['SPECIFIC_AJAX_CALL_ID'] ); }) .fail(function(response){ // show the log-in form once more, now with an error $('h2', '#form-login').after('Your credentials were wrong.') $('#form-login').get(0).reset(); }) e.preventDefault(); return false; }) } } }) |
Good luck!
Updated on October 13, 2013
DoToKnow
After nearly a year of working on a new collaborative portfolio platform it is about time to start announcing it.
With a couple of friends I have been working on DoToKnow. A website on which you can keep track of your projects alone or together, and with that automatically updating your portfolio. This way you can build great portfolios based on any kind of project. Whether you work on it alone (building a bike) or together with colleagues (designing a building). By keeping track of your project you are not only building your portfolio but you can share your knowledge with others and you can gain their knowledge again. Because for sure there are more people around the world working on a similar project facing the same problems and tackling them identically. So why spend all that time reinventing the wheel again while the answers are right out there?
With this platform we hope to open up new resources of information while your able to build a great portfolio or exhibit of your work. Of course we aim for the best privacy standards and allowing you to choose whether to share information or not. But we hope you will since only together we can make the next step!
So if you are interested, feel free to subscribe now. Soon we hope to open up the Beta and allowing you to try out this new great platform!
Updated on May 19, 2015
Biofuels a renewable or limited energy resource?
After a quick research done on the topic of the Double Counting policy induced by the Renewable Energy Directive of the European Union I came to several preliminary conclusions about biofuels.
Basically the question is whether biofuels are – as currently seen by many governments and organisations – a sustainable future energy resource. There are some worrying consequences based on forecasts. Especially the required land usage and nutrients (fertilizers) needed to produce all those biofuels is still of great concern. The preliminary conclusion is that due to the limited resource of phosphates and nitrates (required to grow the algae or other crops for biofuels) as well as land usage, biofuels can be seen as a limited resource. This would mean that it is questionable whether biofuels can be seen as a renewable resource.
Why?
Well to answer in short: The expected demand for biofuels will increase a ten fold in 40 years. This means that we will rely more on dedicated grown feedstock for biofuels since residues or waste based feedstock for biofuels is limited – we are not going to eat more potatoes to generate more waste. The increased dedicated grown feedstock will increase demand of nutrients such as phosphates and nitrates. Since these are limited (the easy to mine nutrients) it will have consequences for the availability and price of fertilizers and cause increased competition between agriculture for food production and biofuel production. Also land is a limited resource to grow the feedstock for biofuels, another factor competing with agriculture for food production. The land change required to grow the crops for biofuels also has consequences on increased carbon emissions, increased monocultures and less biodiversity.
Below you can find the poster with some more information from this small research. Unfortunately it does not cover everything due to time restrictions, however I hope to present a more thorough paper here sometime soon.
Updated on February 15, 2019
Removing Ambiguous Anchors in Illustrator
Sometimes after merging shapes it happens that a vector in illustrator has anchors that you don’t need. These anchors might prevent you from doing some other great things with your vector. Unfortunately the simplify function of Illustrator is not sufficient enough to get rid of those, so that is why I wrote a little Illustrator script to get rid of the annoying redundant anchor points.
For a recent project I created some simplified maps of Europe with either horizontal, vertical or 45 degree lines. With the Live Paint Bucket tool I was able to fill a grid built up of triangles. This way I created the borders of countries in a simplified way. However after I tried to stylise the vectors by applying rounded corners to it I noticed that only a few corners were rounded.
After zooming to 6400% I noticed the following. Many corners anchors in my path had redundant anchors close around them:
Unfortunately I could not find any plugins that can solve this issue by removing the redundant anchors. So I decided to write my first Illustrator Script.
The script is not optimal yet, but it worked like a charm in most of my use cases. These are some of it functionalities:
- It removes the redundant anchors
- Several methods to determine the optimal anchor (which one to keep), or interpolate between the possible options. It does this by looking one anchor back and one ahead of the group of ambiguous anchors.
- It can solve multiple groups of anchors at the same time (be careful that
- Adjust the threshold of how close anchors may be together to be called ambiguous
Download & How to use:
Download- Download the script.
- Save it your Adobe Illustrator Presets/Scripts folder. In my case that was: file:\%ProgramFiles%AdobeAdobe Illustrator CS6 (64 Bit)Presetsen_GBScripts
- Open your file with ambiguous anchors
- Select with the Direct Selection Tool (A) part of a path, or select an entire path
- Execute the script by going to File > Scripts > RemoveRedundant
- If the script is not present in this submenu, either you did not save it at the right place, or you have to restart Illustrator
- You can also navigate to the script by clicking on Other Script…
Options:
There are some global variables you can change to optimise the script for your usage. You should open the script in a text editor to do so.
- Turn on debugging (several alerts will be presented when executing the script), default is off
- Show a prompt dialog when executing the script to ask for the precision (threshold) for finding redundant anchors, default is off
- The default precision. The default is 0.1; (I have used it between 1 and 0.01)
- Maximum number of anchors to evaluate. This is a precaution to prevent your illustrator from freezing. Default is 100 anchors.
Issues:
- Trying to solve too many anchors, or heavily anchored paths at the same time might freeze illustrator
- Sometimes certain ambiguous groups are completely removed (could not identify yet how). This happens often when multiple groups are being solved in one go. To prevent this select one group of ambiguous anchors at the same time.
- Grouped paths will be skipped at the moment. So select your path at the lowest level possible!
- It only works for straight cornered anchors. If you have smooth anchors these will be converted to corner anchors.
- On large files it can be a bit slow
If you come across any issues or have some suggestions please let me know! In some future I might try to turn this into a proper plugin which would make the script run much smoother and faster.
Updated on July 15, 2013
Smarty’s hidden global variables
Recently I have been working on some web design projects in which we are using the templating parser Smarty. And even though the parser itself is very extensive, the documentation is not. To use variables across nested template files you need to globalise variables. I wrote a tiny Smarty plugin that does this job for you.