Skip to content

Instantly share code, notes, and snippets.

ssh_keypair { '/tmp/foo':
ensure => present,
key_type => 'dsa',
}
# /etc/puppet/modules/<module_name>lib/puppet/type/ssh_keypair.rb
Puppet::Type.newtype(:ssh_keypair) do
newparam(:name, :namevar => true) do
@kchida
kchida / gist:d1c15f3968f4f8272c49
Created July 17, 2014 05:06
etcd vs consul vs ???
- What do Etcd, Consul, and Zookeeper do?
- Service Registration:
- Host, port number, and sometimes authentication credentials, protocols, versions
numbers, and/or environment details.
- Service Discovery:
- Ability for client application to query the central registry to learn of service location.
- Consistent and durable general-purpose K/V store across distributed system.
- Some solutions support this better than others.
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
- Centralized locking can be based on this K/V store.
#
# Copyright (C) 2013 Loic Dachary <loic@dachary.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
from nonlocal_ import nonlocal_
def foo():
a = 1
def bar():
nonlocal_('a')
a = 2
bar()
return a
@theanalyst
theanalyst / fibs.c
Last active November 23, 2018 14:02
Hy, Python & C play nicely with each other
#include "fibs.h"
long fib(int n)
{
if (n == 0)
return 1;
else if (n == 1)
return 1;
else
return fib(n-1) + fib(n-2);
@dergachev
dergachev / squid-deb-proxy_on_docker.md
Last active May 25, 2023 03:55
Caching debian package installation with docker

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"
@emasaka
emasaka / dsl.mk
Created October 12, 2013 07:20
Makefile for GNU make 4.0 that rules are written by embedded Guile.
define dsl
(use-modules (srfi srfi-1))
(define targets '())
(define (showtargets)
(string-join (reverse targets) "\n") )
(define-macro (push! place item)
`(set! ,place (cons ,item ,place)) )
@paultag
paultag / info.md
Last active December 10, 2015 02:09
Hython Runtime

tl;dr

PyPy is ruddy fast. So is Hy.

Time of fib(9), using a simple recursive implementation.