Skip to content

Instantly share code, notes, and snippets.

View dineshPallapa's full-sized avatar

DineshPallapa dineshPallapa

View GitHub Profile
@jlblancoc
jlblancoc / Install_gcc7_ubuntu_16.04.md
Last active June 23, 2025 14:31
Installing gcc-7 & g++-7 in Ubuntu 16.04LTS Xenial

Run the following in the terminal:

Install the gcc-7 packages:

sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-7 -y

Set it up so the symbolic links gcc, g++ point to the newer version:

@satendra02
satendra02 / app.DockerFile
Last active November 19, 2024 17:28
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
@ssaunier
ssaunier / README.md
Created September 6, 2017 13:22
Quick caching in Rails (backed by Redis, with Heroku Redis Cloud add-on)

Add this line to your Gemfile and run bundle install

# Gemfile
gem "redis"

Create a new initializer to have a global $redis variable at hand:

@jnst
jnst / array.rb
Last active November 20, 2019 23:46
Difference of max and max_by in Ruby
array = [
{ id: 1, lv: 56 },
{ id: 2, lv: 12 },
{ id: 3, lv: 38 },
{ id: 4, lv: 99 },
{ id: 5, lv: 27 },
]
p array.max { |a, b| a[:lv] <=> b[:lv] } # => {:id:4, lv:99}
p array.max_by { |v| v[:lv] } # => {:id:4, lv:99}
@bschwartz757
bschwartz757 / async.js
Last active November 15, 2023 03:23
Async/await function to fetch data from multiple URLs in parallel
/* Client side, works in Chrome 55 and Firefox 52 without transpilation */
//https://blogs.msdn.microsoft.com/typescript/2016/11/08/typescript-2-1-rc-better-inference-async-functions-and-more/
async function fetchURLs() {
try {
// Promise.all() lets us coalesce multiple promises into a single super-promise
var data = await Promise.all([
/* Alternatively store each in an array */
// var [x, y, z] = await Promise.all([
// parse results as json; fetch data response has several reader methods available:
//.arrayBuffer()
@calvinh8
calvinh8 / 1.mongodb-aws-setup-guide.md
Last active June 17, 2025 17:38
MongoDB Setup Guide for AWS EC2 Instances with Auth Enabled

MongoDB AWS EC2 Setup Guide

You can see my latest update in my blog here https://medium.com/@calvin.hsieh/steps-to-install-mongodb-on-aws-ec2-instance-62db66981218

Credits:

Big thanks to Elad Nava and Shane Rainville for writing the above articles that allow me to conduct this guide. If by all means that I violated original post's copyright, please contact me.

@maxdbn
maxdbn / sidekiq.config
Last active May 23, 2021 12:05
Gracefully restarting Sidekiq on Elasticbeanstalk, only after it's done with the running jobs. Tested on: 64bit Amazon Linux 2016.09 v2.3.0 running Ruby 2.3 (Puma). Thanks to ssaunier for the original gist! https://gist.github.com/ssaunier/44bbebb9c0fa01953860
# Sidekiq interaction and startup script
commands:
create_post_dir:
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh":
mode: "000755"
owner: root
group: root
@wolivera
wolivera / read_write_json_file.rake
Last active February 22, 2019 12:12
Task to read, write and save a JSON file in Ruby
namespace :json do
# Usage: rake json:set_fields[file_name]
desc "Set some sample fields to an existing JSON file"
task :set_fields, [:file_name] => :environment do |t, args|
file_name = args[:file_name]
file_folder = Rails.root.join('app','assets','sample') # Step over the right folder
file = File.read(file_folder.join(file_name + ".json")) # Get the JSON file
fields = JSON.parse(form) # Get the JSON data to parse
updated_fields = set_fields(fields) # Set required to ruby Hash
@zentetsukenz
zentetsukenz / ruby_on_rails_deployment.md
Last active December 2, 2024 01:26
Deploy Ruby on Rails application with Docker Compose and Capistrano with ease

Docker

Files and Folders.

|
|\_ app
|...
|\_ docker
| |
import {applyMiddleware, compose, createStore} from 'redux'
import thunk from 'redux-thunk'
import {apiMiddleware} from 'redux-api-middleware'
import apiErrorMiddleware from './utils/apiError'
import rootReducer from './rootReducer'
import {routerMiddleware} from 'react-router-redux'
import {reduxSearch} from 'redux-search'
export default function configureStore(initialState = {}, history) {
// Compose final middleware and use devtools in debug environment