Skip to content

Instantly share code, notes, and snippets.

Working Remote

Ankit Singhaniya ankitsinghaniyaz

Working Remote
View GitHub Profile
ankitsinghaniyaz / webdev.yaml
Created May 21, 2020 19:13
Ansible file to setup a web develoipment environment in an Ubuntu(ish) OS
View webdev.yaml
# Set up a development environment on an Ubuntu flavored linux distribution
# install and sets up:
# rbenv, nvm, mysql, postgres, redis
# vscode, slack, docker, chormium, tilix, heroku, postman, beekeeper, skype, kazam, peek and more
# setup an rsa key
# Usage:
# install ansible 2.7+ - latest
## sudo apt-add-repository ppa:ansible/ansible && sudo apt update && sudo apt install ansible
# run the playbook:
## ansible-playbook webdev.yaml -K -e "email=<>"
View tambola-ticket-generator.rb
expected output is a 2d array
=> [[nil, 10, 27, 31, 45, 54, 60, nil, nil], [nil, nil, 29, 32, nil, 58, 61, 77, nil], [5, 11, nil, nil, nil, nil, 64, nil, 88]]
=> [[2, nil, nil, nil, nil, 51, 68, 71, 82], [nil, 19, 23, 34, 45, 57, 69, 73, nil], [nil, nil, nil, 35, nil, nil, nil, 75, 83]]
ankitsinghaniyaz / encryptor.rb
Created March 18, 2020 08:39
A simpler herlper library to encrypt and decrypt values
View encryptor.rb
# Encryptor - is a library responsible for ecnrypting and decrypting values
# Inspired from -
require 'openssl'
class Encryptor
SECRET_KEY = Rails.application.secrets.secret_key_base
def self.encrypt(text)
cipher ='DES-EDE3-CBC').encrypt
ankitsinghaniyaz / constant.css
Created March 14, 2019 18:29
Tailwind inspired CSS variable configuration
View constant.css
Adapted from the idea of tailwindcss. I really liked the project and enjoyed using it.
But I wanted a simpler light weight solution. I really liked the idea of having things in a constants
thus avoid spilling the value throughout the application! With the indtroduction of css varialbes I found this to be
very elegent and productive.
Prefered usage with in conjunction of normailize.css
http: //
:root {
ankitsinghaniyaz / csrf.vue
Created January 4, 2018 13:29
A simple wrapper to handle CSRF in Rails and Vue
View csrf.vue
<div class="">
<input name="utf8" type="hidden" value="✓">
<input type="hidden" name="authenticity_token" :value="csrf">
export default {
data: function() {
ankitsinghaniyaz / index.html.erb
Created November 17, 2017 16:12
Vue generator generated files
View index.html.erb
<div id="posts-index-view">
<%= stylesheet_pack_tag 'posts/index' %>
<%= javascript_pack_tag 'posts/index' %>
View vue_generator.rb
# the generator extends from NamedBase base class which makes sure
# alleast a name must be provided to the generator
class VueGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
# if you remember all the public methods will be executed in the defined order
# this method will create a JavaScript file using the javascript.erb template
# in the location defined as the next params
# we will look into the content of the templates next
View html.erb
<div id="<%= vue_component_kebab_name %>">
<%= vue_component_snippet %>
<%= stylesheet_pack_tag_snippet %>
<%= javascript_pack_tag_snippet %>
View vue-usage
Create Vue files corresponding to the Rails views
rails generate vue [namespace]/[controller]/action
This will create:
View view-devise-registrations-new.html.erb
<!-- this is the same id we reffered in the vue file -->
<!-- for consisteny, I also follow a convention in this -->
<!-- {folder-paths}-{action}-view -->
<div id="devise-registrations-new-view">
<!-- we talked about passing the validation error to vue -->
<!-- here is how easy it is to do this -->
<devise-registrations-new-view :errors="<%= resource.errors.full_messages %>">