Skip to content

Instantly share code, notes, and snippets.

View ankitsinghaniyaz's full-sized avatar
📺
Working Remote

Ankit Singhaniya ankitsinghaniyaz

📺
Working Remote
View GitHub Profile
@ankitsinghaniyaz
ankitsinghaniyaz / constant.css
Created March 14, 2019 18:29
Tailwind inspired CSS variable configuration
/*
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: //necolas.github.io/normalize.css/
*/
:root {
@ankitsinghaniyaz
ankitsinghaniyaz / webdev.yaml
Created May 21, 2020 19:13
Ansible file to setup a web develoipment environment in an Ubuntu(ish) OS
# 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=<your@email.com>"
<script>
// .vue files typically have 3 section
// 1.template - markup, 2.script - js, 3.style - css
// we are importing the csrf component it has two hidden input fields
// for csrf token and utf encoding
// creating a component helps us reuse it in multiple forms
import CSRF from 'components/shared/csrf.vue';
export default {
@ankitsinghaniyaz
ankitsinghaniyaz / csrf.vue
Created January 4, 2018 13:29
A simple wrapper to handle CSRF in Rails and Vue
<template>
<div class="">
<input name="utf8" type="hidden" value="✓">
<input type="hidden" name="authenticity_token" :value="csrf">
</div>
</template>
<script>
export default {
data: function() {
@ankitsinghaniyaz
ankitsinghaniyaz / nginx_proxy.config
Created April 20, 2017 17:15
Elastic Beankstalk Nginx configuration to supports /assets and /packs
# This is to enable WS support. Credits: # https://gist.github.com/Bubelbub/0a942a0d51a3d329897d
# THIS WORKS! for running the example 5.0.0.beta1 chat app on a single instance Elastic beanstalk AWS instance
files:
"/etc/nginx/conf.d/websockets.conf" :
content: |
upstream backend {
server unix:///var/run/puma/my_app.sock;
}
=begin
expected output is a 2d array
irb(main):001:0> TicketGenerator.new.generate
=> [[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]]
irb(main):002:0> TicketGenerator.new.generate
=> [[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]]
irb(main):003:0>
=end
@ankitsinghaniyaz
ankitsinghaniyaz / encryptor.rb
Created March 18, 2020 08:39
A simpler herlper library to encrypt and decrypt values
# Encryptor - is a library responsible for ecnrypting and decrypting values
# Inspired from - https://gist.github.com/wteuber/5318013
require 'openssl'
class Encryptor
SECRET_KEY = Rails.application.secrets.secret_key_base
def self.encrypt(text)
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
@ankitsinghaniyaz
ankitsinghaniyaz / index.html.erb
Created November 17, 2017 16:12
Vue generator generated files
<div id="posts-index-view">
<posts-index-view>
</posts-index-view>
</div>
<%= stylesheet_pack_tag 'posts/index' %>
<%= javascript_pack_tag 'posts/index' %>
<div id="<%= vue_component_kebab_name %>">
<%= vue_component_snippet %>
</div>
<%= stylesheet_pack_tag_snippet %>
<%= javascript_pack_tag_snippet %>
# 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