03
Jun 14

“Swift” is Syntactic Sugar

download The “new” Swift programming language from Apple is nothing more that syntactic sugar on top of Javascript.

A few examples from Swift Welcome page and Swift Tour page

Example 1:

Swift code:

============================
let people = ["Anna": 67, "Beto": 8, "Jack": 33, "Sam": 25]
for (name, age) in people {
println("\(name) is \(age) years old.")
}
==============================

JS code ( http://jsfiddle.net/SSD9Y/1/ ) :

============================
var people = {"Anna": 67, "Beto": 8, "Jack": 33, "Sam": 25}

for ( person in people ) {
alert( person + " is " + people[person] + " years old.")
==============================

Example 2:

Swift code:

============================
let cities = ["London", "San Francisco", "Tokyo", "Barcelona", "Sydney"]
let sortedCities = sort(cities) { $0 < $1 }
if let indexOfLondon = find(sortedCities, "London") {
println("London is city number \(indexOfLondon + 1) in the list")
}
==============================

JS code ( http://jsfiddle.net/pYWb9/1/ ) :

============================
var cities = ["London", "San Francisco", "Tokyo", "Barcelona", "Sydney"]
var sortedCities = cities.sort()

indexOfLondon = sortedCities.indexOf("London")+1
alert("London is city number " + indexOfLondon + " in the list")
==============================

Example 3:

Swift code:

============================
var shoppingList = ["catfish", "water", "tulips", "blue paint"]
shoppingList[1] = "bottle of water"

var occupations = [
"Malcolm": "Captain",
"Kaylee": "Mechanic",
]
occupations["Jayne"] = "Public Relations"
==============================

JS code ( http://jsfiddle.net/p3FM6/1/ ):

============================
var shoppingList = ["catfish", "water", "tulips", "blue paint"]
shoppingList[1] = "bottle of water"
var occupations= {Malcolm: 'Captain',Kaylee:'Mechanic'}
occupations["Jayne"] = "Public Relations"
==============================

Example 4:

Swift code:

============================
let individualScores = [75, 43, 103, 87, 12]
var teamScore = 0
for score in individualScores {
if score > 50 {
teamScore += 3
} else {
teamScore += 1
}
}
teamScore
==============================

JS code ( http://jsfiddle.net/s9DF5/1/ ):

============================
var individualScores = [75, 43, 103, 87, 12]
var teamScore = 0
for (score in individualScores) {
if (score > 50) {
teamScore += 3
} else {
teamScore += 1
}
==============================

08
May 14

Why I Might Have Blocked You, Unfriended You or Uncircled You

download

 

 

 

 

 

 

 

General reasons:

  • you are a company/newspaper/spammer
  • you are a “social media expert” and “content curator”
  • you havent posted anything in the last year
  • you have benefited from and even hijacked my comments and I havent ever derived value from yours
  • you used to be a “friend” but now you ignore me and have ignored me for the last 1 or 2 years
  • you dont like me but you still followed me and took advantage of my openess and ideas (you damned hypocrite). You are probably a newspaper, journalist, reporter, company, “schmoozer” or politician.
  • I dont like you. Usually for being stupid or a “joker”. Or for your political ideas.

Twitter: all of the above

Google Plus: all of the above

Facebook: all of the above. Aditionally you’re not family, a “friend” when we’ve never met or havent met for the last 5 years

If you think that I have done any of the above mistakenly let me know.


05
Apr 14

46

46 no


31
Mar 14

Some Random Wild Ideas

geniusMy list of hacking and business ideas has achieved critical mass. Meaning that I now have more than 100 items in my “someday” list.

So I decided to publish *some* of them. Those are the ones that I no longer have patience or coding skills for and those that I cant come up with a way to monetize (aka make money from)

Without further ado and in no particular order:

  • someone should launch a Bitcoin credit card. Maybe use the smartphone to do it. A card would be easier for physical use in stores and stuff. The banks might already be looking at this, so it would a tough job
  • a picture request site would be fun. You’d go to the site and request a picture of something or somewhere and someone in the network would take it. Hard to monetize I think. Plus there might be a lot of fake pictures taken (you know, search Google for something like the request).
  • an implementation of TCP/IP over Twitter would be hilarious
  • an implementation of a Pub/Sub queue (or other types of queues) would also be funny
  • someone should hack a converter to translate Erlang into Javascript. Probably using Emscripten, I dont know
  • implement the possibiliy of sending encrypted tweets. Probably through a FF/Chrome extension. People would publish their public key in their profile. The extension would be able to send an encrypted tweet to someone by reading their public key from the profile. The recipient of the tweet would be able to decrypt it using his private key (stored in some way or other, I dont know; local storage maybe)
  • a distributed search engine using browser Javascript webworkers to compete with Google. How? An extension for FF/Chrome would be needed. The extension would track and index every page the user visited. The results would be stored locally but also distributed to the other people in the network (ie using the extension)  using some kind of DHT. Users of the extension would then be able to make a query/search which would be retrieved through the DHT network. Privacy would be a problem
  • an Saas service that would provide people with an easy way to sell subdomains. Say that I have the xpto.com domain. I would be able to sell subdomains (ie abc.xpto.com, zbr.xpto.com, etc). The ecommerce part is pretty easy. The DNS magic needed would be the problem. And maybe not needed due to the new TLDs.
  • Portuguese government sites are a piece of shit. Someone should crawl the whole gov.pt domain (and a few others) and provide a single interface to find information
  • the amount of crap that is tweeted everyday is astonishing. Mental farts are easy. Someone should build a better twitter (or better whatsapp, viber, etc) by creating a service that would only allow for one “tweet” per day. Make it count. I actually have a name for it and the domain: http://bulletiner.com/
  •  like I mentioned somewhere else in my blog (dont have the time right now to search for it), it would be possible to compete with twitter (or any other messaging service) by creating a distributed messaging system. Once again using browser extensions and DHTs. You’d have to some site to get the “app”. Whenever you “tweeted” (for want of a better word) the “tweet” would be stored in local storage but would also distributed to other users of the service in an encrypted form and stored in someone of those using a DHT scheme. Users would be able to request the “tweets” from the people they followed by querying the DHT network.
  • create a short URL database. Crawl the web for short urls (goo.gl, t.co, fb.me, bit.ly, etc). Or just brute force them. And then find out and store the destination url. One would then be able to find out what short urls were available for each original url.  It would also make an excelent basis for a search engine. Sort of delicious but using actually important urls, those that people actually found interesting
  • register open.id. Create a centralized place for people to identify themselves. I guess keybase.io already invalidated this idea
  • and, of course, a real full stack web development framework fully in Javascript. DB written in JS; app server written in JS; message queue in JS; template system using JS, browserside and just using HMTL. Prototype oriented (instead of the “class based OO insanity). With automatic object persistence (aka no ORM, the “vietnam of programming”). With inheritance via acquisition. For more information look at previous posts of mine and look at Zope.

Thats it. Have fun. I’ll only request 1% of shares if you make it big.


25
Mar 14

Subvert the Domination Paradigm

Screenshot from 2014-03-25 22:47:38

 

 

 

 

Jovem e ingénuo. Coerente e presciente desde 1968. Publica 1999 Classe Politica 2020