Skip to content

Instantly share code, notes, and snippets.

Piyush awasthi piyushawasthi

Block or report user

Report or block piyushawasthi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
piyushawasthi / json_web_token.rb
Created Jul 29, 2019
Json web token implementation
View json_web_token.rb
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)
def self.decode(token)
piyushawasthi /
Created Jul 11, 2019
Install latest RVM, Ruby and Rails on ubuntu
sudo apt-get update &&
sudo apt-get install build-essential git-core curl &&
curl -L | 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 / validate.rb
Created Aug 17, 2018
validate whitespace characters such as spaces, tabs, or newlines
View validate.rb
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/) )
puts "Test-case-1"
tab = "foo bar"
tab1= "foo\tbar"
s = "foo bar"
st = "foo \t bar"
piyushawasthi /
Last active May 25, 2018
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 / cert_varification.rb
Created Jan 30, 2018
Verify Certificate from certificate store
View cert_varification.rb
require 'chef'
require 'mixlib/shellout'
require 'ffi'
require "chef/win32/api"
require 'openssl'
module Cert
extend Chef::ReservedNames::Win32::API
extend FFI::Library
piyushawasthi / Vagrantfile
Created Apr 17, 2017
Vagrantfile with chef_zero
View Vagrantfile
# -*- 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
You can’t perform that action at this time.