Skip to content

Instantly share code, notes, and snippets.

View vik-y's full-sized avatar

Vikas Yadav vik-y

View GitHub Profile
@vik-y
vik-y / amahi_design.md
Last active August 27, 2017 08:41
Design document to explain the changes done in amahi codebase

Design Document

Amahi now supports Docker. It is an open source software for automating the deployment of applications inside software containers. A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings.

For more information related to contianers refer to : https://www.docker.com/what-container

The idea was to get/build images of different applications and run them using docker on the hda. The benefit of using containers as opposed to the earlier method is that each container runs in an isolated environment. So they can each have different versions of different applications. For example we can have an app running on php5 and another app running on php7. Using this method if we had an image available for an app then we can directly run it using docker without any problems.

Architecture Overview : How it works? Diagram

@vik-y
vik-y / amahi.md
Last active August 22, 2017 15:14
Documentation for contianer apps in Amahi.

Amahi Documentation

Important Terms

Before going further in this document, understanding the following terms might be useful:

Problem Statement

Amahi supports one click install for different kind of apps. To add any app to amahi they have to be packaged properly. Each app might require a completely different environment to run and it might not be possible to provide that environment to every app because their can be dependnecy conflicts. For example some app might require php5 and some might require php7. We need a mechanism to address this concern such that we can add any app to Amahi irrespective of the technology stack that it might require or without version conflicts.

@vik-y
vik-y / CHANGES.MD
Last active July 15, 2017 08:48
Amahi Changes documentation

Dependencies Added

docker-api added in Gemfile. For more details on docker-api refer to https://github.com/swipely/docker-api

Modifications in app/models/app.rb

Firstly I added a few lines to make sure that docker.sock had right permissions. I was facing some issues because the process which runs installer doesn't have the permission to write to docker.sock. We tried various fixes but they didn't work and hence shifted to this temporary workaround

        def install_bg
+               # Change permissions of docker.sock file
+               if Rails.env=="production"
@vik-y
vik-y / runtime_error.cpp
Created July 5, 2017 07:35
Static variables, functions, references and everything , they behave in a very complex. This gist tries to experiment with those concepts
#include<iostream>
using namespace std;
int main()
{
int *ptr = NULL;
int &ref = *ptr; // We are initializing the reference.
cout << ref;
}
@vik-y
vik-y / chrome.sh
Created June 16, 2017 09:33
Run chrome inside a container.
xhost +
docker run -it --privileged --net host -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -v $HOME/Downloads:/root/Downloads --device /dev/snd --name chrome jess/chrome
@vik-y
vik-y / example.cpp
Last active May 28, 2017 03:39
Simple Examples of stack and queue in C++ Standard Library
// cplusplus reference can be useful
// http://www.cplusplus.com/reference/queue/queue/
#include <iostream>
#include <queue>
#include <stack>
int main(){
std::stack<int> s; // Define a stack which stores integers
std::queue<int> q; // Define a queue which stores integers
s.push(5); //Add an element to stack
@vik-y
vik-y / minheap.cpp
Last active June 19, 2017 13:17
MinHeap example in C++
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
// Modify the comparator function to change the heap type
struct comparator {
bool operator()(int i, int j) {
return i > j;
}
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time, re
browser = webdriver.Firefox()
def getUsers():
h = browser.find_element_by_id('#someuserlist')
users = h.get_attribute('innerHTML') # WIll return the html of users.
@vik-y
vik-y / install.sh
Last active March 29, 2017 09:59
A script to install rails using rbenv on fedora (Cross platform work in progress)
# Install all prerequisites
os=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
yum install git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL
@vik-y
vik-y / sql-connect.r
Created October 25, 2016 05:44
Use sqlite table in R
library("RSQLite")
# connect to the sqlite file
driver <- dbDriver("SQLite")
con = dbConnect(driver, dbname="<absolute-path-to-sqlite-file>")
# get a list of all tables
alltables = dbListTables(con)