EMAILS AND RESPONSIVE DESIGN

Posted: November 22, 2013 in development

Email Templates and media queries

These screenshots where taken on an iPad and an iPhone4

email-template on ipad mail
email template on ipad mail
email template on ipad mail
email template on ipad mail

email template on iphone4 mail
email template on iphone4 mail
email template on iphone4 mail
email template on iphone4 mail

<input type=”file” id=”files” name=”files[]” multiple />
<output id=”list”></output>

function handleFileSelect(evt) {
var files = evt.target.files;
var output = [],
item = ”;
for (var i = 0, f; f = files[i]; i++) {
var name = f.name.split(‘MissUniverse_SmallBubbles_’)[1].replace(‘.png’, ”);
var large_name = f.name.replace(‘SmallBubbles’, ‘LargeBubbles’);
item = {
“text”: “Miss ” + name,
“addText”: “”,
“twitter”: name,
“regBg”: “shows/miss-universo/buzzbubbler/images/bubbles/widget/” + f.name,
“lightboxBg”: “shows/miss-universo/buzzbubbler/images/bubbles/lightbox/” + large_name,
“flags”: [“MUni2013”]
};
output.push(item);
}
document.getElementById(‘list’).innerHTML = JSON.stringify(output);
}

document.getElementById(‘files’).addEventListener(‘change’, handleFileSelect, false);

referential transparency

Posted: September 3, 2013 in Uncategorized

The term “referential transparency” comes from analytical philosophy, the branch of philosophy that analyzes natural language constructs, statements and arguments based on the methods of logic and mathematics. In other words, it is the closest subject outside computer science to what we call programming language semantics. The philosopher Quine was responsible for initiating the concept of referential transparency, but it was also implicit in the approaches of Bertrand Russell and Alfred Whitehead.

At its core, “referential transparency” is a very simple and clear idea. The term “reference” is used in analytical philosophy to talk about the thing that an expression refers to. It is roughly the same as what we mean by “meaning” or “denotation” in programming language semantics. Using Andrew Birkett’s example (blog post), the term “the capital of Scotland” refers to the city of Edinburgh. That is a straightforward example of “reference”.

A context in a sentence is “referentially transparent” if replacing a term in that context by another term that refers to the same entity doesn’t alter the meaning. For example

The Scottish Parliament meets in the capital of Scotland.

means the same as

The Scottish Parliament meets in Edinburgh.

So the context “The Scottish Parliament meets in …” is a referentially transparent context. We can replace “the capital of Scotland” with “Edinburgh” without altering the meaning. To put another way, the context only cares about what the term refers to and nothing else. That is the sense in which the context is “referentially transparent.”

On the other hand, in the sentence,

Edinburgh has been the capital of Scotland since 1999.

we can’t do such a replacement. If we did, we would get “Edinburgh has been Edinburgh since 1999”, which is a nutty thing to say, and doesn’t convey the same meaning as the original sentence. So, it would seem that the context “Edinburgh has been … since 1999” is referentially opaque (the opposite of referentially transparent). It apparently cares about something more than what the term refers to. What is it?

Things such as “the capital of Scotland” are called definite terms and they gave no lean amount of head ache to logicians and philosophers for a long time. Russell and Quine sorted them out saying that they are not actually “referential”, i.e., it is a mistake to think that the are used to refer to entities. The right way to understand the above sentence is to say

Scotland has had a capital since 1999 and that capital is Edinburgh.

This sentence cannot be transformed to a nutty one. Problem solved! The point of Quine was to say that natural language is messy, or at least complicated, because it is made to be convenient for practical use, but philosophers and logicians should bring clarity by understanding them in the right way. Referential transparency is a tool to be used for bringing such clarity of meaning.

What does all this have to do with programming? Not very much, actually. As we said, referential transparency is a tool to be used in understanding language, i.e., in assigning meaning. Christopher Strachey, who founded the field of programming language semantics, used it in his study of meaning. His foundational paper “Fundamental concepts in programming languages” is available on the web. It is a beautiful paper and everybody can read and understand it. So, please do so. You will be much enlightened. He introduces the term “referential transparency” in this paragraph:

One of the most useful properties of expressions is that called by Quine [4] referential transparency. In essence this means that if we wish to find the value of an expression which contains a sub-expression, the only thing we need to know about the sub-expression is its value. Any other features of the sub-expression, such as its internal structure, the number and nature of its components, the order in which they are evaluated or the colour of the ink in which they are written, are irrelevant to the value of the main expression.

The use of “in essence” suggests that Strachey is paraphrasing it in order to explain it in simple terms. Functional programmers seem to understand this paragraph in their own way. There are 9 other occurrences of “referential transparency” in the paper, but they don’t seem to bother about any of the others. In fact, the whole paper of Strachey is devoted to explaining the meaning of imperative programming languages. But, today, functional programmers claim that imperative programming languages are not referentially transparent. Strachey would be turning in his grave.

We can salvage the situation. We said that natural language is “messy, or at least complicated” because it is made to be convenient for practical use. Programming languages are the same way. They are “messy, or at least complicated” because they are made to be convenient for practical use. That does not mean that they need to confuse us. They just have to be understood the right way, using a meta language that is referentially transparent so that we have clarity of meaning. In the paper I cited, Strachey does exactly that. He explains the meaning of imperative programming languages by breaking them down into elementary concepts, never losing clarity anywhere. An important part of his analysis is to point out that variables in programming languages have two kinds of “values”, called l-values and r-values. Before Strachey’s paper, this was not understood and confusion reigned supreme. Today, the definition of C mentions it routinely and every C programmer understands the distinction. (Whether the programmers in other languages understand it equally well is hard to say.)

Both Quine and Strachey were concerned with the meaning of language constructions that involve some form of context-dependence. For example, our example “Edinburgh has been the capital of Scotland since 1999” signifies the fact that “capital of Scotland” depends on the time at which it is being considered. Such context-dependence is a reality, both in natural languages and programming languages. Even in functional programming, free and bound variables are to be interpreted with the respect to the context in which they appear in. Context dependence of any kind blocks referential transparency in some way or the other. If you try to understand the meaning of terms without regard to the contexts they depend on, you would again end up with confusion. Quine was concerned with the meaning of modal logic. He held that modal logic was referentially opaque and it should be cleaned up by translating it into a referentially transparent framework (e.g., by regarding necessity as provability). He largely lost this debate. Logicians and philosophers alike found Kripke’s possible world semantics to be perfectly adequate. Similar situation also reigns with imperative programming. State-dependence explained by Strachey and store-dependence explained by Reynolds (in a manner similar to Kripke’s possible word semantics) are perfectly adequate. Functional programmers don’t know much of this research. Their ideas on referential transparency are to be taken with a large grain of salt.

[Additional note: The examples above illustrate that a simple phrase such as “capital of Scotland” has multiple levels of meaning. At one level, we might be talking about the capital at the current time. At another level, we might talking about all possible capitals that Scotland might have had through the course of time. We can “zoom into” a particular context and “zoom out” to span all contexts quite easily in normal practice. The efficiency of natural language makes use of our ability to do so. Imperative programming languages are efficient in very much the same way. We can use a variable x on the right hand side of an assignment (the r-value) to talk about its value in a particular state. Or, we might talk about its l-value which spans all states. Grown-up people are rarely confused by such things. However, they may or may not be able to precisely explain all the layers of meaning inherent in language constructs. All such layers of meaning are not necessarily ‘obvious’ and it is a matter of science to study them properly. However, the inarticulacy of ordinary people to explain such layered meanings doesn’t imply that they are confused about them.]

A separate “postscript” below relates this discussion to the concerns of functional and imperative programming.

source: http://stackoverflow.com/questions/210835/what-is-referential-transparency

app.post('/upload', function(req, res, next) {
    var is = fs.createReadStream(req.files.upload.path),
        fileType = getExtention(is.fileName)
        os = fs.createWriteStream('public/images/users/' + req.session.adress + '.' + fileType);
});

function getExtension(filename) { var ext = path.extname(filename||'').split('.'); return ext[ext.length - 1]; }

//function getExtension(filename) {
    //var i = filename.lastIndexOf('.');
  //  return (i < 0) ? '' : filename.substr(i);
//}

widget

Posted: July 12, 2012 in Uncategorized

by Aneudy Abreu Reynoso, Elements of Sociology 1101-1776

The XLVI Super Bowl

The super bowl, rather than being just a popular event  is like a holiday for most people. The food and drink sales reach astonishing levels. The famous chicken wings turn into a temptation really hard to avoid. The majority of companies take advantage of the vast number of viewers to present their commercials, which are always funnier, more attractive, and certainly more expensive than usual time slots. According to Yahoo!®Sports, the XLVI Super Bowl had 111.3M viewers and 166.8M who watched at least part of the game. Some of those people  watched the game for the commercials or for the half-time show on which Madonna was viewed by an average of 114 million. Whether they watched it for the commercials or because they really follow the game, what is certainly true is that a lot of people from different cultures, customs and countries were more than just watching the same game but having something in common. This is one of the events on which the social status, economic position or even your ethnic group does not matter. That day we all were either Giants or Patriots. Almost all of New York was dressed up with blue colors, even the Empire State was illuminated blue.

The eve before the game some of my friends told me that the Super bowl was one of the most important events for the American people. This statement drew me to the following questions? Is it really important for American people only? Does anyone else watch the game? Why do they watch it?  I did not find the answer browsing the Internet. Instead,  I woke up Sunday  morning early,   grabbed my pad and went out to survey people in the streets. I live in  a crowded sector of Hispanic people so I started with them. To my surprise I found  that 6 out of 10 young people were going to watch the game. When I asked them why they were watching it, some of them told me “because I like the commercials,” others were a bit more sincere and confessed to not knowing anything about the game, but they did not want to miss it. I also interview some others Hispanic people who told me they were planning not just to watch the game but to go to a bar with friends and enjoy  the classic big screen, a lot of chicken wings and beer.

While doing my survey all day long I met people from totally different cultures where American football is not practiced but they were still watching the game that day.  After seeing the result of my survey I looked back to my first days in New York. My brother took me to Times Square to see all of the huge billboards and all of the stunning lights. I remember I wasn’t that amazed but at some point when I started to look around I found myself staring at a woman whose skin hue was totally unfamiliar to me. Without exaggerating she seemed to me to have an orange color. Then I  noticed that I was surrounded by people from all over the world. None of us shared anything in common except for one thing; we all wanted either live in or visit New York City. We all wanted to be a New Yorker. That is where the sociology perspective comes onto the scene. According to an article posted on http://www.CliffsNotes.com “sociologists analyze social phenomena at different levels and from different perspectives. From concrete interpretations to sweeping generalizations of society and social behavior, sociologists study everything from specific events (the micro level of analysis of small social patterns) to the “big picture” (the macro level of analysis of large social patterns).” It’s at that macro level that the social phenomenon of the  Super Bowl has become a mass-media event. Either by their own way or via the “standard” way of following and enjoying the game, people go through the same social patterns.

The XLVI Super Bowl

References

Anthony Riccobono, Sport&Starts, Super Bowl Ratings: How many people will be watching in 2012? (2012)  <http://www.ibtimes.com/articles/292823/20120203/super-bowl-ratings.htm&gt;

CliffsNotes.com. Three Major Perspectives in Sociology. 10 Feb 2012

<http://www.cliffsnotes.com/study_guide/topicArticleId-26957,articleId-26837.html&gt;.

Yahoo!®Sports, Super Bowl draws record 111.3M viewers on NBC (2012)

< http://sports.yahoo.com/nfl/news?slug=ap-superbowl-ratings&gt;