Skip to content

Instantly share code, notes, and snippets.

//Article url: http://www.sitepoint.com/understanding-components-in-ember-2/
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@SitePointEditors
SitePointEditors / painter.cljs
Last active March 14, 2016 14:18 — forked from danprince/painter.cljs
Immutable, undoable pixel editor
(def height 10)
(def width 10)
(def pixel-size 10)
(defn ->2D [i]
[(mod i width)
(.floor js/Math (/ i width))])
(def coords (map ->2D, (range (* height width))))
(def colors (repeat "#fff"))

03:33:51 prompt > Where do you want to load your phone book from? File name:

book 03:33:54 debug > Loading phone book from book.txt failed. No phone book found at that directory.

03:33:54 message > Opened a new phone book at book

03:33:54 message > Menu: Enter | Action 1 to View Contacts

03:37:26 prompt > Where do you want to load your phone book from? File name:

book 03:37:29 message > Loaded your book phone book of 1 contacts.

03:37:29 message > Contacts: < lincoln: 9165551234 > | < kate: 5135554321 > |

03:37:29 prompt > What do you want to do?

@SitePointEditors
SitePointEditors / dom-helper.js
Created March 28, 2017 09:56 — forked from m3g4p0p/dom-helper.js
Mini jQuery, sort of.
/**
* A collection of helper prototype for everyday DOM traversal, manipulation,
* and event binding. Sort of a minimalist jQuery, mainly for demonstration
* purposes. MIT @ m3g4p0p
*/
window.$ = (function (undefined) {
/**
* Duration constants
* @type {Object}
public class MyApiController : ApiController
{
// Top-level method
public ActionResult HandleRESTApiCall(){
SomeType someObj = DoSomethingAsync().Result;
return OkResult(someObj);
}
private async Task<SomeType> DoSomethingAsync(){
var someData = await GetDataAsync();
public async Task<ResultType> DoWorkAsync()
{
ResultType retVal;
try {
Task<APIResult> apiResultTask = CallAnAPIAsync();
var fileName = CreateFileName();
var apiResult = await apiResultTask;
await WriteToAFileAsync(fileName, apiResult);
retVal = await StartAsyncOperation(fileName);
} catch (RealException rex) {
public ResultType DoWork()
{
ResultType retVal;
try {
var apiResult = CallAnAPIAsync().Result;
var fileName = CreateFileName();
WriteToAFileAsync(fileName, apiResult).Wait();
retVal = StartAsyncOperation(fileName).GetAwaiter().GetResult();
} catch (AggregateException aex) {
HandleError(aex);
public async Task<ReturnType> DoSomethingAndReturnSomeValAsync()
{
DoSomething();
SomeType someObj = await DoSomethingElseAsync();
return new ReturnType(someObj);
}
private async Task<SomeType> DoSomethingElseAsync(){
...
}
<template>
<h1>{{ title }}</h1>
<ul>
<li v-for="task in tasks" :key="task.id">
{{task.id}}. {{ task.name }}
</li>
</ul>
</template>