Skip to content

Instantly share code, notes, and snippets.

View rakibulislam's full-sized avatar
🎯
Focusing

K M Rakibul Islam (Rakib) rakibulislam

🎯
Focusing
View GitHub Profile
CURRENT_DATE=`date -Ru | sed 's/+0000/GMT/'`
CHECKSUM=$(echo -n "application/json,,/transactions,$CURRENT_DATE" \
| openssl dgst -sha1 -binary -hmac "your-secret-key" \
| base64)
curl "https://apix.casiregalii.com/transactions" \
-X POST \
-d '{
"account_number": "12345678998",
"amount": "2000.0",
@rakibulislam
rakibulislam / subdomain-localhost-rails-5.md
Created February 8, 2018 03:48 — forked from indiesquidge/subdomain-localhost-rails-5.md
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
@rakibulislam
rakibulislam / rails http status codes
Created December 13, 2017 20:14 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@rakibulislam
rakibulislam / gist:dbebce065d6219fc68cbc5d296803d2d
Created December 8, 2017 21:42
Ruby AES Encryption using OpenSSL
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@rakibulislam
rakibulislam / SOLID.markdown
Created November 28, 2017 21:56 — forked from emaraschio/SOLID.markdown
SOLID Principles with ruby examples

#SOLID Principles with ruby examples

##SRP - Single responsibility principle A class should have only a single responsibility.

Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.

##OCP - Open/closed principle Software entities should be open for extension, but closed for modification.

@rakibulislam
rakibulislam / test_let_spec.rb
Created November 14, 2017 20:23 — forked from ernsheong/test_let_spec.rb
Exploring let and let! in RSpec. Puzzled by how let and let! behaves, I decided to take https://www.relishapp.com/rspec/rspec-core/docs/helper-methods/let-and-let and modify it further to inspect let and let!
require 'spec_helper'
# comment out `config.order = "random"` in spec_helper or run rspec with `--order default` configuration (just for illustration)
# I have Database Cleaner set up in spec_helper too
$count1 = 0
$count2 = 0
describe "let and let!" do
describe "let!" do

Keybase proof

I hereby claim:

  • I am rakibulislam on github.
  • I am rakib (https://keybase.io/rakib) on keybase.
  • I have a public key ASAIuXJ_ua2Q5531Z7ixDx40nj8Ynj-0f4SgSg0bG3nRPwo

To claim this, I am signing this object:

@rakibulislam
rakibulislam / js.md
Created August 25, 2017 14:52 — forked from nuhil/js.md
Javascript Handbook

Javascript Handbook

A hand crafted markdown document contains all major Javascript topics covered, taken from different sources. Brush Up your JS memory.

Comments


Single line comments start with //. For multi-line commands, you use /* ... */

// This is a single line comment
PASSWORD_FORMAT = /\A
(?=.{8,}) # Must contain 8 or more characters
(?=.*\d) # Must contain a digit
(?=.*[a-z]) # Must contain a lower case character
(?=.*[A-Z]) # Must contain an upper case character
(?=.*[[:^alnum:]]) # Must contain a symbol
/x
# validates_format_of :password,
# with: /\A(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*\z/
# fibonacci
# https://stackoverflow.com/questions/44837662/named-anonymous-functions-in-elixir/44837880#44837880
defmodule Fibonacci do
def get(n) when n <= 1, do: 1
def get(n), do: get(n-1) + get(n-2)
end
# Elixir how to iterate over two lists at once to produce a new list?
# https://stackoverflow.com/questions/44938494/elixir-how-to-iterate-over-two-lists-at-once-to-produce-a-new-list/44940454#44940454