Skip to content

Instantly share code, notes, and snippets.

View tejasbubane's full-sized avatar
💭
WFH 🏡

Tejas Bubane tejasbubane

💭
WFH 🏡
View GitHub Profile
@tejasbubane
tejasbubane / .rubocop.yml
Created August 4, 2019 07:51
Sample rubocop with sane config
AllCops:
TargetRubyVersion: 2.5
Exclude:
- 'config/**/*.rb'
- 'db/**/*.rb'
- '**/Rakefile'
- '**/config.ru'
- '**/spec_helper.rb'
- '**/rails_helper.rb'
- 'lib/tasks/db_extensions.rake'
@tejasbubane
tejasbubane / with_lock_spec.rb
Created March 26, 2019 15:28
Testing with_lock activerecord
# For stackoverflow question: https://stackoverflow.com/questions/55339129/how-to-test-lock-mechanism
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@tejasbubane
tejasbubane / rust-macros.rs
Created January 27, 2019 18:47
My notes while learning Rust Macros
// These are my notes from learning Rust Macros during a meetup
// https://www.meetup.com/rustox/events/256709420/
// I had not done any Rust before - but was still able to learn a lot!!
use std::collections::HashMap;
// All these macros run at compile time
// Simplest macro
macro_rules! hello {
@tejasbubane
tejasbubane / change_id_to_uuid.rb
Created December 17, 2018 13:57
Rails migration for changing primary key to postgres UUID
class ChangePlayersIdToUuid < ActiveRecord::Migration[5.2]
def change
# Enable extension
enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto')
# Create temp column and generate random uuids for existing data
add_column :players, :uuid, :uuid, default: "gen_random_uuid()", null: false
remove_column :players, :id
rename_column :players, :uuid, :id
@tejasbubane
tejasbubane / or-monoid.hs
Created November 8, 2018 11:04
Monoid for Or datatype in Haskell
data Or a b = Fst a | Snd b deriving (Eq, Show)
instance (Semigroup a, Semigroup b) => Semigroup (Or a b) where
(Fst a) <> (Fst a') = Fst (a <> a')
(Snd b) <> _ = Snd b
_ <> (Snd b) = Snd b
orGen :: (Arbitrary a, Arbitrary b) => Gen (Or a b)
orGen = do
a <- arbitrary
@tejasbubane
tejasbubane / flow-unions.js
Created June 28, 2018 19:51
Function Unions in Flow
type FunA = (foo: number, bar: string) => void;
type FunB = (foo: boolean, bar: number) => void;
type FunctionUnion =
| FunA
| FunB
declare var f1: FunA; // value of type FunA
declare var f2: FunB; // value of type FunB
@tejasbubane
tejasbubane / analysis.md
Last active June 24, 2018 17:11
Exercism Ecmascript Audit

Exercises in javascript track but not in ecmascript

  • forth
  • point-mutations
  • rational-numbers
  • reverse-string
  • variable-length-quantity
  • zipper

Exercises in ecmascript track but not in javascript

  • complex-numbers
@tejasbubane
tejasbubane / webpack.common.js
Created June 21, 2018 16:07
Webpack v4 config - separated dev and prod
"use strict";
const webpack = require("webpack");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const devMode = process.env.NODE_ENV !== "production";
module.exports = {
entry: ["babel-polyfill", "./src/index.js"],
@tejasbubane
tejasbubane / github-profiles-app.md
Last active June 21, 2018 09:51
Github profiles Application

Create a simple VueJS application with the following functionalities:

  1. The app will have two routes: /profiles and /repos - look at vue-router on how to create page routes.

  2. /profiles page will have a text box which will accept github username and on pressing submit will display following info about the user:

    • Full name
    • profile image
    • total number of repositories
    • top 5 repositories repositories (sort by most number of stars)
@tejasbubane
tejasbubane / example.js
Created March 13, 2018 13:40
Robot Simulator Exercism Fixed File
'use strict';
var VALID_DIRECTIONS = ['north', 'east', 'south', 'west'];
var INSTRUCTION_KEYS = {
A: 'advance',
L: 'turnLeft',
R: 'turnRight'
};
function Robot() {