Skip to content

Instantly share code, notes, and snippets.

@midu
Last active August 29, 2015 14:05
Show Gist options
  • Save midu/58f144ba839867624b1f to your computer and use it in GitHub Desktop.
Save midu/58f144ba839867624b1f to your computer and use it in GitHub Desktop.
<p id="welcome">
  Welcome to ChallengePost
</p>

When the page loads, you have the above markup. Without reloading the page, you want to add the user's full name in the message so it reads "Welcome to ChallengePost John Doe!"

An ajax request to /users/me.json will return information about the current user in a JSON format that looks like this:

{
  "firstName": "John",
  "lastName": "Doe",
  // ...
}

How would you implement it?

Implement a Konami code easter egg on a website.

Konami code s a cheat code that appears in many Konami video games,[1] although the code also appears in some non-Konami games.

http://en.wikipedia.org/wiki/Konami_Code

It is also a common easter egg that web developers like to put on their websites.

How would you implement it?

Konami code is:

BAStart

  38 #
  40 #
  37 #
  39 #
  66 # B
  65 # A
  13 # ↩ (enter)
  • (Use Enter for start)
  • When a user entered the Konami code, an alert message should appear with the message of your choice

You have a button on a page.

  <button id="button">Save</button>

When a user clicks that button, we want to get data from two APIs, and when we have both results, we want to aggregate them and send them to our server via ajax.

// API 1
var api1Url = 'http://weather.com/aspen.json'; // GET that url and it returns a JSON with weather forecast in ASPEN
var api2Url = 'http://snow.com/aspen.json'; // GET that url and it returns a JSON with snow forecast in ASPEN

// use a POST here, to save in your app's database
// expects a json as data that looks like this:
// { 
//  forecast: { /* whatever was returns from weather.com },
//  snowcast: {  /* whatever was returns from snow.com }
// }
var api3Url = 'http://weatherandsnowinaspen.com/save';

Use any library you'd like. You can write in JS or Coffee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment