Skip to content

Instantly share code, notes, and snippets.

View ravibhure's full-sized avatar

Ravi ravibhure

View GitHub Profile
@ravibhure
ravibhure / UbuntuLXCPortForwarding.md
Created February 14, 2017 12:25
Ubuntu LXC Port Forwarding

Ubuntu LXC Port Forwarding

So you have a service running in an LXC container behind a bridge, and you need ports forwarded for that service. In this case, we'll use Minecraft as an example, which runs on port 25565. Our container's IP is 10.0.3.116.

sudo iptables -t nat -I PREROUTING -p tcp -d $PUBLICIP --dport 25565 -j DNAT --to 10.0.3.116:25565
sudo iptables -A FORWARD -p tcp -d 10.0.3.116 --dport 25565 -j ACCEPT
@ravibhure
ravibhure / install_docker.sh
Created February 6, 2017 05:27
Install Docker
#!/bin/bash
# install docker on ubuntu
# https://docs.docker.com/engine/installation/linux/ubuntu/
myname=`id -u -n`
sudo apt-get update
sudo apt-get -y install curl \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
@ravibhure
ravibhure / Query-Registry.ps1
Created January 24, 2017 04:00 — forked from so0k/Query-Registry.ps1
Query a docker registry v2/_catalog endpoint from powershell
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
$Filter=".*",
#TODO: handle https & no basic auth as well..
$RegistryEndpoint = "registry.mysite.com",
$UserName = "user",
$Password = "password"
)
@ravibhure
ravibhure / headless.md
Created December 29, 2016 13:01 — forked from addyosmani/headless.md
So, you want to run Chrome headless.
@ravibhure
ravibhure / redis_and_resque.mkd
Created November 25, 2016 08:21 — forked from Diasporism/redis_and_resque.mkd
How to configure Redis and Resque for your Rails app.

Redis and Resque

What this guide will cover: the code you will need in order to include Redis and Resque in your Rails app, and the process of creating a background job with Resque.

What this guide will not cover: installing Ruby, Rails, or Redis.

Note: As of this writing I am still using Ruby 1.9.3p374, Rails 3.2.13, Redis 2.6.11, and Resque 1.24.1. I use SQLite in development and Postgres in production.

Background jobs are frustrating if you've never dealt with them before. Over the past few weeks I've had to incorporate Redis and Resque into my projects in various ways and every bit of progress I made was very painful. There are many 'gotchas' when it comes to background workers, and documentation tends to be outdated or scattered at best.

@ravibhure
ravibhure / git_rebase.md
Last active April 11, 2025 09:30
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@ravibhure
ravibhure / tproxy.md
Last active November 15, 2016 09:36
Transparent proxy support

Transparent proxy support

This feature adds Linux 2.2-like transparent proxy support to current kernels. To use it, enable the socket match and the TPROXY target in your kernel config. You will need policy routing too, so be sure to enable that as well.

  1. Making non-local sockets work ================================
@ravibhure
ravibhure / ansible-local.py
Last active November 7, 2016 04:54
Ansible dynamic inventory Terraform
#!/usr/bin/env python
# vim:syntax=python
import argparse
import collections
import json
import os
import os.path
from ansible.vars import VariableManager
@ravibhure
ravibhure / bootstrap_ansible_node.sh
Last active May 19, 2017 05:52
Bootstrap for ansiblized node
#!/bin/bash
# Bootstrap for ansiblized node
# Author: Ravi Bhure <[email protected]>
# Usages: curl -L https://raw.githubusercontent.com/ravibhure/terraform-provisioner-ansible/master/bootstrap_ansible_node.sh | sudo bash
machine=`uname -m`
os=`uname -s`
if test -f "/etc/lsb-release" && grep -q DISTRIB_ID /etc/lsb-release && ! grep -q wrlinux /etc/lsb-release; then
platform=`grep DISTRIB_ID /etc/lsb-release | cut -d "=" -f 2 | tr '[A-Z]' '[a-z]'`
@ravibhure
ravibhure / socket_state.sh
Created September 14, 2016 12:13
print number of sockets in different tcp state
sudo netstat -ant | awk '{print $6}' | tr ')' ' ' | sort | uniq -c