Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Tuesday, 8 July 2014

The BARON Programming Language

I'm currently designing a new programming language, which I'm presently naming 'BARON'…yes, it's named after me, I say to myself if Linus can name an OS after himself why can't I do something similar;)

And also it's BARON all in caps, as an homage to the simplicity of BASIC.


I'm going to publish soon a detailed design intention document but in resume, the goal of this vanity project is to develop a simple wrapper user interface prototyping language.

I currently find it still too slow to prototype & implement UI front-ends for interactive applications, especially on web platforms.

The panoply of client-side web languages/specifications makes it hard to focus on the actual UX design of the front-end interface. My end goal is to wrap CSS, HTML & JavaScript into a simple unified syntax & language structure that is focused on the principales of finite states.

BARON might not be a precise solution for large scale productions but it can become a good tool for quick UI/UX scripting & prototyping.

Wednesday, 11 June 2014

WWDC 2014

The one thing I wanted to hear from Apple at WWDC was a focus on stability, they seem to have lost one of their core pillars in their products, which is stableness.


Because the most core element in UX design is not simplicity or responsiveness but stability, for nothing breaks more an user's experience than a unstable system.

Monday, 3 October 2011

Learn The Trigonometry Functions

Sunday, 2 October 2011

Simple Solution: Reading Twitter Feeds

I was working on a way to feed Twitter messages into an indie game prototype last March. Basically, certain events and unlocks could be triggered by specific commands embedded in subtle Twitter messages.

I was slamming my head against Twitter API and JSON, when it clicked, I could simply read the generated RSS feed and parse out what I need.

In other words, I find that most of the time, it's easier to bypass the official API of the service provider and always check for simple alternatives.

Links:
iPhone SDK: First Steps With JSON Data Using the Twitter API
With Just 3 Lines Of Code Add Twitter/Facebook Into Your iOS App

Use self()

I’m building a database abstract layer in PHP using a Singleton pattern, I based my code the following article.


In the comments, I found that you can self-instantiate a class with “self” instead of calling it by name, very useful if you plan to change the class name over time.


Must re-write code if you change the class name:


self::$m_pInstance = new Database();

No worries with self():


self::$m_pInstance = new self();

PHP & Enums

Enums are not native to PHP, at least not for the moment but I found a way to simulate with the help of this post on stackoverflow.

<?php

class DiceEnum
{
        const d4 = 4;
        const d6 = 6;
        const d8 = 8;
        const d10 = 10;
        const d12 = 12;
        const d20 = 20;
}
?>

But if I base myself on the SPL documentation, it’s seems we are going to have a supported native integration very soon.

Syntax :: the use of ?

I had a PHP exam this morning for a job interview, which I feel I probably failed, my main problem is that I had doubts on how PHP5 handles object references, I’ve been programming in C++ and objetive-C recently and my mind is stretch out with all the different IDEs, scoping, syntax and specifications of each language.


This causing me to go from one mindset to the other and in a written exam, were you don’t have access to documentation when in doubt or a debugger to feel out the language, it gets very difficult.


And so I’m reviewing the PHP5 documentation in hopes it will help me perform better at my next job interview.


While reading up, I found this very interesting proof of concept, the thing I like the most about it it’s the use of the syntax:


($bar === $this ? “Yes\n” : “No\n”)


Never used it or at least not everyday and it’s actually was a question on the exam.


At least when I fail, it’s always epic!



<?php

class Bar
{
public $prop = 42;
}

class Foo
{
public $prop = 17;
function boom()
{
$bar = &$this;
echo "\$bar is an alias of \$this, a Foo.\n";
echo '$this is a ', get_class($this), '; $bar is a ', get_class($bar), "\n";

echo "Are they the same object? ", ($bar === $this ? "Yes\n" : "No\n");
echo "Are they equal? ", ($bar === $this ? "Yes\n" : "No\n");
echo '$this says its prop value is ';
echo $this->prop;
echo ' and $bar says it is ';
echo $bar->prop;
echo "\n";

echo "\n";

$bar = new Bar;
echo "\$bar has been made into a new Bar.\n";
echo '$this is a ', get_class($this), '; $bar is a ', get_class($bar), "\n";

echo "Are they the same object? ", ($bar === $this ? "Yes\n" : "No\n");
echo "Are they equal? ", ($bar === $this ? "Yes\n" : "No\n");
echo '$this says its prop value is ';
echo $this->prop;
echo ' and $bar says it is ';
echo $bar->prop;
echo "\n";

}
}

$t = new Foo;
$t->boom();
?>

Watching GIFs on OSX

One thing I really love are GIFs but OSX and iPhoto don’t play them natively so I build the following Applescript to generate a local web page which lists and displays all my GIFs that are located in a specific folder.


You can download the .scpt here.



set gifFolderName to "gif:"
set gifDisplayPage to "GIFDisplayPage.html"

tell application "Finder"
set currentFolder to container of (path to me) as string
set gifFolderPath to (currentFolder &amp; gifFolderName)
set fileList to every file of folder gifFolderPath
-- display dialog currentFolder
end tell

set gifPage to (currentFolder &amp; gifDisplayPage)
set htmlStart to "Watch your GIFs" as string
set htmlEnd to "" as string

try
open for access file gifPage with write permission
write htmlStart to file gifPage as string
repeat with currentFile in fileList
set currentFileName to (name of currentFile)
write ("<img src="gif/&quot; &amp; currentFileName &amp; &quot;" alt="" />") to file gifPage as string
end repeat
write htmlEnd to file gifPage as string
close access file gifPage
on error errorMessage
log errorMessage
try
close access file gifPage
end try
end try

tell application "Finder"
open file gifPage
end tell

Steering Behaviors for Text Animation

I’ve been reading this very fascinating white paper called ‘Steering Behaviors For Autonomous Characters‘.


Great resource for anyone working on pathfinding or NPC scripting.


But I’m thinking of using those very advance algos for simple text animation.
By example for animating title screens by giving each letter a group behavior and a path.