Skip to content

Instantly share code, notes, and snippets.

View prcongithub's full-sized avatar

Prashant Chaudhari prcongithub

View GitHub Profile
@prcongithub
prcongithub / gv
Last active October 20, 2020 11:50
Get version for any command without worrying about the parameter to pass
#!/bin/bash
if [ -z "$1" ]
then
echo "Comand Argument Is Missing! Try get_version java"
fi
commands=("--version" "-version" "version" "-v" "-V" "--v")
for i in "${commands[@]}"
@prcongithub
prcongithub / CRUDActions
Last active November 4, 2019 07:16
Simple Lightweight module for clean, dynamic and highly optimised API controllers
require 'active_support'
module CRUDActions
extend ActiveSupport::Concern
included do
before_action :set_resource, only: [:show, :update, :destroy]
after_action :set_response_headers, only: [:index]
end
# Returns count of records matching the scope
@prcongithub
prcongithub / rubygems_error
Created March 23, 2017 05:48
Rubygems 503
** [out :: companies1.ur-nl.com] Fetching from: https://rubygems.org/api/v1/dependencies?gems=thread_safe,minitest,method_source,concurrent-ruby,memcache-client,bcrypt-ruby,abstract,test-spec,camping,fcgi,mongrel,ruby-openid,thin,actionview,rack-mount,rails-dom-testing,rails-html-sanitizer,rails-deprecated_sanitizer,archive-tar-minitar,rcov,hoe,mime-types-data,facets,tlsmail,activejob,text-format,activerecord-deprecated_finders,rails-observers,mini_portile,racc,tenderlove-frex,rake-compiler,rexical,mini_portile2,weakling,pkg-config,rspec,launchy,httparty,aws-sdk-resources,aws-sdk-v1,aws-sdk-codebuild,aws-sdk-rekognition,aws-sdk-health,aws-sdk-sfn,aws-sdk-xray,aws-sdk-workspaces,aws-sdk-wafregional,aws-sdk-waf,aws-sdk-support,aws-sdk-storagegateway,aws-sdk-snowball,aws-sdk-simpledb,aws-sdk-shield,aws-sdk-servicecatalog,aws-sdk-swf,aws-sdk-ssm,aws-sdk-sqs,aws-sdk-sns,aws-sdk-sms,aws-sdk-ses,aws-sdk-s3,aws-sdk-route53domains,aws-sdk-route53,aws-sdk-redshift,aws-sdk-rds,aws-sdk-polly,aws-sdk-pinpoint,aws-sdk-ops
@prcongithub
prcongithub / release_4_17.rb
Last active September 28, 2016 07:56
Categories and Groups Migration
# Mark existing incomplete content as incomplete regardless of status and schedule
Sq::CheatSheet.all.each do |cheat_sheet|
if cheat_sheet.items.empty?
cheat_sheet.status = Sq::CheatSheet::Status::INCOMPLETE
cheat_sheet.save!
end
end
# Before Deployment
Sq::Lesson.all.each do |lesson|
if lesson.flash_cards.empty?
class IdPSettingsAdapter
def self.settings(company)
idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
settings = idp_metadata_parser.parse_remote(company.saml_metadata_url)
settings.assertion_consumer_service_url = "https://api.local.ur-nl.com:6080/users/saml/auth"
settings.issuer = "https://api.local.ur-nl.com:6080/saml/metadata"
settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
settings.authn_context = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
settings
end
@prcongithub
prcongithub / ubuntu_setup.md
Last active March 6, 2023 18:38
Setup Ubuntu with NodeJS, MySQL, Nginx, Postgres, Ruby, Rails etc.

Setup NodeJS

sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_0.10 | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g express
sudo npm install -g express-generator
sudo npm install -g nodemon
express demo_app -e ejs
cd demo_app
@prcongithub
prcongithub / autopgsqlbackup
Last active September 7, 2015 09:22 — forked from matthewlehner/autopgsqlbackup
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <axelseaa@amadmax.com>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@prcongithub
prcongithub / aws time difference fix
Created January 27, 2015 12:49
AWS Time difference fix
It's due to difference in time on your server and Amazon SES.
1. Check your linux server time by
> date
2. Check Amazon SES time by
> wget https://email.us-east-1.amazonaws.com --no-check-certificate --server-response
@prcongithub
prcongithub / nodejs
Last active December 28, 2015 18:19
NodeJS installation
yum groupinstall "Development Tools"
yum install gcc-c++
cd /usr/src
wget http://nodejs.org/dist/v0.10.4/node-v0.10.4.tar.gz
tar zxf node-v0.10.4.tar.gz
cd node-v0.10.4
./configure
make
make install
yum update npm
@prcongithub
prcongithub / hash_json.rb
Created September 26, 2013 09:10
hash to json
hash = {
:persons => []
}
persons.each do |person|
person_hash = {
:name => person.name,
:email => person.email,
:phone => []
}