Skip to content

Instantly share code, notes, and snippets.

@leehsueh
leehsueh / TodoActionCreator.js
Created April 3, 2015 16:33
Basic Flux Todo with Vanilla Angular
angular.module('fluxTodo').factory('TodoActionCreator', function(dispatcher) {
return {
createTodo: function(text) {
dispatcher.handleViewAction({
actionType: 'CREATE',
text: text
});
},
toggleTodo: function(id) {
dispatcher.handleViewAction({
@leehsueh
leehsueh / api_service.js
Last active June 23, 2016 10:54
Generic Angular API Service with $http
'use strict';
//////////////////////////////////////////////
// Service object to interact with some API //
//////////////////////////////////////////////
angular.module('myApp.services')
.factory('someApi', ['$q', '$http', function($q, $http) {
var endPointUrl = "[some api end point]";
return {
@leehsueh
leehsueh / angular-jquery-fade-slide-directive.js
Created October 26, 2012 01:47
Angular directive for jquery fade/slide animations. An approximate drop-in substitution for ng-show. Options can be passed using jq-options and specifying an object.
var app = angular.module('myApp', []);
app.directive('jqShowEffect', ['$timeout', function($timeout) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
// configure options
var passedOptions = scope.$eval(attrs.jqOptions);
// defaults
var options = {
@leehsueh
leehsueh / boolparser.py
Created October 16, 2011 09:07
Python Boolean Expression Parser/Evaluator
"""
Grammar:
========
Expression --> AndTerm { OR AndTerm}+
AndTerm --> Condition { AND Condition}+
Condition --> Terminal (>,<,>=,<=,==) Terminal | (Expression)
Terminal --> Number or String or Variable
Usage:
======