Skip to content

Instantly share code, notes, and snippets.

View piyushawasthi's full-sized avatar

Piyush awasthi piyushawasthi

  • Chef Software
  • Pune
View GitHub Profile
@piyushawasthi
piyushawasthi / Vagrantfile
Created April 17, 2017 12:52
Vagrantfile with chef_zero
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@piyushawasthi
piyushawasthi / cert_varification.rb
Created January 30, 2018 10:33
Verify Certificate from certificate store
require 'chef'
require 'mixlib/shellout'
require 'ffi'
require "chef/win32/api"
require 'openssl'
module Cert
extend Chef::ReservedNames::Win32::API
extend FFI::Library
@piyushawasthi
piyushawasthi / AzureImageCreate.md
Last active May 25, 2018 13:54
Easy way to Create VM Image in Azure

Create VM Image in Azure

1: Create VM to create Image for same.

a: Open the Command Prompt window as an administrator.
b: Change the directory to %windir%\system32\sysprep
   
   cd C:\Windows\system32\sysprep
   
c: run sysprep.exe
@piyushawasthi
piyushawasthi / validate.rb
Created August 17, 2018 08:41
validate whitespace characters such as spaces, tabs, or newlines
def invalid_name?(pname)
( pname.is_a?(Array) && pname.any? { |name| name.index(/\s|\\t|\\n/) } ) || ( pname.is_a?(String) && pname.to_s.index(/\s|\\t|\\n/) )
end
puts "Test-case-1"
tab = "foo bar"
tab1= "foo\tbar"
s = "foo bar"
st = "foo \t bar"
@piyushawasthi
piyushawasthi / install_r3.sh
Created July 11, 2019 10:00
Install latest RVM, Ruby and Rails on ubuntu
sudo apt-get update &&
sudo apt-get install build-essential git-core curl &&
curl -L get.rvm.io | bash -s stable &&
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc &&
. ~/.bashrc &&
sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev \
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 \
libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison \
subversion &&
rvm autolibs enable &&
@piyushawasthi
piyushawasthi / json_web_token.rb
Created July 29, 2019 07:15
Json web token implementation
require 'jwt'
class JsonWebToken
def self.encode(payload, expiration = Rails.application.secrets.jwt_expiration_seconds.to_i.seconds.from_now)
payload = payload.dup
payload[:exp] = expiration.to_i
JWT.encode(payload, Rails.application.secrets.hmac_secret_key)
end
def self.decode(token)