Skip to content

Instantly share code, notes, and snippets.

@dimroc
dimroc / gorm_diff_types_repro.go
Last active January 26, 2019 01:03
Reproduce issue where the underlying db will change the Scan type in `gorm`: https://github.com/jinzhu/gorm/issues/2276
package main
import (
"database/sql/driver"
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
diff --git a/services/application.go b/services/application.go
index 39573a5b..3d5c0cad 100644
--- a/services/application.go
+++ b/services/application.go
@@ -43,7 +43,7 @@ type ChainlinkApplication struct {
BulkRunDeleter SleeperTask
pendingConnectionResumer *pendingConnectionResumer
bridgeTypeMutex sync.Mutex
- jobSubscriberID, txManagerID, connectionResumerID string
+ jobSubscriberID, txManagerID, connectionResumerID int
diff --git a/services/application.go b/services/application.go
index 39573a5b..3d5c0cad 100644
--- a/services/application.go
+++ b/services/application.go
@@ -43,7 +43,7 @@ type ChainlinkApplication struct {
BulkRunDeleter SleeperTask
pendingConnectionResumer *pendingConnectionResumer
bridgeTypeMutex sync.Mutex
- jobSubscriberID, txManagerID, connectionResumerID string
+ jobSubscriberID, txManagerID, connectionResumerID int
@dimroc
dimroc / assert_on_methods.go
Last active November 19, 2018 22:35
Finding it hard to shoe horn into table driven tests
func TestHeightsController_Index(t *testing.T) {
threshold := big.NewInt(2)
tests := []struct {
name string
status int
}{
{"good clients", 200},
// Hard to do error cases without adding an if with difference setup. could add test helpers...
}
#!/usr/bin/env node
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const countdown = async () => {
await delay(5000)
console.log("hello world")
}
countdown()
@dimroc
dimroc / reflection_intro.go
Created October 10, 2018 18:28
Experiments with golang reflection. Create an empty slice of the type passed in in a callback: https://play.golang.org/p/Zc9HiABuMi_a
package main
import (
"fmt"
"reflect"
)
func main() {
callback := func(int) bool { return false }
@dimroc
dimroc / coremltools-sample.py
Created August 28, 2018 22:35
Simple barebones coremltools conversation to Keras
coreml_model = coremltools.converters.Keras.convert(
path,
input_names=['input_1'],
image_input_names=['input_1'],
output_names=['density_map'])
coreml_model.save("CrowdPredictor.mlmodel")
@dimroc
dimroc / sync_cond_reaper.go
Last active August 21, 2018 15:43
Real use of Golang's `sync.Cond` to efficiently signal a second goroutine when to run and limit the number of reapers that can be enqueue while running to 1.
package services
import (
"sync"
"time"
"github.com/asdine/storm"
"github.com/smartcontractkit/chainlink/logger"
"github.com/smartcontractkit/chainlink/store"
"github.com/smartcontractkit/chainlink/store/models"
@dimroc
dimroc / Prediction.playground.linkerError.txt
Last active August 12, 2018 21:36
Crowd Count Prediction.playground spurious linker errors: https://github.com/dimroc/count/tree/master/ios
error: Couldn't lookup symbols:
type metadata for CrowdCountApiMac.FriendlyClassification
CrowdCountApiMac.MultiArray.copy() -> CrowdCountApiMac.MultiArray<A>
CrowdCountApiMac.MultiArray.image(offset: A, scale: A) -> Swift.Optional<__C.NSImage>
CrowdCountApiMac.FriendlyPredictor.predictAllPromise(image: __C.NSImage, on: __C.OS_dispatch_queue) -> Promises.Promise<Swift.Array<CrowdCountApiMac.FriendlyPrediction>>
protocol witness table for Swift.Double : CrowdCountApiMac.MultiArrayType in CrowdCountApiMac
__swift_FORCE_LOAD_$_swiftCoreMedia
__swift_FORCE_LOAD_$_swiftCoreAudio
CrowdCountApiMac.FriendlyPredictor.DensityMapWidth.unsafeMutableAddressor : Swift.Int
type metadata accessor for CrowdCountApiMac.FriendlyPredictor
@dimroc
dimroc / Realm.Configuration+migrations.swift
Created August 3, 2018 15:32
Lightweight management of Realm migrations
//
// RealmConfiguration+extensions.swift
// CrowdCount
//
// Created by Dimitri Roche on 8/3/18.
// inspired by https://medium.com/@shenghuawu/realm-lightweight-migration-4559b9920487
// Copyright © 2018 Dimitri Roche. All rights reserved.
//
import Foundation