Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Anoob Bava anoobbava

🎯
Focusing
View GitHub Profile
@anoobbava
anoobbava / rspec_model_testing_template.rb
Created Feb 10, 2021 — forked from kyletcarlson/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…
View rspec_model_testing_template.rb
# 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 Oct 4, 2020
main.dart for blogging
View main.dart
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 Feb 7, 2020 — forked from satendra02/app.DockerFile
docker+rails+puma+nginx+postgres (Production ready)
View app.DockerFile
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 Jan 8, 2020
blog_data_dart_flutter
View main.dart
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
View updateTodoMutation.js
updateTodoMutation (state, todo) {
let index = state.todos.findIndex(element => element.id === todo.id)
state.todos[index] = todo
}
View ApiHelper.js
async updateTodo (todo) {
const updatedTodoHash = { is_completed: todo.is_completed }
const response = await axios.put('todos/' + todo.id, updatedTodoHash)
return response.data
}
View updateTodoAction.js
updateTodoAction ({ commit }, todo) {
return new Promise((resolve, reject) => {
ApiHelper.updateTodo(todo)
.then(response => {
commit('updateTodoMutation', response)
resolve(response)
})
.catch(error => {
reject(error)
})
View updateTodo.vue
updateTodo(todo) {
this.updateTodoAction(todo)
.then(() => SweetAlert.successfulLogin())
.catch(() => SweetAlert.failureLogin())
}
View Home.vue
<v-checkbox
v-model="task.is_completed"
color="info darken-3"
@change="updateTodo(task)"
>
View saveTodoMutation.js
saveTodoMutation (state, todo) {
state.todos = [...state.todos, todo]
}