Skip to content

Instantly share code, notes, and snippets.

Avatar
🌉
SF, hacking, thinking, observing, feeling

Anton Podviaznikov podviaznikov

🌉
SF, hacking, thinking, observing, feeling
View GitHub Profile
@podviaznikov
podviaznikov / error-handling-workers.js
Created May 25, 2017
error handling on the workers
View error-handling-workers.js
onContainerDataSaved = function (container) {
let networkData
try {
networkData = network.fetchNetworkData()
network.attachContainerToNetwork(networkData, container)
websockets.sendErrorToClients("Cannot attach container to the network")
} catch (err) {
if (err instanceof NetworkAttachError) {
messageBus.emit('network.attach.failed', { container, networkData })
}
View error-handling.js
// ideally those should be sent in parallel
// failure of one shouldn't impact failure of others
function sendNotifications (data, instance, container) {
try {
slack.sendNotification(data, instance, container)
} catch (err) {
// retry sending a message
slack.sendNotification(data, instance, container)
}
try {
View gist:f088b96dc3886b1717b93a7220da33b0
{"name":"palantiri","commit":"e8d147487e65d9dcf2f90ba9827c7e3ee3e23cfa","environment":"production-delta","hostname":"palantiri","pid":15,"tx":true,"module":"Swarm","method":"getHostsWithOrgs","level":10,"info":{"ID":"","Containers":14457,"ContainersRunning":3122,"ContainersPaused":0,"ContainersStopped":11335,"Images":6485,"Driver":"","DriverStatus":null,"SystemStatus":[["Role","primary"],["Strategy","spread"],["Filters","health, port, containerslots, dependency, affinity, constraint"],["Nodes","257"],[" (unknown)","10.8.204.92:4242"],[" ? ID",""],[" ? Status","Pending"],[" ? Containers","0"],[" ? Reserved CPUs","0 / 0"],[" ? Reserved Memory","0 B / 0 B"],[" ? Labels",""],[" ? Error","Cannot connect to the Docker daemon. Is the docker daemon running on this host?"],[" ? UpdatedAt","2016-08-03T16:55:09Z"],[" ? ServerVersion",""],[" ip-10-8-192-52.9487339","10.8.192.52:4242"],[" ? ID","SRSN:VBV3:4ZSI:J3HF:AXQF:KZWX:2SJH:7TUY:N3KG:WEP5:AIHP:5FSQ"],[" ? Status","Healthy"],[" ? Containers","36"],[" ? Reserved CPUs"
View Dockerfile-metalsmith-blog
# Full list of versions available here: https://registry.hub.docker.com/_/node/tags/manage/\n' +
FROM node:0.10.38
# Open up ports on the container
EXPOSE 80 8000 8080 3000
# Add repository files to container
ENV BASE_URL=http://metalsmith-blog-staging-runnable.runnableapp.com
@podviaznikov
podviaznikov / Datomic News Updates
Created Apr 21, 2016 — forked from stuarthalloway/Datomic News Updates
Datomic update examples against a social news database
View Datomic News Updates
;; Datomic example code
;; demonstrates various update scenarios, using a news database
;; that contains stories, users, and upvotes
;; grab an in memory database
(use '[datomic.api :only (q db) :as d])
(def uri "datomic:mem://foo")
(d/create-database uri)
(def conn (d/connect uri))
@podviaznikov
podviaznikov / idea-shortcust
Created Jul 3, 2015
Intelij idea shortcust
View idea-shortcust
http://blog.jetbrains.com/idea/2014/03/intellij-idea-13-1-rc-introduces-sublime-text-style-multiple-selections/
@podviaznikov
podviaznikov / nace.clj
Last active Aug 29, 2015
generate naces
View nace.clj
(ns nace.core
(:require [cheshire.core :refer :all]))
(def st (slurp "./resources/nace.json" :encoding "UTF-8"))
(defn remove-dots [s]
(clojure.string/replace s "." ""))