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: "[email protected]",
@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 / 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 / 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 / main.dart
Last active October 25, 2018 07:48
Flutter Navigation Drawer
import 'package:flutter/material.dart';
void main() => runApp(new Keeper());
class Keeper extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Keeper',
home: new KeeperDrawer(),
@vemarav
vemarav / main.dart
Last active October 25, 2018 07:37
Flutter Navigation Drawer Header
import 'package:flutter/material.dart';
const String _AccountName = 'Aravind Vemula';
const String _AccountEmail = '[email protected]';
const String _AccountAbbr = 'AV';
void main() => runApp(new Keeper());
class Keeper extends StatelessWidget {
@override
@vemarav
vemarav / main.dart
Last active October 25, 2018 07:31
Flutter Navigation Drawer List
import 'package:flutter/material.dart';
const String _AccountName = 'Aravind Vemula';
const String _AccountEmail = '[email protected]';
const String _AccountAbbr = 'AV';
void main() => runApp(new Keeper());
class Keeper extends StatelessWidget {
@override
@vemarav
vemarav / main.dart
Last active October 25, 2018 07:45
Flutter Navigation Routing
import 'package:flutter/material.dart';
const String _AccountName = 'Aravind Vemula';
const String _AccountEmail = '[email protected]';
const String _AccountAbbr = 'AV';
void main() => runApp(new Keeper());
class Keeper extends StatelessWidget {
@override
@vemarav
vemarav / page_route_builder.dart
Last active November 13, 2023 17:37
Flutter Navigation Fade Transition
Navigator.of(context).push(
new PageRouteBuilder(
pageBuilder: (BuildContext context, _, __) {
return new Notes();
},
transitionsBuilder: (_, Animation<double> animation, __, Widget child) {
return new FadeTransition(
opacity: animation,
child: child
);