TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: 2048-as-a-service, an API to build complex 2048 based apps

4 pointsby vinothgopiabout 11 years ago

1 comment

vinothgopiabout 11 years ago
tl;dr paste this in your console for demo<p>perl -e &#x27;my $host = &quot;<a href="http://2048.semantics3.com/hi/&quot;;my" rel="nofollow">http:&#x2F;&#x2F;2048.semantics3.com&#x2F;hi&#x2F;&quot;;my</a> $cmd = &quot;curl --silent -L $host&quot;.&quot;start&quot;;my $output = `$cmd`;my $session_id = $output;$session_id=~s&#x2F;.<i>?ID:\s(\w+).</i>&#x2F;$1&#x2F;si;my %keyMap = ( &#x27;w&#x27; =&gt; 0, &#x27;d&#x27; =&gt; 1, &#x27;s&#x27; =&gt; 2, &#x27;a&#x27; =&gt; 3);print STDERR $output,&quot;\n&quot;;while(1) { print STDERR &quot;Input (w - up, a - left, d - right, s - down):\n&quot;; my $userInput =&lt;stdin&gt; ; chomp ($userInput); if(defined($keyMap{$userInput})) { $userInput = $keyMap{$userInput}; } else { print STDERR &quot;Invalid move.. w - up, a - left, d - right, s - down\n&quot;; next; } my $cmd = &quot;curl --silent $host&quot;.&quot;state&#x2F;$session_id&#x2F;move&#x2F;$userInput&quot;; my $output = `$cmd`; print STDERR &quot;\n$output\n&quot;; if($output=~&#x2F;Message:&#x2F;si) { exit(0); }}&#x27;