Skip to content

Instantly share code, notes, and snippets.

(function(){
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str){
return this.slice(0, str.length) == str;
};
}
if (typeof String.prototype.endsWith != 'function') {
String.prototype.endsWith = function (str){
return this.slice(this.length - str.length, this.length) == str;
# Simple manifest
# by vkhomenko
#
# We want to create VM, and run bash command on it.
# We need 2 steps: provision (ask amazon to launch instance) and run-command.
# To define order for our steps, we use "phase - precedingPhases". precedingPhases means we shall wait until phases listed there finished.
# Also, after starting node, we need a way to access it. Adding roleName, we adds our node to pool, named "computes-pool".
# Parameter "roles", passed to execrun, tells where to execute command. Right now it's just one node.
launch:
@dornatsky
dornatsky / 1.yaml
Last active December 14, 2015 13:08
multi-line shell script
launch:
parameters:
- ip:
description: static ip address
default: ""
steps:
- grow:
action: provisionAmazonVm
parameters:
phase: provision
@dornatsky
dornatsky / error-formats.js
Created October 24, 2012 10:57 — forked from al6x/error-formats.js
Errors formats.
// Single error.
{
error: "a is bad"
}
// Single detailed error.
{
error: {
message : 'a is bad',
text : 'a is bad because of ...',
launch:
steps: []
destroy:
steps: []
scale-up:
steps: []
scale-down:
@dornatsky
dornatsky / Main.scala
Created June 20, 2012 22:15
(almost) transparent maps serialization
import com.novus.salat._
import com.novus.salat.global._
import com.mongodb.casbah.Imports._
import com.novus.salat.annotations._
case class KeyValuePair[K, V](key: K, value: V)
object DaoMap {
implicit def toDaoMap[K, V](map: Map[K, V]): Seq[KeyValuePair[K, V]] = {
//TODO handle nested maps
@dornatsky
dornatsky / gist:2725484
Created May 18, 2012 14:14
no basic launch
launch:
parameters:
appPrefix:
description: Web application prefix (edited)x
default: myApp
accessKey:
description: AWS Access Key
secretKey:
description: AWS Secret Key
steps:
@dornatsky
dornatsky / Taxes.cs
Created September 23, 2011 15:14
taxes calculation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
private static TaxRate[] _entries = new TaxRate[]
@dornatsky
dornatsky / ForLoop.cs
Created June 23, 2011 15:33
Will run a for loop of an arbitrary nesting depth
public class ForLoop
{
private int[] _indices;
private int[] _boundaries;
private Action<int[]> _action;
public ForLoop(int[] indices, int[] bondaries, Action<int[]> action)
{
_indices = indices;
_boundaries = bondaries;