Skip to content

Instantly share code, notes, and snippets.


Sulman Baig sulmanweb

View GitHub Profile
View chatgpt_service.rb
# @note: This service is used to call the OpenAI API to generate a response to a message
# @note: The API key is stored in the credentials file
# @param message [String] The message to generate a response for
# @param model [String] The model to use for the response [gpt-3.5-turbo, gpt-3.5-turbo-0301]
# @return [String] The generated response
# @example
#'What is your name?', 'gpt-3.5-turbo')
# => "\n\nI am an AI language model created by OpenAI, so I don't have a name. You can call me OpenAI or AI assistant."
# API Docs:
class ChatgptService
sulmanweb / error.bash
Created November 1, 2022 11:56
Error while bin/setup
View error.bash
/var/run/postgresql:5432 - accepting connections
[platform-postgresql] Granting SUPERUSER to toptal role
[platform-postgresql] Set development environment
Top level ::CompositeIO is deprecated, require 'multipart/post' and use `Multipart::Post::CompositeReadIO` instead!
Top level ::Parts is deprecated, require 'multipart/post' and use `Multipart::Post::Parts` instead!
WARNING: Zeitwerk defines the constant Karafka after the directory
sulmanweb / export_transaction_service.rb
Last active September 7, 2022 06:53
Export User Transactions in CSV and upload to Active Storage or send as attachment in email #rails
View export_transaction_service.rb
# frozen_string_literal: true
# app/services/export_services/export_transaction_service.rb
# Example:
#{ user: User,last}).call
#{ user: User.last, from_date: '2022-01-01', to_date: '2022-09-01'}).call
module ExportServices
# ExportTransactionService
class ExportTransactionService
# initialize the service with user, from_date and to_date and setting transactions accordingly
sulmanweb / email_job.rb
Created September 7, 2022 03:05
Send Emails using SendGrid SDK for Ruby in Rails using Dynamic SendGrid Email Templates
View email_job.rb
# frozen_string_literal: true
require 'sendgrid-ruby'
#### Example Call
# { name: },
# ENV.fetch('EXPORT_TEMPLATE', nil),
# [
sulmanweb / click_button.dart
Created June 21, 2022 09:16
Flutter Assignment 1
View click_button.dart
import 'package:flutter/material.dart';
class ClickButton extends StatelessWidget {
final VoidCallback onPressedHandler;
const ClickButton({Key? key, required this.onPressedHandler})
: super(key: key);
Widget build(BuildContext context) {
sulmanweb / create_document.rb
Created January 7, 2022 11:50
ActiveStorage, Ruby on Rails 7, GraphQL and RSpec
View create_document.rb
# app/graphql/mutations/create_document.rb
module Mutations
class CreateDocument < Mutations::BaseMutation
description "Create a document"
argument :doc, ApolloUploadServer::Upload, required: true, description: "The document to upload"
field :document, Types::Objects::DocumentType, null: false
field :code, Types::Enums::CodeEnum, null: false
sulmanweb / create_document.rb
Last active January 11, 2023 14:07
ActiveStorage file uploading in GraphQL API in Rails
View create_document.rb
# app/graphql/types/objects/document_type.rb
module Mutations
class CreateDocument < BaseMutation
description "creates a document for the user in the system"
argument :doc, ApolloUploadServer::Upload, required: true
field :document, Types::Objects::DocumentType, null: false
sulmanweb / api-rspec.yml
Created July 25, 2020 15:53
RSpec Rails API GitHub Actions Workflow
View api-rspec.yml
name: CI RSpec Tests
on: [push, pull_request]
- 'api/**'
- 'api/**'
sulmanweb / minimal-responsive-signup-page-with-tailwindcss.html
Last active March 1, 2020 09:51
Minimal Responsive SignUp Page with TailwindCSS
View minimal-responsive-signup-page-with-tailwindcss.html
<body class="bg-gray-100">
<div class="" id="sign-up-page">
<div class="max-w-xl mx-auto mt-2 md:mt-8 lg:mt-16">
<!-- Heading -->
<div class="bg-white p-8 shadow rounded-lg">
<!-- SVG Illustration -->
<!-- -->
<svg id="29e4b1a0-13d0-4a0f-9be2-3c3977a6a4ba" class="h-32 w-full mb-4 md:h-48" data-name="Layer 1" xmlns="" xmlns:xlink="" width="785" height="753.73" viewBox="0 0 785 753.73"><defs><linearGradient id="b4c3f788-9d51-49bd-96f9-c54f9fd51398" x1="452.8" y1="753.73" x2="452.8" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="gray" stop-opacity="0.25"/><stop offset="0.54" stop-color="gray" stop-opacity="0.12"/><stop offset="1" stop-color="gray" stop-opacity="0.1"/></linearGradient><linearGradient id="778ed1c4-cafd-494e-8a04-dc2b91aee6fd" x1="209.37" y1="339.46" x2="209.37" y2="101.61" xlink:href="#b4c3f788-9d51-49bd-96f9-c54f9fd51398"/><linearGradient id="92c6cb1b-63b4-4a00-
sulmanweb / .rspec
Last active October 4, 2019 09:59
RSpec files
View .rspec
--require spec_helper
--format documentation