Monday, December 19, 2016
Saturday, December 17, 2016
Friday, December 16, 2016
Food pairing
There is a popular article about food pairing: http://www.nature.com/articles/srep00196
The article says that Western cuisines show a tendency to use ingredient pairs that share many flavour compounds, supporting the so-called food pairing hypothesis. By contrast, East Asian cuisines tend to avoid compound sharing ingredients.
But the "food pairing hypothesis" was actually confuted in this sensory test: https://jcunieuws.files.wordpress.com/2008/06/food-pairing.pdf
I am wondering if any progress has been done lately in this field.
In Tuscany, the region I am originally from, we combine these foods:
The article says that Western cuisines show a tendency to use ingredient pairs that share many flavour compounds, supporting the so-called food pairing hypothesis. By contrast, East Asian cuisines tend to avoid compound sharing ingredients.
But the "food pairing hypothesis" was actually confuted in this sensory test: https://jcunieuws.files.wordpress.com/2008/06/food-pairing.pdf
I am wondering if any progress has been done lately in this field.
In Tuscany, the region I am originally from, we combine these foods:
- Prosciutto e Melone (Italian Ham and Melon)
- Salame e Fichi (Tuscany Salami and Figs)
- Pane e Uva (Bread and Grapes)
- Cacio e Pere (Pecorino Toscano cheese and Pears)
Radio stations from any corner of the globe
Radio Garden, a nicely crafted website from Studio Puckey in Amsterdam.
Listen to radio stations from any corner of the globe: http://radio.garden/
Listen to radio stations from any corner of the globe: http://radio.garden/
Saturday, December 10, 2016
Chat Bots in Javascripts
Playing with Chat Bots with Node.js. Here there is a good tutorial:
https://www.smashingmagazine.com/2016/10/how-to-develop-a-chat-bot-with-node-js/
https://www.smashingmagazine.com/2016/10/how-to-develop-a-chat-bot-with-node-js/
Tools
Lists
Examples
- eBay ShopBot https://www.messenger.com/t/ebayshopbot
- PokeBotai https://www.messenger.com/t/pokebotai
- Swell http://www.swell.wtf/
- Food Network https://www.messenger.com/t/FoodNetwork/
Thursday, December 8, 2016
How many scripts?
How many pieces of script are running on a page?
I counted them in the HTML Source and in the DOM running the script below in the console for each website.
The number of external Javascript files is from the Console > Network > JS
I counted them in the HTML Source and in the DOM running the script below in the console for each website.
The number of external Javascript files is from the Console > Network > JS
Saturday, December 3, 2016
The Shape is the Food
During the last trip in Sicily I have been eating often delicious Arancini. The filling can be various, such as Ragu, Cheese and Ham, Egg plants, etc. To guess the content of Arancini they just give them different shape. I wonder if this system could be used also for onigiri. I have always been struggling to guess their content.
And, out of curiosity curiosity, let's see how Google is doing in recognising Arancini shapes:
Google doesn't know yet that Arancini come in multiple shapes.
No luck also with Microsoft's CaptionBot:
This is the full Google's answer:
Two arancini (foreground and background) |
Onigiri at Konbini |
Google doesn't know yet that Arancini come in multiple shapes.
No luck also with Microsoft's CaptionBot:
This is the full Google's answer:
Tuesday, November 29, 2016
Simple way to embed html in javasript
If you are not working with React and JSX, this could be a quick way to embed html inside Javascript...
Sunday, November 13, 2016
Food Recipes: Semantic representation, Formal Language and Visualization
I always enjoyed the precision that programming languages commands give instructions to computers and I have been wondering if that precision could be applied to food recipes.
If computers could understand semantically a recipe, they would be able to perform many interesting tasks.
For example a computer could
Other formats:
Video could also be used. Animation could fit better because could be generated in CG. I personally like this point of view in recipe video:
And as a final note, this is a video of my mother that I took several years ago. Not a good example of clarity but... a good recipe:
If computers could understand semantically a recipe, they would be able to perform many interesting tasks.
For example a computer could
- Scale the recipe: Not only multiplying ingredients but also adjusting the time and the difficulty
- Merge recipes fitting one into another taking advantage of the idle moments. It would be possible to plan several recipes with a certain deadline. Something like "I want to prepare Risotto alle Fragole and Arista for 3 people and everything should be ready by 7 pm". This is as example of simplified merging process:
- Combine recipes to come out with new variation. There is the "Computer Cooking Contest" that is trying to achieve this result. The event is organised every year, see in the resources section for links.
- Using a version control system, such as Git, where could have people to add variations of the recipe creating branch, merging, committing, etc.
- Computers could, with the help of a machine or robot, cook for you
Visualization
If the recipe is semantically represented inside the computer, it could be automatically visualised using some algorithm. A viable format could be similar to:Other formats:
Video could also be used. Animation could fit better because could be generated in CG. I personally like this point of view in recipe video:
Resources
A method for extracting major workflow composed of ingredients, tools, and actions from cooking procedural text
By Yoko Yamakata, Shinji Imahori, Hirokuni Maeta, Shinsuke Mori (2016)
A method for extracting a major workflow of cooking procedure from a Japanese recipe on the Web. It is utilized for various applications including recipe search, summarization, and visualization.
http://www.ar.media.kyoto-u.ac.jp/publications/yamakata-CEA16.pdfTraining the PR2 in Culinary Arts. A Natural Language Model for Parsing Recipes
By Jessica Zhao, Alejandro Bordallo, Subramanian Ramamoorthy (2016)
a culinary language model for the kitchen by abstracting cooking instructions into a generalized tripartite form of ACTION, TARGET, TOOL.
http://stanford.edu/~jesszhao/files/PR2cooking.pdfPredicting the Structure of Cooking Recipes
By Jermsak Jermsurawong and Nizar Habash (2015)
An ingredient-instruction dependency tree data structure to represent recipes. The proposed representation allows for more refined comparison of recipes and recipe - parts, and is a step towards semantic representation of recipes
http://www.aclweb.org/anthology/D/D15/D15-1090.pdfFlow Graph Corpus from Recipe Texts
By Shinsuke Mori, Hirokuni Maeta, Yoko Yamakata, Tetsuro Sasada4 (2015)
An attempt at annotating procedural texts with a flow graph as a representation of understanding.The domain we focus on is cooking recipe.
https://pdfs.semanticscholar.org/7f88/398e8928d32366ebf725eb457cb2fa3a94bf.pdf
Monday, November 7, 2016
10 Criterias to Judge a Good Milk Container
#1 Openability |
BAD
This container is difficult to open. It require, at first to remove the blue cap. Then there is a small handle that need to be pulled. Sometime it breakes and the pulling action, due to the strenght required, may make you spill some milk |
GOOD
This container is Easy to open knowing the method. Can be opened with two single steps using one hand while the other hold the bottle. The moviment are slow and would not cause any spill |
---|---|---|
#2 Closability |
BAD
The cup net to be screwed to close so it requires some work. It is a separate object that can get lost. It doesn't seal the container ermetically but it gives the false impression that it does so someone may try to store it horizzontally causing milk to spill |
GOOD
To close the container it is enough to fold it back. It doesn't seal ermetically but it is close enough |
Tuesday, November 1, 2016
GPS nmea GPX (or KLM) converter for Google Maps
This script take large amount of GPS data in nmea format and convert into gpx format to import into Google maps.
I had large amount of data coming from a trip to Iceland and I wanted quicly import it on Google My Maps.
Google has a limit of 5 MB but my data was 90 MB.
To reduce the data the script
There are two variables that you can adjust to get an putput file smaller than 5 MB. In my case the best compromise was
This generate an ouput file of 4,5 MB
Using instead
The output file was 6 MB
The output files are in the folder data.
I had large amount of data coming from a trip to Iceland and I wanted quicly import it on Google My Maps.
Google has a limit of 5 MB but my data was 90 MB.
To reduce the data the script
- only export latitude and longitude
- approximae the latitude and longitude values reducing the number of decimal digit
- skeep points
There are two variables that you can adjust to get an putput file smaller than 5 MB. In my case the best compromise was
- savePointsEvery = 4
- precision = 6
This generate an ouput file of 4,5 MB
Using instead
- savePointsEvery = 4
- precision = 6
The output file was 6 MB
The output files are in the folder data.
Source
Find the source at https://github.com/lucamug/gps-converterExample
This is the result after imported in Google Maps:Thursday, October 20, 2016
Minimal List of Recipes
This is a minimal list of recipes that we all should learn
Italian
Italian
- Frittata di patate
- Frittata di zucchine
- Rostinciana
- Pollo con funghi secchi
- Pollo con uovo e limone (fricassea)
- Baccala con patate in umido
- Fagiolini in umido
- Arista
- Braciole con limone
- Crostini di fegatini
- Insalata russa
- Panzanella
- Carciofi con pomodor e farina
- Uova ripiene con tonno
- Ribollita
- Fagioli uccelletto (e salsiccia)
- Crostini salsiccia e crostini
- Minestra
- Minestra di fermaggio e uova (stracciatella)
- Palline di ricotta e spinaci
- Sugo di Cinghiale
- Trippa
- Carciofi crudi con limone e parmigiano
- Porcini pasta
- Aspara pasta
Japanese
Monday, October 10, 2016
Downloading Google Spreadsheets with Javascript to Json
A small script to download a Google Spreadsheet with multiple worksheet in Javascript.
This is the script and the output in Json format
This is the test Spreadsheet
This is the script and the output in Json format
This is the test Spreadsheet
Sunday, October 2, 2016
CSS Responsive Mini-framework with Resizable sections
This is an experimental Sass/CSS mini-framework for building responsive sites with Resizable (Zoomable?) sections.
Resizable sections enlarge proportionally with the viewport size. These areas are based on relative CSS units as explained in Building Resizeable Components with Relative CSS Units.
I also wanted to have a minor-font-size-scaling, a small font increase that would apply to everything in the page.
Breakpoints are at regular interval. They can be customized but for the example below I have the first breaking point at 34em (544px) and the next with interval of 14em (224px).
The other breaking points are at 48em (768px), 62em (992px), 76em (1216px) and 90em (1440px).
Resizable sections enlarge proportionally with the viewport size. These areas are based on relative CSS units as explained in Building Resizeable Components with Relative CSS Units.
I also wanted to have a minor-font-size-scaling, a small font increase that would apply to everything in the page.
Breakpoints are at regular interval. They can be customized but for the example below I have the first breaking point at 34em (544px) and the next with interval of 14em (224px).
The other breaking points are at 48em (768px), 62em (992px), 76em (1216px) and 90em (1440px).
Tuesday, September 27, 2016
Are all html element closed? Testing it with Javascript
This small snippet check if all html tags are properly closed.
The html can be passed as a string or as an array containing html strings. It is based on the work of Jonathan Aquino that has an online form that has a similar script implemented: http://jona.ca/blog/unclosed-tag-finder
The script run both in NodeJS and in the browser console. I added also a function that allow to test the html coming from a server using the URL.
The usage is:
凸.checkHtml("your html here")
or
凸.checkHtml(["your html here", "and here"])
If you want to check a page served by a server:
凸.buildGetPageFunction()('http://example.com', function(data){console.log(凸.checkHtml(data))})
The html can be passed as a string or as an array containing html strings. It is based on the work of Jonathan Aquino that has an online form that has a similar script implemented: http://jona.ca/blog/unclosed-tag-finder
The script run both in NodeJS and in the browser console. I added also a function that allow to test the html coming from a server using the URL.
The usage is:
凸.checkHtml("your html here")
or
凸.checkHtml(["your html here", "and here"])
If you want to check a page served by a server:
凸.buildGetPageFunction()('http://example.com', function(data){console.log(凸.checkHtml(data))})
Saturday, September 24, 2016
Wait for Something - When Javascript onload event is not enough
Recently I needed to take actions on certain element of the DOM that would be created by other script and I also needed to take actions when images contained in these element where completed loaded.
The onload event seemed not fitting completely this purpose so I wrote this small function.
The onload event seemed not fitting completely this purpose so I wrote this small function.
- The function simply check the existence of the element (or any other condition) and when the condition is met, it execute the callback function.
- If the condition is not met, it sets a timer to call itself again.
- If after certain number of attempts the condition is still not met, the function stops.
Sunday, September 4, 2016
Minimum Font Size Checker
Simple script to highlight text that is rendered with a font smaller than certain threshold. .
Copy and paste the snippet in the console of any website and run the following commands.
To highlight the small fonts run:
Is also possible to add two parameters: Minimum font size and color. For example:
If the page adjust fonts size using proportional units (rem, em, vw, vh, vmin or vmax) you need to re-run the highlight command at every screen size that you would like to check.
Copy and paste the snippet in the console of any website and run the following commands.
To highlight the small fonts run:
凸.SmallFontChecker.highlight()This will highlight in purple color all the text that is smaller than 14 pixels.
Is also possible to add two parameters: Minimum font size and color. For example:
凸.SmallFontChecker.highlight("13px", "red")To restore to the original version you can run the command
凸.SmallFontChecker.reset()After restoring the page you can run the highlight command with different parameters.
If the page adjust fonts size using proportional units (rem, em, vw, vh, vmin or vmax) you need to re-run the highlight command at every screen size that you would like to check.
How it Works
- First the script traverse the entire DOM and check all elements to see if the font size is under the threshold. To do so it uses the global method getComputedStyle (Documentation: https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle)
- If the font is under the threshold, it saves the inline style in "sfc-originalStyle" attribute so that the original style can be restored
- Second it traverse the DOM again and change the font size and font color adding inline stiles.
- It is two steps process because children elements are influenced by parent element the script would fail detecting small font in children
- The recursive function to traverse the DOM is inspired by (copied from?) a script of Douglas Crockford (video)
Sunday, August 21, 2016
Balanced Responsive Grid
I needed to create a responsive grid of logos and this is what I have done.
The just making the image position absolute and adding some style fix the rest. I used max-width and max height = 75% because I wanted to leave some margin around the logo.
The page is much better but I want to limit the max-size of the logo to a certain value, let's say 200px.
The media query is
This would be the conclusion of the exercise until I noted that some font look larger than other. It is just a feeling because the logo share all the same container. Well, probably not just a feeling but it depends on the shape of the logo and eventually on the area of the logo.
So I decided to use the aspect ratio to influence the size of the logo. I eventually came out with this formula:
The calculation of a new percentage of the image require width and height of the logo. These values are available once the image is loaded so it would be reasonable to apply the new percentage on the onload event for each image.
Unfortunately the onload event for image has several issues so I decided to go for a much more inelegant way of just waiting, using timers, for when the sizes are ready. There are probably better solutions than this.
While waiting for the new percentage to kick in, I let the css style to resize logos to an average size. So, in my example I will change the size of images from 90% to 50%, depending on the ratio.
Logos contained in a squared shape with a ratio of 1 will have a percentage of 50%; rectangular logos that have one side 4 times or more longer than the other will have a percentage of 90%. Everything else goes in between these two limit cases.
This is the final result (note how the rectangular logos shrink and the square logo enlarge):
Step 1
I started creating a simple html with the img nested in couple of divs. Then I used the old fashioned float left. Is possible to use flex boxes for a better result. The first result was horrible due to the fact that images have all sort of pixel size and ratio.Step 2
To adjust the things I decided to go with the padding-bottom-trick. Having padding-bottom equal 100% insure that the hight of the div is always square because it relate to the width of the parent div.The just making the image position absolute and adding some style fix the rest. I used max-width and max height = 75% because I wanted to leave some margin around the logo.
The page is much better but I want to limit the max-size of the logo to a certain value, let's say 200px.
Step 3
So I added some math to the Sass that would generated media queries. I started with logos occupying 100% of the screen, so as soon the screen reach 200px I needed to add a media query that would the logos going in two columns.The media query is
@media (min-width: 200px) { .logo { width: 50%; } }When those two logos reach again the maximum width, the screen will be at 200px * 2 = 400px. Time to add a new media query:
@media (min-width: 400px) { .logo { width: 33.33333%; } }And so on. To simplify the list of media queries I first created a mixin like
@mixin mediaQuery($lev) @media (min-width: $max-element-size * $lev) width: percentage( 1 / ( $lev + 1 ) )Then I created a loop that generate the media query with the mixin
@while $level < $max-levels @include mediaQuery($level) $level: $level + 1Now the page adjust itself beautifully and logos width is never wider than 200 pixels.
This would be the conclusion of the exercise until I noted that some font look larger than other. It is just a feeling because the logo share all the same container. Well, probably not just a feeling but it depends on the shape of the logo and eventually on the area of the logo.
Step 4
So I was thinking to calculate the area of the logo to compensate the size but calculating the are may be not trivial as it depend on the shape of the logo and not just the size of the image. Round logos have less area compare to the squared one.So I decided to use the aspect ratio to influence the size of the logo. I eventually came out with this formula:
Size of the image (percentage) = minPerc + ((( maxPerc - minPerc ) / ( maxRatio - 1 )) * ( r - 1 ) );Dove r is the ratio of the image that can go from 1 for squared logos to a very large number for rectangular logos. A logos of size 100px horizontal and 50px vertical would have a ratio of 100/50 = 2. The ratio in this case ignore if the logo is bigger horizontally or vertically. So, to calculate the ration I used this formula:
r = Math.min( Math.max(x,y) / Math.min(x,y), maxRatio );Where maxRatio is the maximum ratio that I will take in consideration. In my example I use 4 so that all logos that have a side longer more than 4 times the other side will all be treated in similar way.
The calculation of a new percentage of the image require width and height of the logo. These values are available once the image is loaded so it would be reasonable to apply the new percentage on the onload event for each image.
Unfortunately the onload event for image has several issues so I decided to go for a much more inelegant way of just waiting, using timers, for when the sizes are ready. There are probably better solutions than this.
While waiting for the new percentage to kick in, I let the css style to resize logos to an average size. So, in my example I will change the size of images from 90% to 50%, depending on the ratio.
Logos contained in a squared shape with a ratio of 1 will have a percentage of 50%; rectangular logos that have one side 4 times or more longer than the other will have a percentage of 90%. Everything else goes in between these two limit cases.
This is the final result (note how the rectangular logos shrink and the square logo enlarge):
Saturday, July 23, 2016
Small Node/Javascript code to upload a file using sftp
This script upload a file using sftp. Before running it be sure to
- Install NodeJS
- Install ssh2 (npm install ssh2)
- Fill the parameters at the top of the file
Tuesday, May 3, 2016
A way to embed html in javasript
If you are not working with React and JSX, this could be a quick way to embed html inside Javascript...
Sunday, February 7, 2016
Intentional or not?
Happened to me several time that I buy food in a box with a nice picture on it and the content is very different from the picture.
Today I found a product with an actual window in the box where I could see the real product. So, no surprises!
But... it seems that the only two nuts inside were just in the position of the window.
Today I found a product with an actual window in the box where I could see the real product. So, no surprises!
But... it seems that the only two nuts inside were just in the position of the window.
Subscribe to:
Posts
(
Atom
)