Skip to content

Instantly share code, notes, and snippets.

View jwaiswa7's full-sized avatar
🏠
Working from home

Joshua jwaiswa7

🏠
Working from home
View GitHub Profile
@jwaiswa7
jwaiswa7 / forio_proporsal.md
Last active November 6, 2024 09:08
Valutus APP

Valutus proporsal

This document describes how to use the forio platform to process information present in a model, and have it available to users through a web/mobile interface. It is assumed that the model has already been created and it's being used to provide information that will be rendered on different user devices.

The model will be processed by Forio and data rendered to the end users. Information provided relates to how forio can be used to process a given model and return information that can be used to render different end user pages.

This aims to research the interactions with Forio though there API service.

How it works.

@jwaiswa7
jwaiswa7 / current_project_response.json
Last active August 2, 2024 10:13
Project list response
{
"projects": [
{
"id": 12,
"name": "aute775bbf1-7540-4bb2-a9cf-6d6826cef02d",
"city": "Toymouth",
"state": "South Carolina",
"zipcode": "29078-0143",
"is_active": false,
"latitude": null,
@jwaiswa7
jwaiswa7 / README.md
Last active October 30, 2024 02:13
How to use refresh tokens with Devise JWT

REFRESH TOKENS WITH DEVISE

I have been using the devise gem with rails to implement user authentication for may applications. When implementing authentication though API requests, then I turn to the devise-jwt gem. I faced an issue when implementing refresh tokens with devise, as devise does not support access tokens. I still needed the superior authentication that devise provides, but needed to manually work with fresh tokens. After looking around the web, here is how I was able to modify the code to implement refresh tokens with devise-jwt.

Take for the example a user model to sore the user email and password.

@jwaiswa7
jwaiswa7 / create_company.rb
Created January 24, 2023 16:11
Hubspot integration
# Starting November 30, 2022, API keys will be sunset as an authentication method. Learn more about this change: https://developers.hubspot.com/changelog/upcoming-api-key-sunset and how to migrate an API key integration: https://developers.hubspot.com/docs/api/migrate-an-api-key-integration-to-a-private-app to use a private app instead.
require 'hubspot-api-client'
api_client = Hubspot::Client.new(access_token: 'YOUR_ACCESS_TOKEN')
properties = {
"city": "Cambridge",
"domain": "biglytics.net",
"industry": "Technology",
"name": "Biglytics",
[
  {
    "id": 1,
    "make": "BMW",
    "model": "M6",
    "year": 2021,
    "sku": "M0H41"
  },
 {
[
  {
    "section_1": [
      {
        "id": 1,
        "response": "response"
      },
      {
 "id": 2,
[
  {
    "section_1": [
      {
        "id": 1,
        "title": "question one",
        "type": "text"
      },
 {

This documents how to add an activity to a pipedrive deal or person

Please see here for details of required parameters

client = ::Pipedrive::Activity.new

params = {
      due_date: date,
 due_time: "12:00",

BinaryGap

Find longest sequence of zeros in binary representation of an integer.

Task description

A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.

For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. The number 15 has binary representation 1111 and has no binary gaps. The number 32 has binary representation 100000 and has no binary gaps.

Write a function:

a

Post.order(likes_count: :desc).preload(:user).map(&:email).uniq.first(5)

Am assuming the email is unique to every user

b

Controller