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 / README.md
Last active April 14, 2024 23:43
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

@jwaiswa7
jwaiswa7 / typeform.json
Created August 21, 2020 14:04
typeform_data
{
"event_id": "01EFF9JWR37JH5CM9C116RWAK5",
"event_type": "form_response",
"form_response": {
"form_id": "dEhLsDuN",
"token": "f2cenm41cbmqplmumal4nf2cenm3yom8",
"landed_at": "2020-08-11T17:03:03Z",
"submitted_at": "2020-08-11T17:37:44Z",
"hidden": {
"car_id": "f91e0491-9d7a-4b7f-abb2-4c9b795155e6",

This is for the Track Covid application API calls

Main endpoint is http://35.179.92.187/

Register user

Receive user details

Request:
Method: Get