Skip to content

Instantly share code, notes, and snippets.

View iankiku's full-sized avatar
🏗️
#BuildInPublic

Ian Kiku iankiku

🏗️
#BuildInPublic
View GitHub Profile
@tykurtz
tykurtz / grokking_to_leetcode.md
Last active June 14, 2025 10:45
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

@tadast
tadast / ruby.yml
Created April 26, 2020 20:29
Example github actions config for Rails with postgres using DATABASE_URL
name: Ruby
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@jesster2k10
jesster2k10 / README.md
Last active June 7, 2025 17:43
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@ValchanOficial
ValchanOficial / gist:82c4fb2d6e9806a8dfb8c61f2440a6cc
Created December 24, 2019 13:22
How to select records from last 24 hours using SQL?
https://stackoverflow.com/a/1888569/11842937
In MySQL:
SELECT *
FROM mytable
WHERE record_date >= NOW() - INTERVAL 1 DAY
In SQL Server:
SELECT *
@kirillshevch
kirillshevch / rails_new_options_help.md
Last active May 21, 2025 13:01
"rails new" options for generating a new Rails application

Run rails new --help to see all of the options you can use to create a new Rails application:

Output for Rails 8+

Usage:
  rails COMMAND [options]

You must specify a command:
@soulmachine
soulmachine / jwt-expiration.md
Last active April 10, 2025 12:28
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@mankind
mankind / rails-jsonb-queries
Last active May 3, 2025 05:37
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@jnewman12
jnewman12 / Forms.md
Last active November 3, 2023 15:36
Forms, form_for, link_to lesson

Forms, form_for, and link_to


Lesson Objectives

  1. Understand forms and the ways we write them
  2. Understand the difference between form_tag and form_for
  3. Understand link_to and how we can use it to dynamically link our application together
@weedySeaDragon
weedySeaDragon / rake_examples.rake
Last active October 13, 2022 19:48
Rake examples - passing arguments to a rake task, calling one rake task from another, and more
# Also @see https://www.viget.com/articles/protip-passing-parameters-to-your-rake-tasks for
# examples using dependents and default values for arguments (see the updates at the end)
# Avdi Grimm's rake tutorial is really helpful. His section on FileLists:
# @see http://www.virtuouscode.com/2014/04/22/rake-part-2-file-lists/
# Rails:
# * to get access to Rails models, etc, your task must depend on the :environment task
# ex: task :my_task => :environment do ....
@bubenkoff
bubenkoff / download_sentry_data.py
Created April 22, 2016 19:51
Download all sentry events for a project. Useful for data processing
"""Download sentry data.
usage:
python download_sentry_data.py <org>/<project> <api_key>
"""
import requests
import csv