Skip to content

Instantly share code, notes, and snippets.

@eunomie
eunomie / README.md
Created April 27, 2017 09:44
How to send containers log to ELK using gelf log driver

Send docker logs to ELK through gelf log driver

There's so many way to send logs to an elk... logspout, filebeat, journalbeat, etc.

But docker has a gelf log driver and logstash a gelf input. So here we are.

Here is a docker-compose to test a full elk with a container sending logs via gelf.

@rose-pace
rose-pace / UrlHelper.js
Last active June 18, 2018 15:05
JavaScript helper object for dealing with urls
var UrlHelper = function (location) {
this.protocol = '';
this.host = '';
this.path = '';
this.queryValues = {};
this.initQueryValues = function (search) {
var vals = {};
if (search) {
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@JamesMessinger
JamesMessinger / IndexedDB101.js
Last active May 19, 2024 18:56
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@bbengfort
bbengfort / cipher-func.js
Last active December 20, 2021 01:13
Encrypting and decrypting aes128 ciphers with an initialization vector in node.js.
var crypto = require('crypto');
var secret = crypto.randomBytes(24);
function encrypt(plaintext) {
var cipher = crypto.createCipher('aes-256-cbc', secret);
cipher.setAutoPadding(false);
var ciphertext = '';
for (var i=0; i < plaintext.length; i+=16) {
ciphertext += cipher.update(plaintext.substr(i, i+16), 'utf8', 'base64');
@rosenfeld
rosenfeld / parseParams.coffee
Created August 7, 2012 19:06
Parse query params in CoffeeScript
# for simple use case - doesn't take into account multiple occurrences
parseParams = (search = window.location.search)->
d = (str)-> decodeURIComponent str.replace /\+/g, ' '
query = search.substring 1
regex = /(.*?)=([^\&]*)&?/g
params = {}
params[d(m[1])] = d(m[2]) while m = regex.exec query
params
@brendanhay
brendanhay / rabbitmq.config
Created December 16, 2011 11:10
Example Shovel Config
[
{rabbit, [
%% snip...
]},
{rabbitmq_shovel, [
{shovels, [
{'MUTHA-SHOVELER', [
{sources, [
{broker, "amqp://"}
@jarus
jarus / base64.js
Created April 29, 2011 07:52 — forked from stubbetje/base64.js
Base64 encode and decode in javascript
var Base64 = {
characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ,
encode: function( string )
{
var characters = Base64.characters;
var result = '';
var i = 0;
do {
@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client