Skip to content

Instantly share code, notes, and snippets.

View sathiyaseelan's full-sized avatar

sathya sathiyaseelan

  • Singapore
View GitHub Profile
@sathiyaseelan
sathiyaseelan / pre-commit
Created February 20, 2017 18:54 — forked from wacko/pre-commit
Git hook to avoid commit debug lines (binding.pry console.log debugger...)
#!/usr/bin/env ruby
# Validates that you don't commit forbidden keywords to the repo
# You can skip this checking with 'git commit --no-verify'
exit 0 if ARGV.include?('--no-verify')
# Update this list with your own forbidden keywords
KEYWORDS = %w(binding.pry console.log debugger)
def red(text) "\033[31m#{text}\033[0m"; end
@sathiyaseelan
sathiyaseelan / pre-commit
Created February 20, 2017 18:54 — forked from wacko/pre-commit
Git hook to avoid commit debug lines (binding.pry console.log debugger...)
#!/usr/bin/env ruby
# Validates that you don't commit forbidden keywords to the repo
# You can skip this checking with 'git commit --no-verify'
exit 0 if ARGV.include?('--no-verify')
# Update this list with your own forbidden keywords
KEYWORDS = %w(binding.pry console.log debugger)
def red(text) "\033[31m#{text}\033[0m"; end
@sathiyaseelan
sathiyaseelan / count_set_bits.rb
Created February 24, 2017 04:26
Count number of set bits in a number (ruby)
#Brian Kernighan’s algorithm
def count_set_bits(num)
count = 0
while num != 0
num &= (num-1)
count += 1
end
count
end
@sathiyaseelan
sathiyaseelan / insert_singly_circular_ll.rb
Created April 2, 2017 08:06
Insert in Sorted Circular Linked List
def insert(new_node)
if tail == nil
new_node.next = new_node
tail = new_node
else
curr = tail.next
while curr.next != tail && curr.data <= new_node.data
curr = curr.next
@sathiyaseelan
sathiyaseelan / Selenium_with_headless_chrome.md
Created November 22, 2017 04:29 — forked from sathya-moneysmart/Selenium_with_headless_chrome.md
Capybara Setup for selenium with headless chrome

Setup for Capybara selenium with headless chrome

This gist contains all you need to setup capybara for selenium with headless chrome.

  1. Add these gems to the Gemfile under test group
  gem 'capybara'
  gem 'chromedriver-helper
  gem 'selenium-webdriver'
@sathiyaseelan
sathiyaseelan / Database cleaner configuration with multiple ORMs
Created November 24, 2017 10:49
Database cleaner configuration for apps using both mongoid and activerecord
# Database cleaner configuration for apps using both mongoid and activerecord.
When your apps using multiple ORMs, you might want to fine tune each ORM in different way.
This contains the sample configuration for using mongoid and activerecord together.
This shows how to use different startegy for different ORMs.
@sathiyaseelan
sathiyaseelan / Responsive Spec Helpers With Meta tags
Last active November 29, 2017 01:57
Helpers for Responsive feature Specs in Capybara
The responsive helpers are to help the developer with writing responsive specs.
All you have to do is, add `responsive_helper.rb` to the spec support directory.
And tag the specs with :mobile, :tablet for mobile and tablet size respectively.
If you don't use any tag, it would render the desktop size.
@sathiyaseelan
sathiyaseelan / Elixir and Go lang comparison.md
Last active December 3, 2017 22:25
Golang and Elixir comparision with respect to building JSON APIs

Spent some time to understand go and (elixir + (phoenix)) with respect to write APIs. I’ve considered only syntax, developer productivity and features like ORM.

Golang

Pros

  1. Faster than Elixir.
  2. GORM provides similar functionality as ActiveRecord

Cons

@sathiyaseelan
sathiyaseelan / golang_setup.md
Last active April 1, 2024 18:51
Basics to setup a golang project repo in your local

Simple Guide to setup Golang in your Mac and clone a repo.

Setup Go and workspace

Type go in terminal, to verify the installation.

  • Create a Go workspace and set GO PATH
@sathiyaseelan
sathiyaseelan / golang_env_vars_setup.md
Created January 8, 2018 06:03
Using different .env files for loading environment variables.

Currently the godotenv library doesn't support loading different .env files such as .env.test for testing .env.staging for staging.

Here's the small snippet, to support different environments file dynamically. Based on the @adamcohen comment.(option 1)

joho/godotenv#43 - Follow this issue for future changes

  1. Create a config struct as below
  2. Access the env values using the config struct
  3. Run the program with current ENVIRONMENT value set