Skip to content

Instantly share code, notes, and snippets.

View al6x's full-sized avatar

Alex Kraft al6x

  • Australia
View GitHub Profile
@al6x
al6x / markdown.js
Created October 19, 2012 00:05
JavaScript helper to call REST markdown service
var fs = require('fs');
var http = require('http');
var querystring = require('querystring');
var markdown = function(source, target, host, port, cb) {
// Allowing to call callback only once.
var once = function(cb) {
return function() {
if (once.called) return;
once.called = true;
@al6x
al6x / error-formats.js
Created October 24, 2012 10:41
Errors formats.
// Single error.
{
error: "a is bad"
}
// Single detailed error.
{
error: {
message : 'a is bad',
text : 'a is bad because of ...',
@al6x
al6x / readme.md
Created November 6, 2012 15:41
Color line as a difference between versions

There are two parts - how to get similar hashes for similar versions and how to display hash as a color line.

Displaying hash it as a color line should be simple, every digit in hash can be mapped to color palette, and the result will be line of colors corresponding to the hash value.

Getting similar caches is more complex, I know two methods how to do it.

Difference between origin and other versions.

It's simple and robust approach with good quality but the limitation is - it only can compare single origin version with others, it can't compare two arbitrary versions. But maybe we still can use it - use latest version as origin and show how previous are different from it.

generateSshKeys = (btn) =>
server.organizations.generateSshKeys @model, btn.waiting app.fork (data) =>
@model.set data
organization.set data
f.setAttribute k, v for k, v of data
generateSshKeys = (btn) =>
server.organizations.generateSshKeys(@model, btn.waiting(app.fork((data) =>
@model.set data
organization.set data
it "should create environment", async ->
@browser.navigate '/environments'
wait => @browser.click 'Add an environment...'
dialog = @browser.dialog 'Add environment'
dialog.type
name: 'New Environment'
dialog.click 'Add'
@al6x
al6x / empty.yml
Last active December 11, 2015 11:48
#This is the simplest manifest
launch:
steps: []
destroy:
steps: []
/*!
* jQuery JavaScript Library v1.7.1
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
@al6x
al6x / interview.js
Last active December 15, 2015 10:39
JS interview questions
// http://tinkerbin.com/uJgj6uCY
print = function(msg){document.write(msg + "<br/>")}
var map = function(list, fn){
result = []
for(var i = 0; i < list.length; i++) result.push(fn(list[i]))
return result
}
var pow2 = function(v){return v * v}
@al6x
al6x / format.js
Last active December 19, 2015 01:28
// Type can be enum, string, application. Anything else is considered string.
launchParameters = {
instanceName : "New instance of my app",
environments : listOfEnvironments,
applicationId : "id-of-main-application",
revisionId : "revision1",
parameters : [
{
@al6x
al6x / new.coffee
Created December 24, 2013 11:01
New test framework
it "should display application and instances", (done) ->
await @browser.post '/applications', {name: 'Some application'}, defer application
await @browser.post "/applications/#{application.id}/launch", defer instance
await @browser.navigate "/applications/#{application.id}", defer()
await trying (done) =>
await @browser.application application.id, defer()
await @browser.instanceItem instance.id, defer()
done()