Skip to content

Instantly share code, notes, and snippets.

View gourshete's full-sized avatar
🏠
Working from home

Swapnil Gourshete gourshete

🏠
Working from home
View GitHub Profile
@gourshete
gourshete / linux useful commands
Created August 11, 2021 17:54
Linux Useful Commands
1. Unistall package in ubuntu
sudo apt-get purge package_name
## remove dependencies as well
sudo apt-get purge --auto-remove package_name
@gourshete
gourshete / git commands
Created July 1, 2021 10:57
Rarely needed git commands
# git rename current branch
git branch -m <newname>
# change last commit message
git commit --amend
def hello
puts 'Hello world'
end
@gourshete
gourshete / expanded-routes.rb
Created June 26, 2019 14:37
Expanded routes for resource books
# config/routes.rb
Rails.application.routes.draw do
# resources :books becomes...
get '/books' => 'books#index'
get '/books/new' => 'books#new'
post '/books' => 'books#create'
get '/books/:id' => 'books#show'
get '/books/:id/edit' => 'books#edit'
put '/books/:id' => 'books#update'
@gourshete
gourshete / routes.rb
Created June 26, 2019 14:36
Simple routes for books resource
Rails.application.routes.draw do
resources :books
end
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
@gourshete
gourshete / web_server_calls_rack_app.rb
Last active July 1, 2021 10:59
Simple demonstration of web server calling to a Rack app and handling response
env = {
'REQUEST_METHOD' => 'GET',
'PATH_INFO' => '/hello',
'HTTP_HOST' => 'railsexamples.com',
# ...
}
status, headers, body = app.call(env)
status # => 200
@gourshete
gourshete / simple-nginx.conf
Last active June 25, 2019 07:44
Simple nginx config for serving assets
location /assets {
alias /var/myapp/public/assets;
gzip_static on;
gzip on;
add_header Cache-Control public;
}
@gourshete
gourshete / kubernetes_useful_commands.txt
Last active August 11, 2021 17:55
Kubernetes useful commands
### List all pods from all namespaces in current cluster
kubectl get pods --all-namespaces
### Get info about specific pod
kubectl describe pods --namespace pod-name pod-id
### SSH to a pod
kubectl exec -it -n insert_namespace_here -c web insert_pod_name_here -- bash
### Investigate CrashLoopBackOff state by finding previous container logs
@gourshete
gourshete / matrix-hacker.html
Created November 14, 2018 08:54
Code is fa!ling...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Gone!!!</TITLE>
<link rel="shortcut icon" HREF="/favicon.ico" TYPE="image/x-icon" />
<META NAME="description"
CONTENT="Swapnil Gourshete, tech enthu." />