Skip to content

Instantly share code, notes, and snippets.

View esshka's full-sized avatar
🏠
Working from home

Eugeny esshka

🏠
Working from home
View GitHub Profile
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Zoomator.directive("timeline", [
"$filter", "$document", "$window", "FactorComputate", function($filter, $document, $window, FactorComputate) {
return {
restrict: "EA",
replace: true,
template: "<div id='timeline' style='height:90px;'><svg style='height:100%;width:100%;'></svg></div>",
scope: {
/*
This code takes a 2D transformation matrix described as a one-dimensional array
(in column order, top to bottom and left to right) and decomposes it using the dojo
matrix library. This input matrix should produce a 45-deg X skew:
1 1 0
0 1 0
0 0 1
The output of decompose() looks like this:
(function () {
"use strict";
angular.module("exampleApp")
.factory("WebWorks", ["$q", function ($q) {
var worker = new Worker('scripts/workers/doWork.js');
var defer;
worker.addEventListener('message', function(e) {
<table border="1" cellspacing="0" cellpadding="0" width="530" style="width:397.5pt;background:#f8faf9;border-collapse:collapse;border:none">
<tbody>
<tr>
<td style="border-top:solid #358e8a 3.0pt;border-left:solid #358e8a 3.0pt;border-bottom:none;border-right:none;padding:0cm 0cm 0cm 0cm">
<p>&nbsp;</p>
</td>
<td style="border:none;border-top:solid #358e8a 3.0pt;padding:0cm 0cm 0cm 0cm"><p>&nbsp;</p>
</td>
<td style="border:none;border-top:solid #358e8a 3.0pt;padding:0cm 0cm 0cm 0cm"><p>&nbsp;</p>
</td>

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>

Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy.

To get around this, we're going to run our node app as an Upstart service. Upstart services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts.

###Step 1: Create a service for your node app

  • ssh in as root ssh root@youripaddress
  • Create a node-app.conf file in /etc/init
    IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. service node-app start

##Setup your server (this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g forever

##Install flightplan

  • npm install -g flightplan
  • in your project folder npm install flightplan --save-dev
  • create a flightplan.js file
app = angular.module 'BlogExample', []
# Simple controller that loads all blog posts
app.controller 'BlogCtrl', ['$scope', 'Blog', ($scope, Blog) ->
# Get all the blog posts
Blog.all().then (posts) ->
$scope.posts = posts
# Extend the $scope with our own properties, all in one big block
# I like this because it looks like declaring a class.
@esshka
esshka / boot.js
Last active August 29, 2015 14:11 — forked from jdx/boot.js
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@esshka
esshka / sidekiq
Last active August 29, 2015 14:06 — forked from dyerc/sidekiq
#!/bin/bash
# sidekiq Init script for Sidekiq
# chkconfig: 345 100 75
#
# Description: Starts and Stops Sidekiq message processor for Stratus application.
#
# User-specified exit parameters used in this script:
#
# Exit Code 5 - Incorrect User ID
# Exit Code 6 - Directory not found