Skip to content

Instantly share code, notes, and snippets.

View anoobbava's full-sized avatar
🎯
Focusing

Anoob Bava anoobbava

🎯
Focusing
View GitHub Profile
@anoobbava
anoobbava / db.rake
Created August 31, 2022 05:49 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@anoobbava
anoobbava / benchmark_evaluator.rb
Created August 12, 2022 07:13
benchmark Evaluator
class BenchmarkEvaluator
def initialize(count)
@count = count
end
def execute
results = {}
Rails.logger.info '===== Enqueuing jobs'
benchmark = "Enqueuing #{@count} ActiveJob jobs"
results[benchmark] = Benchmark.measure do
image: user/docker_image_name
pipelines:
branches:
'*':
- step:
script:
- export DATABASE_URL=postgresql://pg_user:pg_user_password@localhost/pipelines
- bundle exec rails db:schema:load RAILS_ENV=test
Widget build(BuildContext context) {
return FutureBuilder(
future: fetchMovies(),
builder: (context, AsyncSnapshot snapshot) {
if (!snapshot.hasData) {
return Center(
child: Image.asset('assets/images/loading.gif'),
);
} else {
return HorizontalCards(snapshot.data.movies);
@anoobbava
anoobbava / detail.dart
Created October 17, 2021 15:14
for blogging
body: SingleChildScrollView(
child: Column(
children: <Widget>[
SizedBox(height: 10.0),
Text(
movieName,
style: TextStyle(fontSize: 22.0, fontWeight: FontWeight.bold),
),
SizedBox(height: 10.0),
Text(
@anoobbava
anoobbava / rspec_model_testing_template.rb
Created February 10, 2021 11:28 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@anoobbava
anoobbava / main.dart
Created October 4, 2020 17:16
main.dart for blogging
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import './pages/home_page.dart';
import './pages/search_movies.dart';
Future main() async {
await DotEnv().load('.env');
runApp(MyApp());
}
@anoobbava
anoobbava / app.DockerFile
Created February 7, 2020 10:30 — forked from satendra02/app.DockerFile
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
@anoobbava
anoobbava / main.dart
Created January 8, 2020 05:06
blog_data_dart_flutter
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(