Skip to content

Instantly share code, notes, and snippets.

SF, hacking, thinking, observing, feeling

Anton Podviaznikov podviaznikov

SF, hacking, thinking, observing, feeling
Block or report user

Report or block podviaznikov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 {
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 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)",""],[" ? 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",""],[" ? 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:\n' +
FROM node:0.10.38
# Open up ports on the container
EXPOSE 80 8000 8080 3000
# Add repository files to container
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))
View pascaltriangle.clj
(defn pascaltriangle-iter [row col]
(if (or (= col 1) (= col row))
(pascaltriangle-iter (- row 1) (- col 1))
(pascaltriangle-iter (- row 1) col))))
(defn pascaltriangle-row [row]
(for [i (range 1 (+ 1 row))]
(pascaltriangle-iter row i)))
View nginx.txt
podviaznikov / fibonacci.clj
Created Oct 30, 2013
Fibonacci implementation on Clojure.
View fibonacci.clj
(defn fib-iter [a b n]
(if (zero? n)
(recur (+ a b) a (dec n))))
(defn fib [n]
(fib-iter 1 0 n))
(fib 40) ;102334155
podviaznikov / gdc.clj
Created Oct 30, 2013
The greatest common divisor (GCD) of two integers: x and y. Clojure implementation.
View gdc.clj
(defn gdc [x y]
(if (= x y)
(if (> x y)
(recur (- x y) y)
(recur (- y x) x))))
(gdc 10, 100) ; 10
You can’t perform that action at this time.