Skip to content

Instantly share code, notes, and snippets.

@aslakknutsen
aslakknutsen / main_test.go
Created October 27, 2016 12:08
Playing with Otto
package main
import (
"fmt"
"testing"
"github.com/robertkrimen/otto"
)
type WorkItem struct {
package main
import "database/sql"
type Application interface {
WorkItems() WorkItems
}
type GormApplication struct {
*gorm.DB
@aslakknutsen
aslakknutsen / service.go
Created October 5, 2016 20:42
almighty tech overview
package main
type CoreService interface {
}
func (c CoreService) RegisterService(service Service) {
// RegisterWorKitems
// Add to Service Register
}
var order [][]func()
order = append(order, []func(db) {ExecSQLFile("add_customer.sql"), MigrateCustomerFieldName})
order = append(order, []func(db) {ExecSQLFile("add_some_other")})
// db.tx.begin // TODO: Make sure currentVersion is read inside TX
for verison := currentVersion() && version < size(order) {
for migrationFun := order[version] {
migrationFunc(db)
}
@aslakknutsen
aslakknutsen / central_downloads.rb
Last active August 29, 2016 12:24
Arquillian Core Impl Central download statistics
require 'date'
require 'net/http'
require 'csv'
@DEBUG = false
def fetch_data(auth, download = true)
data_found = true
current_month = Time.new.to_date.prev_month
found_files = []
@aslakknutsen
aslakknutsen / loading_data_test.go
Last active August 26, 2016 09:27
Simple function to allow persisting of remote system data with a refresh option. Delete persistent file or run with 'REFRESH_DATA=true go test' to get fresh data from the remote resource.
func TestGiHubIssueMapping(t *testing.T) {
content, err := LoadTestData("github_issue_mapping.json", func() ([]byte, error) {
url := "https://api.github.com/repos/almighty/almighty-core/issues/131"
response, err := http.Get(url)
if err != nil {
return nil, err
}
defer response.Body.Close()
package main
import (
"encoding/json"
"fmt"
"testing"
"github.com/almighty/almighty-core/models"
)
@aslakknutsen
aslakknutsen / domain.go
Last active August 9, 2016 13:43
ALM Domain
package models
type State string
type Reason string
type Transision struct {
From State
To State
Reason Reason
}
@aslakknutsen
aslakknutsen / console
Created July 29, 2016 22:05
Goa CLI Payload example
[aslak@localhost:~/types/tool/types-cli(master)]$ ./types-cli create array_prism --help
Resource array_prism contains artifical actions that showcase the use of the array type in the DSL.
Payload example:
{
"any_array": [
1481958210139591269
],
"bool_array": [
@aslakknutsen
aslakknutsen / launch.json
Created July 8, 2016 10:49
Located in .vscode
{
"version": "0.2.0",
"configurations": [
{
"name": "Test",
"type": "go",
"request": "launch",
"mode": "test",
"remotePath": "",
"port": 2345,