Skip to content

Instantly share code, notes, and snippets.

@shreyaskarnik
shreyaskarnik / Instructions.md
Last active March 24, 2023 15:35
Route Docker Logs to ELK Stack
  • With Docker 1.8.0 shipped new log-driver for GELF via UDP, this means that the logs from Docker Container(s) can be shipped directly to the ELK stack for further analysis.
  • This tutorial will illustrate how to use the GELF log-driver with Docker engine.
  • Step 1: Setup ELK Stack:
    • docker run -d --name es elasticsearch
    • docker run -d --name logstash --link es:elasticsearch logstash -v /tmp/logstash.conf:/config-dir/logstash.conf logstash logstash -f /config-dir/logstash.conf
    • Note the config for Logstash can be found at this link
    • docker run --link es:elasticsearch -d kibana
  • Once the ELK stack is up now let's fire up our nginx container which ships its logs to ELK stack.
  • LOGSTASH_ADDRESS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' logstash)
  • `docker run -d --net=host --log-driver=gelf --log-opt gelf-address=u
@LeeMendelowitz
LeeMendelowitz / README.md
Last active December 6, 2018 23:02
D3 Dynamic Table with Nested Data

This script is another demonstration of the update, enter, and exit selections in D3. The script also makes use of key functions to bind data to each row, and transitions to animate opacity and delay the removal of rows. This script demonstrates nested data, where an array of values is bounded to each row (<tr>), and then a single value is bound to each cell (<td>) element in the row.

Each row of the table has a unique letter key, which is displayed as the first cell. The remainder of the row is an array of random digits. At each iteration:

  1. A new set of letter keys is randomly selected from the alphabet.
  2. For each letter in the set, a new row with random data will be inserted in the table if the letter is not already in the table.
  3. Any row in the table with a key which is not in the new set is removed.
  4. The number of columns in the table is randomly adjusted. If the new number of columns is larger than the current table, random data is appended to each row. Otherwise, cel
anonymous
anonymous / README.md
Created February 28, 2014 17:47
Integrating D3 with a CouchDB database

Part 1

Proof of concept

Say, you want to save your D3 application in a CouchDB database. This is just a proof of concept that this is possible. I use the »Focus + Context« diagram by Mike Bostock (http://bl.ocks.org/1667367) as an example.

Prerequisites:

googleapis
.discover('analytics', 'v3')
.execute(function(err, client) {
if (err) {
utils.applog('error', {from: "lib/fetch/analytics.js", value: err, reference: "getAnalytics", resource: user_id});
return;
}
// Array that contains all request
var requests_list = [
{metrics: "ga:visits,ga:newVisits,ga:percentNewVisits,ga:newVisits,ga:pageviews,ga:visitBounceRate,ga:pageviewsPerVisit,ga:avgTimeOnSite"},
@mustafaturan
mustafaturan / ruby.2.6.3-setup.sh
Last active February 2, 2023 10:08
ruby 2.6.3 setup for centos 6.x
#!/usr/bin/env bash
# repository
cd /tmp
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
# system update
yum -y update
yum -y groupinstall "Development Tools"
yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@Redsandro
Redsandro / gist:5473335
Created April 27, 2013 14:30
jQuery plugin - Turn raw JSON code into formatted, indented, color-coded collapsible code.
/*
* Collapsible JSON Formatter - Formatter and colorer of raw JSON code
*
* jQuery Json Formatter plugin v0.1.3
*
* Usage
* -----
*
* $('#target').jsonFormat('#source'); // or
* $('#target').jsonFormat('#source', {options override defaults}); // see jf.config
@davidensinger
davidensinger / adding-open-graph-tags-to-jekyll.html
Last active May 31, 2024 11:00
Adding Open Graph Tags to Jekyll
<meta content="{{ site.title }}" property="og:site_name">
{% if page.title %}
<meta content="{{ page.title }}" property="og:title">
{% else %}
<meta content="{{ site.title }}" property="og:title">
{% endif %}
{% if page.title %}
<meta content="article" property="og:type">
{% else %}
<meta content="website" property="og:type">
@ruliana
ruliana / bootstrap-chef-solo.sh
Last active December 14, 2015 11:28
Bootstrap Chef Solo for Ruby-2.0.0-p0 (run it with "sudo" because it installs ruby in "/usr/local")
#!/usr/bin/env bash
# Pre-requisites
apt-get -y update
sudo apt-get --no-install-recommends -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev
# Download and compile Ruby 2.0.0-p0
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -xvzf ruby-2.0.0-p0.tar.gz
@oroce
oroce / bunyan-pipe-to-mongodb.js
Created November 10, 2012 21:29
pipe bunyan logger into mongodb (even with node-restify)
var mongoCol = require( "mongo-col" ),
mongoStream = require( "mongo-stream" ),
mongoInsertStream = mongoStream( mongoCol( "piped-collection", null, {
dbOptions:{
safe: true
}
})),
Logger = require( "bunyan" );
new Logger({