Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home forever and ever

Max Claus Nunes maxcnunes

🏠
Working from home forever and ever
View GitHub Profile
View git-lol.sh
# setting a new alias
git config --global --add alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit --all"
# using the new alias
git lol
@maxcnunes
maxcnunes / docker-elk.sh
Created Mar 29, 2015
Docker ELK - Logs agregator for Docker containers
View docker-elk.sh
/usr/bin/docker run \
--restart=always \
-d \
--name logs-elasticsearch_1 \
-v /data/logs_elasticsearch/config:/usr/share/elasticsearch/config -v /data/logs_elasticsearch/data:/usr/share/elasticsearch/data \
-p 172.17.42.1:9200:9200 -p 172.17.42.1:9300:9300 \
elasticsearch:1.5.0
/usr/bin/docker run \
View update-coreos-cloud-config.sh
#!/bin/bash
SERVER_IP=<MY_SERVER_IP>
# copy cloud-config.yml to the server
scp cloud-config.yml core@$SERVER_IP:~/
# validate cloud-config file
ssh core@$SERVER_IP "coreos-cloudinit -validate --from-file ~/cloud-config.yml"
if [[ $? == "0" ]]; then
View __init__.py
from flask import Flask, render_template, redirect, url_for
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
# Basic Routes #
View max.zsh-theme
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$FG[245]%}git:("
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$FG[245]%})%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_SVN_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX
ZSH_THEME_SVN_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX
ZSH_THEME_SVN_PROMPT_DIRTY=$ZSH_THEME_GIT_PROMPT_DIRTY
ZSH_THEME_SVN_PROMPT_CLEAN=$ZSH_THEME_GIT_PROMPT_CLEAN
vcs_status() {
View libxmljs-finding-xml-elements-with-namespaces-using-xpath.js
var libxmljs = require("libxmljs");
var xml = [
'<?xml version="1.0" encoding="utf-8"?>',
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">',
' <soap:Body>',
' <Response xmlns="http://tempuri.org/">',
' <Result>',
' <client xmlns="">',
' <msg>SEARCH OK.</msg>',
' <code>0</code>',
View purge-docker-vols.py
#!/usr/bin/env python
"""
Check all existing Docker containers for their mapped paths, and then purge any
zombie directories in docker's volumes directory which don't correspond to an
existing container.
"""
import logging
import os
import sys
@maxcnunes
maxcnunes / example1.js
Created Oct 8, 2014
Javascript Double Not-Operator(!!)
View example1.js
if (typeof x !=== 'undefined' && x !=== '') {
// not emtpy
}
View node.util.inspect.sublime-snippet
<snippet>
<content><![CDATA[
console.log(${1:'\n---->${2}', }require('util').inspect(${3:arguments}, { depth: null, colors: true }));
]]></content>
<tabTrigger>inspect</tabTrigger>
<scope>source.js</scope>
<description>nodejs - util.inspect</description>
</snippet>
View curl-post-json.sh
curl -H "Content-Type: application/json" -d '{ "field": "value" }' http://someurl.com