Skip to content

Instantly share code, notes, and snippets.

View dineshsprabu's full-sized avatar

Dineshprabu S dineshsprabu

  • Bangalore, India.
View GitHub Profile
@dineshsprabu
dineshsprabu / docker_contribution_helper.txt
Last active June 12, 2017 06:25
[Docker] Docker contribution helper
Ref: https://docs.docker.com/opensource/project/set-up-dev-env/#task-3-make-a-code-change
Connecting to an existing setup:
Start virtual machine
docker-machine start dp-vm
Check docker machine status
docker-machine status dp-vm
Change directory to moby
@dineshsprabu
dineshsprabu / activerecord_bug_test_helper.rb
Created June 8, 2017 05:45
[Rails][Activerecord] Active Record Bug Test Helper
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'activerecord', '4.2.8'
gem 'mysql2', '0.4.5'
gem 'byebug'
GEMFILE
system 'bundle install'
end
@dineshsprabu
dineshsprabu / xhr_request_promisified.js
Created May 6, 2017 08:03
[Javascript] XHR Request
function makeRequest (opts) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open(opts.method, opts.url);
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
resolve(xhr.response);
} else {
reject({
status: this.status,
@dineshsprabu
dineshsprabu / range_golang.md
Created April 26, 2017 06:33
[Golang] Using range in Golang

Golang 'range' method returns 2 values (index, value)

package main

import (
"fmt"
)

func main(){
@dineshsprabu
dineshsprabu / creating_new_docker_image_for_rails_app.md
Last active April 25, 2017 10:16
[Docker] Creating new docker container image for a rails app

New Rails app with Mysql in Docker

Create a Gemfile with content

source 'source 'https://rubygems.org'
gem 'rails', '4.2.7.1'

Create an empty file 'Gemfile.lock'

@dineshsprabu
dineshsprabu / docker-compose.yml
Last active April 25, 2017 10:12
[Docker] docker-compose yml example app - note-app
version: '2'
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_USER: root
MYSQL_PASSWORD: ''
MYSQL_DATABASE: 'noteapp_development'
ports:
@dineshsprabu
dineshsprabu / installing_docker-compose_on_docker-machine.txt
Created April 25, 2017 08:36
[Docker] Installing docker-compose on docker-machine
SSH to docker-machine with 'docker-machine ssh <machine-name>'
Run below commands for installing docker-compose.
curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > ./docker-compose
sudo mv ./docker-compose /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose
@dineshsprabu
dineshsprabu / docker_usage_helper.txt
Last active June 2, 2017 05:57
[Docker] Installing and using docker-machine and docker containers
Downloading and installing.
curl -L https://github.com/docker/machine/releases/download/v0.10.0/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && chmod +x /usr/local/bin/docker-machine
Adding VBox dependency
brew cask install virtualbox
Creating a new machine. 'default' would be the name of the machine.
docker-machine create --driver default
Listing the machines.
@dineshsprabu
dineshsprabu / configuring_pjax.txt
Last active April 25, 2017 05:45 — forked from livando/pjax
[RAILs] Pjax implementation in Rails
1) add gem
2) create vendor directory, and download script
3) configure application.rb
4) write js that points the trigger to the displayer
5) ensure the trigger has the correct jquery selector
6) ensure the displayer has the correct jquery selector
1) add gem
gem 'rack-pjax'
@dineshsprabu
dineshsprabu / oauth2_client_example_google_api.rb
Last active March 11, 2017 12:56
[RUBY][RAILS] Accessing Google API with Oauth2 using the Oauth2 gem
require 'oauth2'
# on the initial action.
# Get the client_id and client_secret for your app from
# from the developer console of the app to be authenticated.
client = OAuth2::Client.new('client_id', 'client_secret', :authorize_url => '/o/oauth2/auth' ,:site =>'https://accounts.google.com')
# The redirect uri is the endpoint on our app which can
# take the code/access_token sent for further access.
a_url = client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth2/callback')