Skip to content

Instantly share code, notes, and snippets.

View roylee0704's full-sized avatar
🧘‍♂️

roylee0704

🧘‍♂️
  • Bangkok, Thailand
View GitHub Profile
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"

If you've done much reading about angularjs you've no doubt come across mention of karma, a test runner recommended especially for use with angularjs applications. The [angular-seed][1] project is a great way to get started with the basics of angular testing using karma, but for projects of any significant size you will soon hit the cieling in terms of organizational complexity. What I want to share in this article is the approach I have taken using [Grunt][2] and the [grunt-karma][3] plugin to sustainably manage my projects' client side unit tests and run them via [TravisCI][4]. I plan to write another entry about how to approach the actual minutia of unit testing angular code in the near future.

Karma, configuration for tests

Karma is really nothing more than a set of centralized configuration that builds a test runner for you. The advantage being that it allows you to easily execute tests in a headless browser, and output to the command line. As someone who has actually set all of that up from scratc

@roylee0704
roylee0704 / promises.md
Last active August 29, 2015 14:22 — forked from domenic/promises.md

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@roylee0704
roylee0704 / .vimrc
Last active August 29, 2015 14:22 — forked from sas1ni69/.vimrc
execute pathogen#infect()
filetype plugin on
filetype indent on
let mapleader=","
colorscheme monokai
set background=dark
set clipboard=unnamed
@roylee0704
roylee0704 / react_setup.md
Last active November 30, 2015 08:49
React Fundamental Setup

#React Fundamental Setup

##1.0 Global - One Time Job

npm install babel webpack webpack-dev-server -g

##2.0 Each React Project Setup

###2.1 Library

#React Components

In general, there are 2 ways to create React Component.

1.0 Class Component

Here an extension of react component, we can do all sort of things, but for class component, it always going need to render(), to return a component.

Note, this component will can have state.

Flavor 1: JSX

@roylee0704
roylee0704 / style.less
Last active March 7, 2016 09:45
for atom theme
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed and saved.
*
* Add your own CSS or Less to fully customize Atom.
* If you are unfamiliar with Less, you can read more about it here:
* http://lesscss.org
*/

Setting up Vim as your Go IDE

The final IDE

Intro

I've been wanting to do a serious project in Go. One thing holding me back has been a my working environment. As a huge PyCharm user, I was hoping the Go IDE plugin for IntelliJ IDEA would fit my needs. However, it never felt quite right. After a previous experiment a few years ago using Vim, I knew how powerful it could be if I put in the time to make it so. Luckily there are plugins for almost anything you need to do with Go or what you would expect form and IDE. While this is no where near comprehensive, it will get you writing code, building and testing with the power you would expect from Vim.

Getting Started

I'm assuming you're coming with a clean slate. For me this was OSX so I used MacVim. There is nothing in my config files that assumes this is the case.