Skip to content

Instantly share code, notes, and snippets.

View akerouanton's full-sized avatar

Albin Kerouanton akerouanton

View GitHub Profile

Gaufrette XYZ adapter

This repository is a metapackage for Gaufrette XYZ adapter.

For issues and PRs please go on KnpLabs/Gaufrette.

Documentation

Read the official Gaufrette documentation and the documentation for this adapter here.

@akerouanton
akerouanton / ResourceManager.js
Created January 4, 2017 01:10
pure js IOC container
export default class ResourceManager {
constructor (defs) {
this._defs = new Map(defs);
this._booted = new Map();
}
async get (name) {
if (!this._defs.has(name)) {
throw new Error(`There is no resource named "${name}".`);
} else if (!this._booted.has(name)) {
@akerouanton
akerouanton / redis-lifecycle-events-to-sns-to-sqs.js
Created September 1, 2016 09:21
Programatically create a SQS queue and subscribe it to a specific SNS topic
const AWS = require('aws-sdk');
// should be configurable
const ACCOUNT_ID = '';
const TOPIC_ARN = "arn:aws:sns:eu-central-1:"+ACCOUNT_ID+":"+TOPIC_ID;
const REGION = 'eu-central-1';
AWS.config.region = REGION;
AWS.config.apiVerison = 'latest';
const amqp = require('amqp');
const config = require('./config');
const logger = require('./lib/logger');
const Analysis = require('./lib/Analysis');
const Runner = require('./lib/Runner');
const connection = amqp.createConnection(config.amqp);
const runner = new Runner(config.docker);
connection.on('error', logger.error);
@akerouanton
akerouanton / dump-unix-socket.sh
Created August 21, 2016 17:03
Dump what goes throught a unix domain socket
socat -x -v UNIX-LISTEN:/tmp/debug-docker.sock,mode=777,reuseaddr,fork,ignoreeof UNIX-CONNECT:/var/run/docker.sock
COMPOSER_PATH=$(which composer)
composer() {
options=$(ls -1 /usr/lib/php5/20131226/ | egrep -v 'xdebug|opcache|mysql|wddx|pgsql'| sed -e 's/\(.*\)/ --define extension=\1/' | tr -d '\n')
bash -xc "php -n -d memory_limit=-1 $options $COMPOSER_PATH $*"
}
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@akerouanton
akerouanton / bastion.json
Created June 7, 2016 10:02
Cloudformation, ansible, SSH bastion & rsync
{
/** Should go into roles/your_playbook/files/bastion.json */
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"BastionInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"AvailabilityZone": "eu-central-1a",
"ImageId": "ami-ccc021a3",
"InstanceType": "t2.nano",
#!/bin/bash
CONTAINER_NAME=${CONTAINER_NAME:=docker-cleanup}
ps="`docker ps -a --format "{{.Names}}: {{.Status}}" | grep ${CONTAINER_NAME}`"
run_container () {
docker run -d \
--name docker-cleanup \
-v /var/run/docker.sock:/var/run/docker.sock:rw \
-v /var/lib/docker:/var/lib/docker:rw \
FROM jenkins:2.3
COPY plugins.txt /usr/share/jenkins/ref/
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/ref/plugins.txt
COPY basic-security.groovy /usr/share/jenkins/ref/init.groovy.d/basic-security.groovy