Skip to content

Instantly share code, notes, and snippets.

View vemarav's full-sized avatar
👨‍💻
Productive

Aravind Vemula vemarav

👨‍💻
Productive
View GitHub Profile
require 'aws-sdk'
ses = AWS.ses
AWS.config(
:access_key_id => '..',
:secret_access_key => '..,
:server => '..')
#puts ses.identities.map(:&identity)
ses.send_email(subject: "Hi",
from: "aravind@classpro.in",
@vemarav
vemarav / rescue_exception.rb
Last active February 7, 2018 17:34
Never rescue Exceptions in Ruby! as shown in below code.
begin
# code that raise an error
# or an exception
rescue Exception => e
# e is an Exception object contains
# information of the error
# e.message is the information
# about why error occurred and
# which object caused the error,
# where e.backtrace(Array) holds
begin
# code that raise an Error
# or an Exception
rescue StandardError => e
# Exceptions are not rescued. But,
# StandardError and subclasses
# of StandardError are rescued
puts e.message, e.backtrace,
# puts e.full_message, e.backtrace_locations
end
@vemarav
vemarav / rescue_type_error.rb
Created February 7, 2018 18:23
Rescue Type Error in case of wrong objects are passed as a parameter.
begin
puts "a" * 5 # => "aaaaa"
puts 1 + "" # => TypeError (string can't be coerced into Integer)
puts 5 * "a" # => Never Evaluate
rescue TypeError => e
puts e.message, e.backtrace
end
@vemarav
vemarav / game_errors.rb
Last active February 8, 2018 05:54
Defining Custom Errors for ruby library(ruby-gem)
# let say you have a class Game and its Audio
module Audio
class NoDeviceError < Error::ENODEV # (No such device)
end
end
class Game
include Audio
@vemarav
vemarav / network_utils.dart
Created April 13, 2018 05:43
Flutter Authentication Flow
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'auth_utils.dart';
class NetworkUtils {
static final String host = productionHost;
static final String productionHost = 'https://authflow.herokuapp.com';
static final String developmentHost = 'http://192.168.31.110:3000';
@vemarav
vemarav / network_utils.dart
Created April 13, 2018 05:43
Flutter Authentication Flow
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'auth_utils.dart';
class NetworkUtils {
static final String host = productionHost;
static final String productionHost = 'https://authflow.herokuapp.com';
static final String developmentHost = 'http://192.168.31.110:3000';
@vemarav
vemarav / network_utils.dart
Created April 13, 2018 05:43
Flutter Authentication Flow
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'auth_utils.dart';
class NetworkUtils {
static final String host = productionHost;
static final String productionHost = 'https://authflow.herokuapp.com';
static final String developmentHost = 'http://192.168.31.110:3000';
@vemarav
vemarav / network_utils.dart
Created April 13, 2018 05:43
Flutter Authentication Flow
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'auth_utils.dart';
class NetworkUtils {
static final String host = productionHost;
static final String productionHost = 'https://authflow.herokuapp.com';
static final String developmentHost = 'http://192.168.31.110:3000';
@vemarav
vemarav / network_utils.dart
Created April 13, 2018 05:43
Flutter Authentication Flow
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'auth_utils.dart';
class NetworkUtils {
static final String host = productionHost;
static final String productionHost = 'https://authflow.herokuapp.com';
static final String developmentHost = 'http://192.168.31.110:3000';